diff options
| author | Jon A. Cruz <jon@joncruz.org> | 2012-05-03 02:06:15 +0000 |
|---|---|---|
| committer | Jon A. Cruz <jon@joncruz.org> | 2012-05-03 02:06:15 +0000 |
| commit | 3198928b491fb91cdd177505c051659f89aa4158 (patch) | |
| tree | 8cf8b51a36ba7e865d3c41984746ae35a26c9e6a /src | |
| parent | Find dialog: better user message (diff) | |
| download | inkscape-3198928b491fb91cdd177505c051659f89aa4158.tar.gz inkscape-3198928b491fb91cdd177505c051659f89aa4158.zip | |
Adding base configurable sizing of controls/handles.
(bzr r11316)
Diffstat (limited to 'src')
33 files changed, 593 insertions, 541 deletions
diff --git a/src/display/guideline.cpp b/src/display/guideline.cpp index dad989655..652f4e2d7 100644 --- a/src/display/guideline.cpp +++ b/src/display/guideline.cpp @@ -5,6 +5,7 @@ * Lauris Kaplinski <lauris@kaplinski.com> * Johan Engelen * Maximilian Albert <maximilian.albert@gmail.com> + * Jon A. Cruz <jon@joncruz.org> * * Copyright (C) 2000-2002 Lauris Kaplinski * Copyright (C) 2007 Johan Engelen @@ -24,6 +25,9 @@ #include "desktop.h" #include "sp-namedview.h" #include "display/sp-canvas.h" +#include "ui/control-manager.h" + +using Inkscape::ControlManager; static void sp_guideline_class_init(SPGuideLineClass *c); static void sp_guideline_init(SPGuideLine *guideline); @@ -228,7 +232,8 @@ static double sp_guideline_point(SPCanvasItem *item, Geom::Point p, SPCanvasItem SPCanvasItem *sp_guideline_new(SPCanvasGroup *parent, char* label, Geom::Point point_on_line, Geom::Point normal) { SPCanvasItem *item = sp_canvas_item_new(parent, SP_TYPE_GUIDELINE, NULL); - SPCanvasItem *origin = sp_canvas_item_new(parent, SP_TYPE_CTRLPOINT, NULL); + SPCanvasItem *origin = ControlManager::getManager().createControl(parent, Inkscape::CTRL_TYPE_ORIGIN); + ControlManager::getManager().track(origin); SPGuideLine *gl = SP_GUIDELINE(item); SPCtrlPoint *cp = SP_CTRLPOINT(origin); diff --git a/src/display/sp-canvas-item.h b/src/display/sp-canvas-item.h index 0a6d343b2..8baa09401 100644 --- a/src/display/sp-canvas-item.h +++ b/src/display/sp-canvas-item.h @@ -41,6 +41,23 @@ typedef struct _SPCanvasItemClass SPCanvasItemClass; #define SP_IS_CANVAS_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_CANVAS_ITEM)) #define SP_CANVAS_ITEM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), SP_TYPE_CANVAS_ITEM, SPCanvasItemClass)) +namespace Inkscape +{ + +// Rough initial set. Most likely needs refinement. +enum ControlType { + CTRL_TYPE_UNKNOWN, + CTRL_TYPE_ADJ_HANDLE, + CTRL_TYPE_ANCHOR, + CTRL_TYPE_POINT, + CTRL_TYPE_ROTATE, + CTRL_TYPE_SIZER, + CTRL_TYPE_SHAPER, + CTRL_TYPE_ORIGIN +}; + +} // namespace Inkscape + /** * An SPCanvasItem refers to a SPCanvas and to its parent item; it has * four coordinates, a bounding rectangle, and a transformation matrix. @@ -51,10 +68,15 @@ struct SPCanvasItem : public GtkObject { SPCanvas *canvas; SPCanvasItem *parent; - double x1, y1, x2, y2; + double x1; + double y1; + double x2; + double y2; Geom::Rect bounds; Geom::Affine xform; - + + Inkscape::ControlType ctrlType; + // Replacement for custom GtkObject flag enumeration gboolean visible; gboolean need_update; @@ -74,6 +96,9 @@ struct _SPCanvasItemClass : public GtkObjectClass { void (* viewbox_changed) (SPCanvasItem *item, Geom::IntRect const &new_area); }; +/** + * Constructs new SPCanvasItem on SPCanvasGroup. + */ SPCanvasItem *sp_canvas_item_new(SPCanvasGroup *parent, GType type, const gchar *first_arg_name, ...); G_END_DECLS diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 0f650bf4a..22aad2442 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -405,31 +405,30 @@ void sp_canvas_item_class_init(SPCanvasItemClass *klass) void sp_canvas_item_init(SPCanvasItem *item) { + item->xform = Geom::Affine(Geom::identity()); + item->ctrlType = Inkscape::CTRL_TYPE_UNKNOWN; + // TODO items should not be visible on creation - this causes kludges with items // that should be initially invisible; examples of such items: node handles, the CtrlRect // used for rubberbanding, path outline, etc. item->visible = TRUE; - item->xform = Geom::Affine(Geom::identity()); } } // namespace -/** - * Constructs new SPCanvasItem on SPCanvasGroup. - */ SPCanvasItem *sp_canvas_item_new(SPCanvasGroup *parent, GType type, gchar const *first_arg_name, ...) { va_list args; g_return_val_if_fail(parent != NULL, NULL); - g_return_val_if_fail(SP_IS_CANVAS_GROUP (parent), NULL); + g_return_val_if_fail(SP_IS_CANVAS_GROUP(parent), NULL); g_return_val_if_fail(g_type_is_a(type, SPCanvasItem::getType()), NULL); - SPCanvasItem *item = SP_CANVAS_ITEM (g_object_new (type, NULL)); + SPCanvasItem *item = SP_CANVAS_ITEM(g_object_new(type, NULL)); - va_start (args, first_arg_name); - sp_canvas_item_construct (item, parent, first_arg_name, args); - va_end (args); + va_start(args, first_arg_name); + sp_canvas_item_construct(item, parent, first_arg_name, args); + va_end(args); return item; } @@ -438,17 +437,17 @@ namespace { void sp_canvas_item_construct(SPCanvasItem *item, SPCanvasGroup *parent, gchar const *first_arg_name, va_list args) { - g_return_if_fail (SP_IS_CANVAS_GROUP (parent)); - g_return_if_fail (SP_IS_CANVAS_ITEM (item)); + g_return_if_fail(SP_IS_CANVAS_GROUP(parent)); + g_return_if_fail(SP_IS_CANVAS_ITEM(item)); - item->parent = SP_CANVAS_ITEM (parent); + item->parent = SP_CANVAS_ITEM(parent); item->canvas = item->parent->canvas; - g_object_set_valist (G_OBJECT (item), first_arg_name, args); + g_object_set_valist(G_OBJECT(item), first_arg_name, args); SP_CANVAS_GROUP(item->parent)->add(item); - sp_canvas_item_request_update (item); + sp_canvas_item_request_update(item); } } // namespace @@ -458,7 +457,7 @@ void sp_canvas_item_construct(SPCanvasItem *item, SPCanvasGroup *parent, gchar c */ static void redraw_if_visible(SPCanvasItem *item) { - if(item->visible) { + if (item->visible) { int x0 = (int)(item->x1); int x1 = (int)(item->x2); int y0 = (int)(item->y1); @@ -528,11 +527,11 @@ static void sp_canvas_item_invoke_update(SPCanvasItem *item, Geom::Affine const // apply object flags to child flags int child_flags = flags & ~SP_CANVAS_UPDATE_REQUESTED; - if(item->need_update) { + if (item->need_update) { child_flags |= SP_CANVAS_UPDATE_REQUESTED; } - if(item->need_affine) { + if (item->need_affine) { child_flags |= SP_CANVAS_UPDATE_AFFINE; } diff --git a/src/draw-anchor.cpp b/src/draw-anchor.cpp index d11ac462f..c9bc5485e 100644 --- a/src/draw-anchor.cpp +++ b/src/draw-anchor.cpp @@ -20,6 +20,9 @@ #include "lpe-tool-context.h" #include "display/sodipodi-ctrl.h" #include "display/curve.h" +#include "ui/control-manager.h" + +using Inkscape::ControlManager; #define FILL_COLOR_NORMAL 0xffffff7f #define FILL_COLOR_MOUSEOVER 0xff0000ff @@ -44,16 +47,12 @@ SPDrawAnchor *sp_draw_anchor_new(SPDrawContext *dc, SPCurve *curve, gboolean sta a->start = start; a->active = FALSE; a->dp = delta; - a->ctrl = sp_canvas_item_new(sp_desktop_controls(dt), SP_TYPE_CTRL, - "size", 6.0, - "filled", 1, - "fill_color", FILL_COLOR_NORMAL, - "stroked", 1, - "stroke_color", 0x000000ff, - NULL); + a->ctrl = ControlManager::getManager().createControl(sp_desktop_controls(dt), Inkscape::CTRL_TYPE_ANCHOR); SP_CTRL(a->ctrl)->moveto(delta); + ControlManager::getManager().track(a->ctrl); + return a; } diff --git a/src/draw-context.cpp b/src/draw-context.cpp index d8ce2729d..a5c182410 100644 --- a/src/draw-context.cpp +++ b/src/draw-context.cpp @@ -4,6 +4,7 @@ * Author: * Lauris Kaplinski <lauris@kaplinski.com> * Abhishek Sharma + * Jon A. Cruz <jon@joncruz.org> * * Copyright (C) 2000 Lauris Kaplinski * Copyright (C) 2000-2001 Ximian, Inc. @@ -42,6 +43,7 @@ #include "sp-namedview.h" #include "live_effects/lpe-powerstroke.h" #include "style.h" +#include "ui/control-manager.h" #include <gdk/gdkkeysyms.h> @@ -132,6 +134,12 @@ static void spdc_selection_modified(Inkscape::Selection *sel, guint flags, SPDra static void spdc_attach_selection(SPDrawContext *dc, Inkscape::Selection *sel); +/** + * Flushes white curve(s) and additional curve into object. + * + * No cleaning of colored curves - this has to be done by caller + * No rereading of white data, so if you cannot rely on ::modified, do it in caller + */ static void spdc_flush_white(SPDrawContext *dc, SPCurve *gc); static void spdc_reset_white(SPDrawContext *dc); @@ -140,9 +148,7 @@ static void spdc_free_colors(SPDrawContext *dc); static SPEventContextClass *draw_parent_class; - -GType -sp_draw_context_get_type(void) +GType sp_draw_context_get_type(void) { static GType type = 0; if (!type) { @@ -154,15 +160,14 @@ sp_draw_context_get_type(void) sizeof(SPDrawContext), 4, (GInstanceInitFunc) sp_draw_context_init, - NULL, /* value_table */ + NULL, // value_table }; type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "SPDrawContext", &info, (GTypeFlags)0); } return type; } -static void -sp_draw_context_class_init(SPDrawContextClass *klass) +static void sp_draw_context_class_init(SPDrawContextClass *klass) { GObjectClass *object_class; SPEventContextClass *ec_class; @@ -180,8 +185,7 @@ sp_draw_context_class_init(SPDrawContextClass *klass) ec_class->root_handler = sp_draw_context_root_handler; } -static void -sp_draw_context_init(SPDrawContext *dc) +static void sp_draw_context_init(SPDrawContext *dc) { dc->attach = FALSE; @@ -214,8 +218,7 @@ sp_draw_context_init(SPDrawContext *dc) new (&dc->sel_modified_connection) sigc::connection(); } -static void -sp_draw_context_dispose(GObject *object) +static void sp_draw_context_dispose(GObject *object) { SPDrawContext *dc = SP_DRAW_CONTEXT(object); @@ -236,8 +239,7 @@ sp_draw_context_dispose(GObject *object) G_OBJECT_CLASS(draw_parent_class)->dispose(object); } -static void -sp_draw_context_setup(SPEventContext *ec) +static void sp_draw_context_setup(SPEventContext *ec) { SPDrawContext *dc = SP_DRAW_CONTEXT(ec); SPDesktop *dt = ec->desktop; @@ -248,7 +250,7 @@ sp_draw_context_setup(SPEventContext *ec) dc->selection = sp_desktop_selection(dt); - /* Connect signals to track selection changes */ + // Connect signals to track selection changes dc->sel_changed_connection = dc->selection->connectChanged( sigc::bind(sigc::ptr_fun(&spdc_selection_changed), dc) ); @@ -256,21 +258,24 @@ sp_draw_context_setup(SPEventContext *ec) sigc::bind(sigc::ptr_fun(&spdc_selection_modified), dc) ); - /* Create red bpath */ + // Create red bpath dc->red_bpath = sp_canvas_bpath_new(sp_desktop_sketch(ec->desktop), NULL); sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(dc->red_bpath), dc->red_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); - /* Create red curve */ + + // Create red curve dc->red_curve = new SPCurve(); - /* Create blue bpath */ + // Create blue bpath dc->blue_bpath = sp_canvas_bpath_new(sp_desktop_sketch(ec->desktop), NULL); sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(dc->blue_bpath), dc->blue_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); - /* Create blue curve */ + + // Create blue curve dc->blue_curve = new SPCurve(); - /* Create green curve */ + // Create green curve dc->green_curve = new SPCurve(); - /* No green anchor by default */ + + // No green anchor by default dc->green_anchor = NULL; dc->green_closed = FALSE; @@ -278,8 +283,7 @@ sp_draw_context_setup(SPEventContext *ec) spdc_attach_selection(dc, dc->selection); } -static void -sp_draw_context_finish(SPEventContext *ec) +static void sp_draw_context_finish(SPEventContext *ec) { SPDrawContext *dc = SP_DRAW_CONTEXT(ec); @@ -297,13 +301,11 @@ sp_draw_context_finish(SPEventContext *ec) spdc_free_colors(dc); } -static void -sp_draw_context_set(SPEventContext */*ec*/, Inkscape::Preferences::Entry */*val*/) +static void sp_draw_context_set(SPEventContext */*ec*/, Inkscape::Preferences::Entry */*val*/) { } -gint -sp_draw_context_root_handler(SPEventContext *ec, GdkEvent *event) +gint sp_draw_context_root_handler(SPEventContext *ec, GdkEvent *event) { gint ret = FALSE; @@ -336,16 +338,14 @@ sp_draw_context_root_handler(SPEventContext *ec, GdkEvent *event) return ret; } -static Glib::ustring const -tool_name(SPDrawContext *dc) +static Glib::ustring const tool_name(SPDrawContext *dc) { return ( SP_IS_PEN_CONTEXT(dc) ? "/tools/freehand/pen" : "/tools/freehand/pencil" ); } -static void -spdc_paste_curve_as_freehand_shape(const SPCurve *c, SPDrawContext *dc, SPItem *item) +static void spdc_paste_curve_as_freehand_shape(const SPCurve *c, SPDrawContext *dc, SPItem *item) { using namespace Inkscape::LivePathEffect; @@ -357,8 +357,7 @@ spdc_paste_curve_as_freehand_shape(const SPCurve *c, SPDrawContext *dc, SPItem * static_cast<LPEPatternAlongPath*>(lpe)->pattern.paste_param_path(svgd); } -static void -spdc_apply_powerstroke_shape(const std::vector<Geom::Point> & points, SPDrawContext *dc, SPItem *item) +static void spdc_apply_powerstroke_shape(const std::vector<Geom::Point> & points, SPDrawContext *dc, SPItem *item) { using namespace Inkscape::LivePathEffect; @@ -375,12 +374,7 @@ spdc_apply_powerstroke_shape(const std::vector<Geom::Point> & points, SPDrawCont lpe->getRepr()->setAttribute("interpolator_beta", "0.2"); } -/* - * If we have an item and a waiting LPE, apply the effect to the item - * (spiro spline mode is treated separately) - */ -void -spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item, SPCurve *curve) +void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item, SPCurve *curve) { using namespace Inkscape::LivePathEffect; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -486,8 +480,7 @@ spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item, SPCurve *c * Selection handlers */ -static void -spdc_selection_changed(Inkscape::Selection *sel, SPDrawContext *dc) +static void spdc_selection_changed(Inkscape::Selection *sel, SPDrawContext *dc) { if (dc->attach) { spdc_attach_selection(dc, sel); @@ -496,18 +489,16 @@ spdc_selection_changed(Inkscape::Selection *sel, SPDrawContext *dc) /* fixme: We have to ensure this is not delayed (Lauris) */ -static void -spdc_selection_modified(Inkscape::Selection *sel, guint /*flags*/, SPDrawContext *dc) +static void spdc_selection_modified(Inkscape::Selection *sel, guint /*flags*/, SPDrawContext *dc) { if (dc->attach) { spdc_attach_selection(dc, sel); } } -static void -spdc_attach_selection(SPDrawContext *dc, Inkscape::Selection */*sel*/) +static void spdc_attach_selection(SPDrawContext *dc, Inkscape::Selection */*sel*/) { - /* We reset white and forget white/start/end anchors */ + // We reset white and forget white/start/end anchors spdc_reset_white(dc); dc->sa = NULL; dc->ea = NULL; @@ -515,17 +506,19 @@ spdc_attach_selection(SPDrawContext *dc, Inkscape::Selection */*sel*/) SPItem *item = dc->selection ? dc->selection->singleItem() : NULL; if ( item && SP_IS_PATH(item) ) { - /* Create new white data */ - /* Item */ + // Create new white data + // Item dc->white_item = item; - /* Curve list */ - /* We keep it in desktop coordinates to eliminate calculation errors */ + + // Curve list + // We keep it in desktop coordinates to eliminate calculation errors SPCurve *norm = SP_PATH(item)->get_curve_for_edit(); norm->transform((dc->white_item)->i2dt_affine()); g_return_if_fail( norm != NULL ); dc->white_curves = g_slist_reverse(norm->split()); norm->unref(); - /* Anchor list */ + + // Anchor list for (GSList *l = dc->white_curves; l != NULL; l = l->next) { SPCurve *c; c = static_cast<SPCurve*>(l->data); @@ -540,20 +533,11 @@ spdc_attach_selection(SPDrawContext *dc, Inkscape::Selection */*sel*/) dc->white_anchors = g_slist_prepend(dc->white_anchors, a); } } - /* fixme: recalculate active anchor? */ + // fixme: recalculate active anchor? } } -/** - * Snaps node or handle to PI/rotationsnapsperpi degree increments. - * - * \param dc draw context - * \param p cursor point (to be changed by snapping) - * \param o origin point - * \param state keyboard state to check if ctrl or shift was pressed -*/ - void spdc_endpoint_snap_rotation(SPEventContext const *const ec, Geom::Point &p, Geom::Point const &o, guint state) { @@ -604,36 +588,31 @@ void spdc_endpoint_snap_free(SPEventContext const * const ec, Geom::Point& p, bo m.unSetup(); } -static SPCurve * -reverse_then_unref(SPCurve *orig) +static SPCurve *reverse_then_unref(SPCurve *orig) { SPCurve *ret = orig->create_reverse(); orig->unref(); return ret; } -/** - * Concats red, blue and green. - * If any anchors are defined, process these, optionally removing curves from white list - * Invoke _flush_white to write result back to object. - */ -void -spdc_concat_colors_and_flush(SPDrawContext *dc, gboolean forceclosed) +void spdc_concat_colors_and_flush(SPDrawContext *dc, gboolean forceclosed) { - /* Concat RBG */ + // Concat RBG SPCurve *c = dc->green_curve; - /* Green */ + // Green dc->green_curve = new SPCurve(); while (dc->green_bpaths) { gtk_object_destroy(GTK_OBJECT(dc->green_bpaths->data)); dc->green_bpaths = g_slist_remove(dc->green_bpaths, dc->green_bpaths->data); } - /* Blue */ + + // Blue c->append_continuous(dc->blue_curve, 0.0625); dc->blue_curve->reset(); sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(dc->blue_bpath), NULL); - /* Red */ + + // Red if (dc->red_curve_is_valid) { c->append_continuous(dc->red_curve, 0.0625); } @@ -645,18 +624,18 @@ spdc_concat_colors_and_flush(SPDrawContext *dc, gboolean forceclosed) return; } - /* Step A - test, whether we ended on green anchor */ + // Step A - test, whether we ended on green anchor if ( forceclosed || ( dc->green_anchor && dc->green_anchor->active ) ) { // We hit green anchor, closing Green-Blue-Red SP_EVENT_CONTEXT_DESKTOP(dc)->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Path is closed.")); c->closepath_current(); - /* Closed path, just flush */ + // Closed path, just flush spdc_flush_white(dc, c); c->unref(); return; } - /* Step B - both start and end anchored to same curve */ + // Step B - both start and end anchored to same curve if ( dc->sa && dc->ea && ( dc->sa->curve == dc->ea->curve ) && ( ( dc->sa != dc->ea ) @@ -674,7 +653,7 @@ spdc_concat_colors_and_flush(SPDrawContext *dc, gboolean forceclosed) return; } - /* Step C - test start */ + // Step C - test start if (dc->sa) { SPCurve *s = dc->sa->curve; dc->white_curves = g_slist_remove(dc->white_curves, s); @@ -700,16 +679,7 @@ spdc_concat_colors_and_flush(SPDrawContext *dc, gboolean forceclosed) c->unref(); } -/* - * Flushes white curve(s) and additional curve into object - * - * No cleaning of colored curves - this has to be done by caller - * No rereading of white data, so if you cannot rely on ::modified, do it in caller - * - */ - -static void -spdc_flush_white(SPDrawContext *dc, SPCurve *gc) +static void spdc_flush_white(SPDrawContext *dc, SPCurve *gc) { SPCurve *c; @@ -728,7 +698,7 @@ spdc_flush_white(SPDrawContext *dc, SPCurve *gc) return; } - /* Now we have to go back to item coordinates at last */ + // Now we have to go back to item coordinates at last c->transform( dc->white_item ? (dc->white_item)->dt2i_affine() : SP_EVENT_CONTEXT_DESKTOP(dc)->dt2doc() ); @@ -738,7 +708,7 @@ spdc_flush_white(SPDrawContext *dc, SPCurve *gc) Inkscape::XML::Document *xml_doc = doc->getReprDoc(); if ( c && !c->is_empty() ) { - /* We actually have something to write */ + // We actually have something to write bool has_lpe = false; Inkscape::XML::Node *repr; @@ -747,7 +717,7 @@ spdc_flush_white(SPDrawContext *dc, SPCurve *gc) has_lpe = sp_lpe_item_has_path_effect_recursive(SP_LPE_ITEM(dc->white_item)); } else { repr = xml_doc->createElement("svg:path"); - /* Set style */ + // Set style sp_desktop_apply_style_tool(desktop, repr, tool_name(dc).data(), false); } @@ -760,7 +730,7 @@ spdc_flush_white(SPDrawContext *dc, SPCurve *gc) g_free(str); if (!dc->white_item) { - /* Attach repr */ + // Attach repr SPItem *item = SP_ITEM(desktop->currentLayer()->appendChildRepr(repr)); // we finished the path; now apply any waiting LPEs or freehand shapes @@ -785,19 +755,15 @@ spdc_flush_white(SPDrawContext *dc, SPCurve *gc) c->unref(); - /* Flush pending updates */ + // Flush pending updates doc->ensureUpToDate(); } -/** - * Returns FIRST active anchor (the activated one). - */ -SPDrawAnchor * -spdc_test_inside(SPDrawContext *dc, Geom::Point p) +SPDrawAnchor *spdc_test_inside(SPDrawContext *dc, Geom::Point p) { SPDrawAnchor *active = NULL; - /* Test green anchor */ + // Test green anchor if (dc->green_anchor) { active = sp_draw_anchor_test(dc->green_anchor, p, TRUE); } @@ -812,11 +778,10 @@ spdc_test_inside(SPDrawContext *dc, Geom::Point p) return active; } -static void -spdc_reset_white(SPDrawContext *dc) +static void spdc_reset_white(SPDrawContext *dc) { if (dc->white_item) { - /* We do not hold refcount */ + // We do not hold refcount dc->white_item = NULL; } while (dc->white_curves) { @@ -829,10 +794,9 @@ spdc_reset_white(SPDrawContext *dc) } } -static void -spdc_free_colors(SPDrawContext *dc) +static void spdc_free_colors(SPDrawContext *dc) { - /* Red */ + // Red if (dc->red_bpath) { gtk_object_destroy(GTK_OBJECT(dc->red_bpath)); dc->red_bpath = NULL; @@ -840,7 +804,8 @@ spdc_free_colors(SPDrawContext *dc) if (dc->red_curve) { dc->red_curve = dc->red_curve->unref(); } - /* Blue */ + + // Blue if (dc->blue_bpath) { gtk_object_destroy(GTK_OBJECT(dc->blue_bpath)); dc->blue_bpath = NULL; @@ -848,7 +813,8 @@ spdc_free_colors(SPDrawContext *dc) if (dc->blue_curve) { dc->blue_curve = dc->blue_curve->unref(); } - /* Green */ + + // Green while (dc->green_bpaths) { gtk_object_destroy(GTK_OBJECT(dc->green_bpaths->data)); dc->green_bpaths = g_slist_remove(dc->green_bpaths, dc->green_bpaths->data); @@ -859,9 +825,10 @@ spdc_free_colors(SPDrawContext *dc) if (dc->green_anchor) { dc->green_anchor = sp_draw_anchor_destroy(dc->green_anchor); } - /* White */ + + // White if (dc->white_item) { - /* We do not hold refcount */ + // We do not hold refcount dc->white_item = NULL; } while (dc->white_curves) { @@ -874,7 +841,6 @@ spdc_free_colors(SPDrawContext *dc) } } -/* Create a single dot represented by a circle */ void spdc_create_single_dot(SPEventContext *ec, Geom::Point const &pt, char const *tool, guint event_state) { g_return_if_fail(!strcmp(tool, "/tools/freehand/pen") || !strcmp(tool, "/tools/freehand/pencil")); Glib::ustring tool_path = tool; @@ -886,10 +852,10 @@ void spdc_create_single_dot(SPEventContext *ec, Geom::Point const &pt, char cons SPItem *item = SP_ITEM(desktop->currentLayer()->appendChildRepr(repr)); Inkscape::GC::release(repr); - /* apply the tool's current style */ + // apply the tool's current style sp_desktop_apply_style_tool(desktop, repr, tool, false); - /* find out stroke width (TODO: is there an easier way??) */ + // find out stroke width (TODO: is there an easier way??) double stroke_width = 3.0; gchar const *style_str = NULL; style_str = repr->attribute("style"); @@ -900,23 +866,24 @@ void spdc_create_single_dot(SPEventContext *ec, Geom::Point const &pt, char cons style->stroke_width.computed = 0; sp_style_unref(style); } - /* unset stroke and set fill color to former stroke color */ + + // unset stroke and set fill color to former stroke color gchar * str; str = g_strdup_printf("fill:#%06x;stroke:none;", sp_desktop_get_color_tool(desktop, tool, false) >> 8); repr->setAttribute("style", str); g_free(str); - /* put the circle where the mouse click occurred and set the diameter to the - current stroke width, multiplied by the amount specified in the preferences */ + // put the circle where the mouse click occurred and set the diameter to the + // current stroke width, multiplied by the amount specified in the preferences Inkscape::Preferences *prefs = Inkscape::Preferences::get(); Geom::Affine const i2d (item->i2dt_affine ()); Geom::Point pp = pt; double rad = 0.5 * prefs->getDouble(tool_path + "/dot-size", 3.0); if (event_state & GDK_MOD1_MASK) { - /* TODO: We vary the dot size between 0.5*rad and 1.5*rad, where rad is the dot size - as specified in prefs. Very simple, but it might be sufficient in practice. If not, - we need to devise something more sophisticated. */ + // TODO: We vary the dot size between 0.5*rad and 1.5*rad, where rad is the dot size + // as specified in prefs. Very simple, but it might be sufficient in practice. If not, + // we need to devise something more sophisticated. double s = g_random_double_range(-0.5, 0.5); rad *= (1 + s); } diff --git a/src/draw-context.h b/src/draw-context.h index 98e4982dd..202dd85b2 100644 --- a/src/draw-context.h +++ b/src/draw-context.h @@ -44,28 +44,29 @@ struct SPDrawContext : public SPEventContext{ guint32 blue_color; guint32 green_color; - /* Red */ + // Red SPCanvasItem *red_bpath; SPCurve *red_curve; - /* Blue */ + // Blue SPCanvasItem *blue_bpath; SPCurve *blue_curve; - /* Green */ + // Green GSList *green_bpaths; SPCurve *green_curve; SPDrawAnchor *green_anchor; gboolean green_closed; // a flag meaning we hit the green anchor, so close the path on itself - /* White */ + // White SPItem *white_item; GSList *white_curves; GSList *white_anchors; - /* Start anchor */ + // Start anchor SPDrawAnchor *sa; - /* End anchor */ + + // End anchor SPDrawAnchor *ea; /* type of the LPE that is to be applied automatically to a finished path (if any) */ @@ -82,11 +83,40 @@ struct SPDrawContext : public SPEventContext{ struct SPDrawContextClass : public SPEventContextClass{}; GType sp_draw_context_get_type(void); + +/** + * Returns FIRST active anchor (the activated one). + */ SPDrawAnchor *spdc_test_inside(SPDrawContext *dc, Geom::Point p); + +/** + * Concats red, blue and green. + * If any anchors are defined, process these, optionally removing curves from white list + * Invoke _flush_white to write result back to object. + */ void spdc_concat_colors_and_flush(SPDrawContext *dc, gboolean forceclosed); + +/** + * Snaps node or handle to PI/rotationsnapsperpi degree increments. + * + * @param dc draw context. + * @param p cursor point (to be changed by snapping). + * @param o origin point. + * @param state keyboard state to check if ctrl or shift was pressed. + */ void spdc_endpoint_snap_rotation(SPEventContext const *const ec, Geom::Point &p, Geom::Point const &o, guint state); + void spdc_endpoint_snap_free(SPEventContext const *ec, Geom::Point &p, boost::optional<Geom::Point> &start_of_line, guint state); + +/** + * If we have an item and a waiting LPE, apply the effect to the item + * (spiro spline mode is treated separately). + */ void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item); + +/** + * Create a single dot represented by a circle. + */ void spdc_create_single_dot(SPEventContext *ec, Geom::Point const &pt, char const *tool, guint event_state); #endif // SEEN_SP_DRAW_CONTEXT_H diff --git a/src/event-context.cpp b/src/event-context.cpp index db7b29640..c4bbc16fd 100644 --- a/src/event-context.cpp +++ b/src/event-context.cpp @@ -14,15 +14,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -/** \class SPEventContext - * SPEventContext is an abstract base class of all tools. As the name - * indicates, event context implementations process UI events (mouse - * movements and keypresses) and take actions (like creating or modifying - * objects). There is one event context implementation for each tool, - * plus few abstract base classes. Writing a new tool involves - * subclassing SPEventContext. - */ - #ifdef HAVE_CONFIG_H # include "config.h" #endif diff --git a/src/event-context.h b/src/event-context.h index 1e641e6ef..fdc6dd136 100644 --- a/src/event-context.h +++ b/src/event-context.h @@ -89,11 +89,19 @@ private: void sp_event_context_snap_delay_handler(SPEventContext *ec, gpointer const dse_item, gpointer const dse_item2, GdkEventMotion *event, DelayedSnapEvent::DelayedSnapEventOrigin origin); + /** * Base class for Event processors. * * This is per desktop object, which (its derivatives) implements * different actions bound to mouse events. + * + * SPEventContext is an abstract base class of all tools. As the name + * indicates, event context implementations process UI events (mouse + * movements and keypresses) and take actions (like creating or modifying + * objects). There is one event context implementation for each tool, + * plus few abstract base classes. Writing a new tool involves + * subclassing SPEventContext. */ struct SPEventContext : public GObject { void enableSelectionCue (bool enable=true); diff --git a/src/knot-holder-entity.cpp b/src/knot-holder-entity.cpp index c556195d6..9f072d8f5 100644 --- a/src/knot-holder-entity.cpp +++ b/src/knot-holder-entity.cpp @@ -29,9 +29,9 @@ int KnotHolderEntity::counter = 0; -void -KnotHolderEntity::create(SPDesktop *desktop, SPItem *item, KnotHolder *parent, const gchar *tip, - SPKnotShapeType shape, SPKnotModeType mode, guint32 color) +void KnotHolderEntity::create(SPDesktop *desktop, SPItem *item, KnotHolder *parent, Inkscape::ControlType type, + const gchar *tip, + SPKnotShapeType shape, SPKnotModeType mode, guint32 color) { knot = sp_knot_new(desktop, tip); @@ -41,11 +41,14 @@ KnotHolderEntity::create(SPDesktop *desktop, SPItem *item, KnotHolder *parent, c my_counter = KnotHolderEntity::counter++; - g_object_set(G_OBJECT (knot->item), "shape", shape, NULL); - g_object_set(G_OBJECT (knot->item), "mode", mode, NULL); + g_object_set(G_OBJECT(knot->item), "shape", shape, NULL); + g_object_set(G_OBJECT(knot->item), "mode", mode, NULL); + + // TODO base more appearance from this type instead of passing in arbitrary values. + knot->item->ctrlType = type; knot->fill [SP_KNOT_STATE_NORMAL] = color; - g_object_set (G_OBJECT (knot->item), "fill_color", color, NULL); + g_object_set (G_OBJECT(knot->item), "fill_color", color, NULL); update_knot(); sp_knot_show(knot); diff --git a/src/knot-holder-entity.h b/src/knot-holder-entity.h index ec936d464..07bd628fc 100644 --- a/src/knot-holder-entity.h +++ b/src/knot-holder-entity.h @@ -18,6 +18,7 @@ #include "knot.h" #include <2geom/forward.h> #include "snapper.h" +#include "display/sp-canvas-item.h" class SPItem; struct SPKnot; @@ -28,8 +29,8 @@ class KnotHolder; namespace Inkscape { namespace LivePathEffect { class Effect; -} -} +} // namespace LivePathEffect +} // namespace Inkscape typedef void (* SPKnotHolderSetFunc) (SPItem *item, Geom::Point const &p, Geom::Point const &origin, guint state); typedef Geom::Point (* SPKnotHolderGetFunc) (SPItem *item); @@ -43,11 +44,14 @@ class KnotHolderEntity { public: KnotHolderEntity() {} virtual ~KnotHolderEntity(); - virtual void create(SPDesktop *desktop, SPItem *item, KnotHolder *parent, const gchar *tip = "", + + virtual void create(SPDesktop *desktop, SPItem *item, KnotHolder *parent, + Inkscape::ControlType type = Inkscape::CTRL_TYPE_UNKNOWN, + const gchar *tip = "", SPKnotShapeType shape = SP_KNOT_SHAPE_DIAMOND, SPKnotModeType mode = SP_KNOT_MODE_XOR, guint32 color = 0xffffff00); - + /* the get/set/click handlers are virtual functions; each handler class for a knot should be derived from KnotHolderEntity and override these functions */ virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state) = 0; diff --git a/src/knotholder.cpp b/src/knotholder.cpp index 947f7c92a..81c7e3890 100644 --- a/src/knotholder.cpp +++ b/src/knotholder.cpp @@ -35,33 +35,36 @@ #include "live_effects/effect.h" #include "desktop.h" #include "display/sp-canvas.h" +#include "display/sp-canvas-item.h" #include "verbs.h" +#include "ui/control-manager.h" #include "xml/repr.h" // for debugging only +using Inkscape::ControlManager; using Inkscape::DocumentUndo; class SPDesktop; -KnotHolder::KnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler) +KnotHolder::KnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler) : + desktop(desktop), + item(item), + //XML Tree being used directly for item->getRepr() while it shouldn't be... + repr(item ? item->getRepr() : 0), + entity(), + sizeUpdatedConn(), + released(relhandler), + local_change(FALSE), + dragging(false) { - //XML Tree being used directly here while it shouldn't be... - Inkscape::XML::Node *repr = item->getRepr(); if (!desktop || !item || !SP_IS_ITEM(item)) { g_print ("Error! Throw an exception, please!\n"); } - this->desktop = desktop; - this->item = item; g_object_ref(G_OBJECT(item)); // TODO: is this still needed after C++-ification? - this->released = relhandler; - - this->repr = repr; - this->local_change = FALSE; - - this->dragging = false; + sizeUpdatedConn = ControlManager::getManager().connectCtrlSizeChanged(sigc::mem_fun(*this, &KnotHolder::updateControlSizes)); } KnotHolder::~KnotHolder() { @@ -72,16 +75,22 @@ KnotHolder::~KnotHolder() { (*i) = NULL; } entity.clear(); // is this necessary? + sizeUpdatedConn.disconnect(); } -/** - * \param p In desktop coordinates. - */ +void KnotHolder::updateControlSizes() +{ + ControlManager &mgr = ControlManager::getManager(); -void -KnotHolder::update_knots() + for (std::list<KnotHolderEntity *>::iterator it = entity.begin(); it != entity.end(); ++it) { + KnotHolderEntity *e = *it; + mgr.updateItem(e->knot->item); + } +} + +void KnotHolder::update_knots() { - for(std::list<KnotHolderEntity *>::iterator i = entity.begin(); i != entity.end(); ++i) { + for (std::list<KnotHolderEntity *>::iterator i = entity.begin(); i != entity.end(); ++i) { KnotHolderEntity *e = *i; e->update_knot(); } @@ -106,7 +115,7 @@ void KnotHolder::knot_clicked_handler(SPKnot *knot, guint state) { KnotHolder *knot_holder = this; - SPItem *saved_item = this->item; + SPItem *saved_item = this->item; for(std::list<KnotHolderEntity *>::iterator i = knot_holder->entity.begin(); i != knot_holder->entity.end(); ++i) { KnotHolderEntity *e = *i; @@ -227,14 +236,14 @@ KnotHolder::knot_ungrabbed_handler(SPKnot */*knot*/) } } -void -KnotHolder::add(KnotHolderEntity *e) +void KnotHolder::add(KnotHolderEntity *e) { + g_message("Adding a knot at %p", e); entity.push_back(e); + updateControlSizes(); } -void -KnotHolder::add_pattern_knotholder() +void KnotHolder::add_pattern_knotholder() { if ((item->style->fill.isPaintserver()) && SP_IS_PATTERN(item->style->getFillPaintServer())) @@ -242,20 +251,24 @@ KnotHolder::add_pattern_knotholder() PatternKnotHolderEntityXY *entity_xy = new PatternKnotHolderEntityXY(); PatternKnotHolderEntityAngle *entity_angle = new PatternKnotHolderEntityAngle(); PatternKnotHolderEntityScale *entity_scale = new PatternKnotHolderEntityScale(); - entity_xy->create(desktop, item, this, + entity_xy->create(desktop, item, this, Inkscape::CTRL_TYPE_POINT, // TRANSLATORS: This refers to the pattern that's inside the object _("<b>Move</b> the pattern fill inside the object"), SP_KNOT_SHAPE_CROSS); - entity_scale->create(desktop, item, this, + + entity_scale->create(desktop, item, this, Inkscape::CTRL_TYPE_SIZER, _("<b>Scale</b> the pattern fill; uniformly if with <b>Ctrl</b>"), SP_KNOT_SHAPE_SQUARE, SP_KNOT_MODE_XOR); - entity_angle->create(desktop, item, this, + + entity_angle->create(desktop, item, this, Inkscape::CTRL_TYPE_ROTATE, _("<b>Rotate</b> the pattern fill; with <b>Ctrl</b> to snap angle"), SP_KNOT_SHAPE_CIRCLE, SP_KNOT_MODE_XOR); + entity.push_back(entity_xy); entity.push_back(entity_angle); entity.push_back(entity_scale); } + updateControlSizes(); } /* diff --git a/src/knotholder.h b/src/knotholder.h index 463436be6..2d195e7b4 100644 --- a/src/knotholder.h +++ b/src/knotholder.h @@ -34,7 +34,6 @@ class PowerStrokePointArrayParamKnotHolderEntity; class KnotHolder { public: - KnotHolder() {} // do nothing in the default constructor KnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler); virtual ~KnotHolder(); @@ -56,16 +55,24 @@ public: friend class Inkscape::LivePathEffect::PowerStrokePointArrayParamKnotHolderEntity; protected: + + void updateControlSizes(); + SPDesktop *desktop; SPItem *item; // TODO: Remove this and keep the actual item (e.g., SPRect etc.) in the item-specific knotholders Inkscape::XML::Node *repr; ///< repr of the item, for setting and releasing listeners. std::list<KnotHolderEntity *> entity; + sigc::connection sizeUpdatedConn; + SPKnotHolderReleasedFunc released; gboolean local_change; ///< if true, no need to recreate knotholder if repr was changed. bool dragging; + +private: + KnotHolder(); // declared but not defined }; /** diff --git a/src/live_effects/lpe-angle_bisector.cpp b/src/live_effects/lpe-angle_bisector.cpp index 99110c51e..b337f71d8 100644 --- a/src/live_effects/lpe-angle_bisector.cpp +++ b/src/live_effects/lpe-angle_bisector.cpp @@ -83,16 +83,14 @@ void LPEAngleBisector::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) { { KnotHolderEntity *e = new AB::KnotHolderEntityLeftEnd(this); - e->create( desktop, item, knotholder, - _("Adjust the \"left\" end of the bisector") - /*optional: knot_shape, knot_mode, knot_color*/); + e->create( desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, + _("Adjust the \"left\" end of the bisector") ); knotholder->add(e); } { KnotHolderEntity *e = new AB::KnotHolderEntityRightEnd(this); - e->create( desktop, item, knotholder, - _("Adjust the \"right\" of the bisector") - /*optional: knot_shape, knot_mode, knot_color*/); + e->create( desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, + _("Adjust the \"right\" of the bisector") ); knotholder->add(e); } }; diff --git a/src/live_effects/lpe-copy_rotate.cpp b/src/live_effects/lpe-copy_rotate.cpp index c61f4c3c1..bddd65be6 100644 --- a/src/live_effects/lpe-copy_rotate.cpp +++ b/src/live_effects/lpe-copy_rotate.cpp @@ -127,20 +127,17 @@ LPECopyRotate::addCanvasIndicators(SPLPEItem */*lpeitem*/, std::vector<Geom::Pat hp_vec.push_back(pathv); } -void -LPECopyRotate::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) { +void LPECopyRotate::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) { { KnotHolderEntity *e = new CR::KnotHolderEntityStartingAngle(this); - e->create( desktop, item, knotholder, - _("Adjust the starting angle") - /*optional: knot_shape, knot_mode, knot_color*/); + e->create( desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, + _("Adjust the starting angle") ); knotholder->add(e); } { KnotHolderEntity *e = new CR::KnotHolderEntityRotationAngle(this); - e->create( desktop, item, knotholder, - _("Adjust the rotation angle") - /*optional: knot_shape, knot_mode, knot_color*/); + e->create( desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, + _("Adjust the rotation angle") ); knotholder->add(e); } }; diff --git a/src/live_effects/lpe-knot.cpp b/src/live_effects/lpe-knot.cpp index 7ec103a85..3a9b036d8 100644 --- a/src/live_effects/lpe-knot.cpp +++ b/src/live_effects/lpe-knot.cpp @@ -607,15 +607,12 @@ LPEKnot::addCanvasIndicators(SPLPEItem */*lpeitem*/, std::vector<Geom::PathVecto hp_vec.push_back(pathv); } -void -LPEKnot::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) { - { - KnotHolderEntity *e = new KnotHolderEntityCrossingSwitcher(this); - e->create( desktop, item, knotholder, - _("Drag to select a crossing, click to flip it") - /*optional: knot_shape, knot_mode, knot_color*/); - knotholder->add(e); - } +void LPEKnot::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) +{ + KnotHolderEntity *e = new KnotHolderEntityCrossingSwitcher(this); + e->create( desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, + _("Drag to select a crossing, click to flip it") ); + knotholder->add(e); }; diff --git a/src/live_effects/lpe-parallel.cpp b/src/live_effects/lpe-parallel.cpp index 4d15bf13e..95340fcf4 100644 --- a/src/live_effects/lpe-parallel.cpp +++ b/src/live_effects/lpe-parallel.cpp @@ -94,20 +94,17 @@ LPEParallel::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd return output + dir; } -void -LPEParallel::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) { +void LPEParallel::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) { { KnotHolderEntity *e = new Pl::KnotHolderEntityLeftEnd(this); - e->create( desktop, item, knotholder, - _("Adjust the \"left\" end of the parallel") - /*optional: knot_shape, knot_mode, knot_color*/); + e->create( desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, + _("Adjust the \"left\" end of the parallel") ); knotholder->add(e); } { KnotHolderEntity *e = new Pl::KnotHolderEntityRightEnd(this); - e->create( desktop, item, knotholder, - _("Adjust the \"right\" end of the parallel") - /*optional: knot_shape, knot_mode, knot_color*/); + e->create( desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, + _("Adjust the \"right\" end of the parallel") ); knotholder->add(e); } }; diff --git a/src/live_effects/lpe-perp_bisector.cpp b/src/live_effects/lpe-perp_bisector.cpp index ddf16cc9a..f6d69f03c 100644 --- a/src/live_effects/lpe-perp_bisector.cpp +++ b/src/live_effects/lpe-perp_bisector.cpp @@ -154,16 +154,14 @@ void LPEPerpBisector::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) { { KnotHolderEntity *e = new PB::KnotHolderEntityLeftEnd(this); - e->create( desktop, item, knotholder, - _("Adjust the bisector's \"left\" end") - /*optional: knot_shape, knot_mode, knot_color*/); + e->create( desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, + _("Adjust the bisector's \"left\" end") ); knotholder->add(e); } { KnotHolderEntity *e = new PB::KnotHolderEntityRightEnd(this); - e->create( desktop, item, knotholder, - _("Adjust the bisector's \"right\" end") - /*optional: knot_shape, knot_mode, knot_color*/); + e->create( desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, + _("Adjust the bisector's \"right\" end") ); knotholder->add(e); } }; diff --git a/src/live_effects/lpe-perspective_path.cpp b/src/live_effects/lpe-perspective_path.cpp index d9df32076..c8048f74b 100644 --- a/src/live_effects/lpe-perspective_path.cpp +++ b/src/live_effects/lpe-perspective_path.cpp @@ -137,15 +137,11 @@ LPEPerspectivePath::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > cons return output; } -void -LPEPerspectivePath::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) { - { - KnotHolderEntity *e = new PP::KnotHolderEntityOffset(this); - e->create( desktop, item, knotholder, - _("Adjust the origin") - /*optional: knot_shape, knot_mode, knot_color*/); - knotholder->add(e); - } +void LPEPerspectivePath::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) { + KnotHolderEntity *e = new PP::KnotHolderEntityOffset(this); + e->create( desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, + _("Adjust the origin") ); + knotholder->add(e); }; namespace PP { diff --git a/src/live_effects/lpe-tangent_to_curve.cpp b/src/live_effects/lpe-tangent_to_curve.cpp index 04cc3335f..633a36860 100644 --- a/src/live_effects/lpe-tangent_to_curve.cpp +++ b/src/live_effects/lpe-tangent_to_curve.cpp @@ -100,23 +100,20 @@ void LPETangentToCurve::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) { { KnotHolderEntity *e = new TtC::KnotHolderEntityAttachPt(this); - e->create( desktop, item, knotholder, - _("Adjust the point of attachment of the tangent") - /*optional: knot_shape, knot_mode, knot_color*/); + e->create( desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, + _("Adjust the point of attachment of the tangent") ); knotholder->add(e); } { KnotHolderEntity *e = new TtC::KnotHolderEntityLeftEnd(this); - e->create( desktop, item, knotholder, - _("Adjust the \"left\" end of the tangent") - /*optional: knot_shape, knot_mode, knot_color*/); + e->create( desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, + _("Adjust the \"left\" end of the tangent") ); knotholder->add(e); } { KnotHolderEntity *e = new TtC::KnotHolderEntityRightEnd(this); - e->create( desktop, item, knotholder, - _("Adjust the \"right\" end of the tangent") - /*optional: knot_shape, knot_mode, knot_color*/); + e->create( desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, + _("Adjust the \"right\" end of the tangent") ); knotholder->add(e); } }; diff --git a/src/live_effects/parameter/point.cpp b/src/live_effects/parameter/point.cpp index eb2543ac7..c192cd6d6 100644 --- a/src/live_effects/parameter/point.cpp +++ b/src/live_effects/parameter/point.cpp @@ -165,7 +165,7 @@ PointParam::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SP { PointParamKnotHolderEntity *e = new PointParamKnotHolderEntity(this); // TODO: can we ditch handleTip() etc. because we have access to handle_tip etc. itself??? - e->create(desktop, item, knotholder, handleTip(), knot_shape, knot_mode, knot_color); + e->create(desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, handleTip(), knot_shape, knot_mode, knot_color); knotholder->add(e); } diff --git a/src/live_effects/parameter/powerstrokepointarray.cpp b/src/live_effects/parameter/powerstrokepointarray.cpp index 06048cb32..07cc71245 100644 --- a/src/live_effects/parameter/powerstrokepointarray.cpp +++ b/src/live_effects/parameter/powerstrokepointarray.cpp @@ -222,22 +222,21 @@ PowerStrokePointArrayParamKnotHolderEntity::knot_click(guint state) }; // add knot to knotholder PowerStrokePointArrayParamKnotHolderEntity *e = new PowerStrokePointArrayParamKnotHolderEntity(_pparam, _index+1); - e->create( this->desktop, this->item, parent_holder, - _("<b>Stroke width control point</b>: drag to alter the stroke width. <b>Ctrl+click</b> adds a control point, <b>Ctrl+Alt+click</b> deletes it."), + e->create( this->desktop, this->item, parent_holder, Inkscape::CTRL_TYPE_UNKNOWN, + _("<b>Stroke width control point</b>: drag to alter the stroke width. <b>Ctrl+click</b> adds a control point, <b>Ctrl+Alt+click</b> deletes it."), _pparam->knot_shape, _pparam->knot_mode, _pparam->knot_color); parent_holder->add(e); } } } -void -PowerStrokePointArrayParam::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) +void PowerStrokePointArrayParam::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) { for (unsigned int i = 0; i < _vector.size(); ++i) { PowerStrokePointArrayParamKnotHolderEntity *e = new PowerStrokePointArrayParamKnotHolderEntity(this, i); - e->create( desktop, item, knotholder, - _("<b>Stroke width control point</b>: drag to alter the stroke width. <b>Ctrl+click</b> adds a control point, <b>Ctrl+Alt+click</b> deletes it."), - knot_shape, knot_mode, knot_color); + e->create( desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, + _("<b>Stroke width control point</b>: drag to alter the stroke width. <b>Ctrl+click</b> adds a control point, <b>Ctrl+Alt+click</b> deletes it."), + knot_shape, knot_mode, knot_color); knotholder->add(e); } } diff --git a/src/live_effects/parameter/vector.cpp b/src/live_effects/parameter/vector.cpp index 3e0ac9092..3348670dd 100644 --- a/src/live_effects/parameter/vector.cpp +++ b/src/live_effects/parameter/vector.cpp @@ -191,11 +191,11 @@ void VectorParam::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) { VectorParamKnotHolderEntity_Origin *origin_e = new VectorParamKnotHolderEntity_Origin(this); - origin_e->create(desktop, item, knotholder, handleTip(), ori_knot_shape, ori_knot_mode, ori_knot_color); + origin_e->create(desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, handleTip(), ori_knot_shape, ori_knot_mode, ori_knot_color); knotholder->add(origin_e); VectorParamKnotHolderEntity_Vector *vector_e = new VectorParamKnotHolderEntity_Vector(this); - vector_e->create(desktop, item, knotholder, handleTip(), vec_knot_shape, vec_knot_mode, vec_knot_color); + vector_e->create(desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, handleTip(), vec_knot_shape, vec_knot_mode, vec_knot_color); knotholder->add(vector_e); } diff --git a/src/object-edit.cpp b/src/object-edit.cpp index 528f202ab..773bd48e6 100644 --- a/src/object-edit.cpp +++ b/src/object-edit.cpp @@ -17,6 +17,7 @@ #include "sp-item.h" +#include "display/sp-canvas-item.h" #include "sp-rect.h" #include "box3d.h" #include "sp-ellipse.h" @@ -39,6 +40,8 @@ #define sp_round(v,m) (((v) < 0.0) ? ((ceil((v) / (m) - 0.5)) * (m)) : ((floor((v) / (m) + 0.5)) * (m))) +namespace { + static KnotHolder *sp_lpe_knot_holder(SPItem *item, SPDesktop *desktop) { KnotHolder *knot_holder = new KnotHolder(desktop, item, NULL); @@ -49,8 +52,11 @@ static KnotHolder *sp_lpe_knot_holder(SPItem *item, SPDesktop *desktop) return knot_holder; } -KnotHolder * -sp_item_knot_holder(SPItem *item, SPDesktop *desktop) +} // namespace + +namespace Inkscape { + +KnotHolder *createKnotHolder(SPItem *item, SPDesktop *desktop) { KnotHolder *knotholder = NULL; @@ -82,6 +88,8 @@ sp_item_knot_holder(SPItem *item, SPDesktop *desktop) return knotholder; } +} // Inkscape + /* SPRect */ /* handle for horizontal rounding radius */ @@ -426,22 +434,27 @@ RectKnotHolder::RectKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderRel RectKnotHolderEntityRY *entity_ry = new RectKnotHolderEntityRY(); RectKnotHolderEntityWH *entity_wh = new RectKnotHolderEntityWH(); RectKnotHolderEntityXY *entity_xy = new RectKnotHolderEntityXY(); - entity_rx->create(desktop, item, this, + + entity_rx->create(desktop, item, this, Inkscape::CTRL_TYPE_ROTATE, _("Adjust the <b>horizontal rounding</b> radius; with <b>Ctrl</b> " "to make the vertical radius the same"), - SP_KNOT_SHAPE_CIRCLE, SP_KNOT_MODE_XOR); - entity_ry->create(desktop, item, this, + SP_KNOT_SHAPE_CIRCLE, SP_KNOT_MODE_XOR); + + entity_ry->create(desktop, item, this, Inkscape::CTRL_TYPE_ROTATE, _("Adjust the <b>vertical rounding</b> radius; with <b>Ctrl</b> " "to make the horizontal radius the same"), SP_KNOT_SHAPE_CIRCLE, SP_KNOT_MODE_XOR); - entity_wh->create(desktop, item, this, + + entity_wh->create(desktop, item, this, Inkscape::CTRL_TYPE_SIZER, _("Adjust the <b>width and height</b> of the rectangle; with <b>Ctrl</b> " "to lock ratio or stretch in one dimension only"), SP_KNOT_SHAPE_SQUARE, SP_KNOT_MODE_XOR); - entity_xy->create(desktop, item, this, + + entity_xy->create(desktop, item, this, Inkscape::CTRL_TYPE_SIZER, _("Adjust the <b>width and height</b> of the rectangle; with <b>Ctrl</b> " "to lock ratio or stretch in one dimension only"), SP_KNOT_SHAPE_SQUARE, SP_KNOT_MODE_XOR); + entity.push_back(entity_rx); entity.push_back(entity_ry); entity.push_back(entity_wh); @@ -672,31 +685,39 @@ Box3DKnotHolder::Box3DKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderR Box3DKnotHolderEntity7 *entity_corner7 = new Box3DKnotHolderEntity7(); Box3DKnotHolderEntityCenter *entity_center = new Box3DKnotHolderEntityCenter(); - entity_corner0->create(desktop, item, this, + entity_corner0->create(desktop, item, this, Inkscape::CTRL_TYPE_SHAPER, _("Resize box in X/Y direction; with <b>Shift</b> along the Z axis; " "with <b>Ctrl</b> to constrain to the directions of edges or diagonals")); - entity_corner1->create(desktop, item, this, + + entity_corner1->create(desktop, item, this, Inkscape::CTRL_TYPE_SHAPER, _("Resize box in X/Y direction; with <b>Shift</b> along the Z axis; " "with <b>Ctrl</b> to constrain to the directions of edges or diagonals")); - entity_corner2->create(desktop, item, this, + + entity_corner2->create(desktop, item, this, Inkscape::CTRL_TYPE_SHAPER, _("Resize box in X/Y direction; with <b>Shift</b> along the Z axis; " "with <b>Ctrl</b> to constrain to the directions of edges or diagonals")); - entity_corner3->create(desktop, item, this, + + entity_corner3->create(desktop, item, this, Inkscape::CTRL_TYPE_SHAPER, _("Resize box in X/Y direction; with <b>Shift</b> along the Z axis; " "with <b>Ctrl</b> to constrain to the directions of edges or diagonals")); - entity_corner4->create(desktop, item, this, + + entity_corner4->create(desktop, item, this, Inkscape::CTRL_TYPE_SHAPER, _("Resize box along the Z axis; with <b>Shift</b> in X/Y direction; " "with <b>Ctrl</b> to constrain to the directions of edges or diagonals")); - entity_corner5->create(desktop, item, this, + + entity_corner5->create(desktop, item, this, Inkscape::CTRL_TYPE_SHAPER, _("Resize box along the Z axis; with <b>Shift</b> in X/Y direction; " "with <b>Ctrl</b> to constrain to the directions of edges or diagonals")); - entity_corner6->create(desktop, item, this, + + entity_corner6->create(desktop, item, this, Inkscape::CTRL_TYPE_SHAPER, _("Resize box along the Z axis; with <b>Shift</b> in X/Y direction; " "with <b>Ctrl</b> to constrain to the directions of edges or diagonals")); - entity_corner7->create(desktop, item, this, + + entity_corner7->create(desktop, item, this, Inkscape::CTRL_TYPE_SHAPER, _("Resize box along the Z axis; with <b>Shift</b> in X/Y direction; " "with <b>Ctrl</b> to constrain to the directions of edges or diagonals")); - entity_center->create(desktop, item, this, + + entity_center->create(desktop, item, this, Inkscape::CTRL_TYPE_POINT, _("Move the box in perspective"), SP_KNOT_SHAPE_CROSS); @@ -926,20 +947,25 @@ ArcKnotHolder::ArcKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderRelea ArcKnotHolderEntityRY *entity_ry = new ArcKnotHolderEntityRY(); ArcKnotHolderEntityStart *entity_start = new ArcKnotHolderEntityStart(); ArcKnotHolderEntityEnd *entity_end = new ArcKnotHolderEntityEnd(); - entity_rx->create(desktop, item, this, + + entity_rx->create(desktop, item, this, Inkscape::CTRL_TYPE_SIZER, _("Adjust ellipse <b>width</b>, with <b>Ctrl</b> to make circle"), SP_KNOT_SHAPE_SQUARE, SP_KNOT_MODE_XOR); - entity_ry->create(desktop, item, this, + + entity_ry->create(desktop, item, this, Inkscape::CTRL_TYPE_SIZER, _("Adjust ellipse <b>height</b>, with <b>Ctrl</b> to make circle"), SP_KNOT_SHAPE_SQUARE, SP_KNOT_MODE_XOR); - entity_start->create(desktop, item, this, + + entity_start->create(desktop, item, this, Inkscape::CTRL_TYPE_ROTATE, _("Position the <b>start point</b> of the arc or segment; with <b>Ctrl</b> " "to snap angle; drag <b>inside</b> the ellipse for arc, <b>outside</b> for segment"), SP_KNOT_SHAPE_CIRCLE, SP_KNOT_MODE_XOR); - entity_end->create(desktop, item, this, + + entity_end->create(desktop, item, this, Inkscape::CTRL_TYPE_ROTATE, _("Position the <b>end point</b> of the arc or segment; with <b>Ctrl</b> to snap angle; " "drag <b>inside</b> the ellipse for arc, <b>outside</b> for segment"), SP_KNOT_SHAPE_CIRCLE, SP_KNOT_MODE_XOR); + entity.push_back(entity_rx); entity.push_back(entity_ry); entity.push_back(entity_start); @@ -1075,14 +1101,15 @@ StarKnotHolder::StarKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderRel SPStar *star = SP_STAR(item); StarKnotHolderEntity1 *entity1 = new StarKnotHolderEntity1(); - entity1->create(desktop, item, this, + entity1->create(desktop, item, this, Inkscape::CTRL_TYPE_SHAPER, _("Adjust the <b>tip radius</b> of the star or polygon; " "with <b>Shift</b> to round; with <b>Alt</b> to randomize")); + entity.push_back(entity1); if (star->flatsided == false) { StarKnotHolderEntity2 *entity2 = new StarKnotHolderEntity2(); - entity2->create(desktop, item, this, + entity2->create(desktop, item, this, Inkscape::CTRL_TYPE_SHAPER, _("Adjust the <b>base radius</b> of the star; with <b>Ctrl</b> to keep star rays " "radial (no skew); with <b>Shift</b> to round; with <b>Alt</b> to randomize")); entity.push_back(entity2); @@ -1271,12 +1298,15 @@ SpiralKnotHolder::SpiralKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolde { SpiralKnotHolderEntityInner *entity_inner = new SpiralKnotHolderEntityInner(); SpiralKnotHolderEntityOuter *entity_outer = new SpiralKnotHolderEntityOuter(); - entity_inner->create(desktop, item, this, + + entity_inner->create(desktop, item, this, Inkscape::CTRL_TYPE_SHAPER, _("Roll/unroll the spiral from <b>inside</b>; with <b>Ctrl</b> to snap angle; " "with <b>Alt</b> to converge/diverge")); - entity_outer->create(desktop, item, this, + + entity_outer->create(desktop, item, this, Inkscape::CTRL_TYPE_SHAPER, _("Roll/unroll the spiral from <b>outside</b>; with <b>Ctrl</b> to snap angle; " "with <b>Shift</b> to scale/rotate")); + entity.push_back(entity_inner); entity.push_back(entity_outer); @@ -1318,7 +1348,7 @@ OffsetKnotHolder::OffsetKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolde KnotHolder(desktop, item, relhandler) { OffsetKnotHolderEntity *entity_offset = new OffsetKnotHolderEntity(); - entity_offset->create(desktop, item, this, + entity_offset->create(desktop, item, this, Inkscape::CTRL_TYPE_SHAPER, _("Adjust the <b>offset distance</b>")); entity.push_back(entity_offset); @@ -1354,7 +1384,7 @@ FlowtextKnotHolder::FlowtextKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotH g_assert(item != NULL); FlowtextKnotHolderEntity *entity_flowtext = new FlowtextKnotHolderEntity(); - entity_flowtext->create(desktop, item, this, + entity_flowtext->create(desktop, item, this, Inkscape::CTRL_TYPE_SHAPER, _("Drag to resize the <b>flowed text frame</b>")); entity.push_back(entity_flowtext); } diff --git a/src/object-edit.h b/src/object-edit.h index ad63e92e2..ba59e46cd 100644 --- a/src/object-edit.h +++ b/src/object-edit.h @@ -1,5 +1,5 @@ -#ifndef __SP_OBJECT_EDIT_H__ -#define __SP_OBJECT_EDIT_H__ +#ifndef OBJECT_EDIT_H_SEEN +#define OBJECT_EDIT_H_SEEN /* * Node editing extension to objects @@ -7,13 +7,19 @@ * Authors: * Lauris Kaplinski <lauris@kaplinski.com> * Mitsuru Oka + * Jon A. Cruz <jon@joncruz.org> * * Licensed under GNU GPL */ #include "knotholder.h" -KnotHolder *sp_item_knot_holder (SPItem *item, SPDesktop *desktop); +namespace Inkscape +{ + +KnotHolder *createKnotHolder(SPItem *item, SPDesktop *desktop); + +} class RectKnotHolder : public KnotHolder { public: @@ -63,7 +69,7 @@ public: virtual ~MiscKnotHolder() {}; }; -#endif +#endif // OBJECT_EDIT_H_SEEN /* Local Variables: diff --git a/src/pen-context.cpp b/src/pen-context.cpp index dbfd436f0..eefc97513 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -43,6 +43,9 @@ #include "macros.h" #include "context-fns.h" #include "tools-switch.h" +#include "ui/control-manager.h" + +using Inkscape::ControlManager; #if !GTK_CHECK_VERSION(2,22,0) #define GDK_KEY_Up 0xff52 @@ -136,11 +139,11 @@ static void pen_set_to_nearest_horiz_vert(const SPPenContext *const pc, Geom::Po static int pen_last_paraxial_dir = 0; // last used direction in horizontal/vertical mode; 0 = horizontal, 1 = vertical + /** * Register SPPenContext with Gdk and return its type. */ -GType -sp_pen_context_get_type(void) +GType sp_pen_context_get_type(void) { static GType type = 0; if (!type) { @@ -152,7 +155,7 @@ sp_pen_context_get_type(void) sizeof(SPPenContext), 4, (GInstanceInitFunc) sp_pen_context_init, - NULL, /* value_table */ + NULL, // value_table }; type = g_type_register_static(SP_TYPE_DRAW_CONTEXT, "SPPenContext", &info, (GTypeFlags)0); } @@ -162,8 +165,7 @@ sp_pen_context_get_type(void) /** * Initialize the SPPenContext vtable. */ -static void -sp_pen_context_class_init(SPPenContextClass *klass) +static void sp_pen_context_class_init(SPPenContextClass *klass) { GObjectClass *object_class; SPEventContextClass *event_context_class; @@ -185,10 +187,8 @@ sp_pen_context_class_init(SPPenContextClass *klass) /** * Callback to initialize SPPenContext object. */ -static void -sp_pen_context_init(SPPenContext *pc) +static void sp_pen_context_init(SPPenContext *pc) { - SPEventContext *event_context = SP_EVENT_CONTEXT(pc); event_context->cursor_shape = cursor_pen_xpm; @@ -214,12 +214,9 @@ sp_pen_context_init(SPPenContext *pc) /** * Callback to destroy the SPPenContext object's members and itself. */ -static void -sp_pen_context_dispose(GObject *object) +static void sp_pen_context_dispose(GObject *object) { - SPPenContext *pc; - - pc = SP_PEN_CONTEXT(object); + SPPenContext *pc = SP_PEN_CONTEXT(object); if (pc->c0) { gtk_object_destroy(GTK_OBJECT(pc->c0)); @@ -246,8 +243,7 @@ sp_pen_context_dispose(GObject *object) } } -void -sp_pen_context_set_polyline_mode(SPPenContext *const pc) { +void sp_pen_context_set_polyline_mode(SPPenContext *const pc) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); guint mode = prefs->getInt("/tools/freehand/pen/freehand-mode", 0); pc->polylines_only = (mode == 2 || mode == 3); @@ -257,22 +253,21 @@ sp_pen_context_set_polyline_mode(SPPenContext *const pc) { /** * Callback to initialize SPPenContext object. */ -static void -sp_pen_context_setup(SPEventContext *ec) +static void sp_pen_context_setup(SPEventContext *ec) { - SPPenContext *pc; - - pc = SP_PEN_CONTEXT(ec); + SPPenContext *pc = SP_PEN_CONTEXT(ec); if (((SPEventContextClass *) pen_parent_class)->setup) { ((SPEventContextClass *) pen_parent_class)->setup(ec); } - /* Pen indicators */ - pc->c0 = sp_canvas_item_new(sp_desktop_controls(SP_EVENT_CONTEXT_DESKTOP(ec)), SP_TYPE_CTRL, "shape", SP_CTRL_SHAPE_CIRCLE, - "size", 4.0, "filled", 0, "fill_color", 0xff00007f, "stroked", 1, "stroke_color", 0x0000ff7f, NULL); - pc->c1 = sp_canvas_item_new(sp_desktop_controls(SP_EVENT_CONTEXT_DESKTOP(ec)), SP_TYPE_CTRL, "shape", SP_CTRL_SHAPE_CIRCLE, - "size", 4.0, "filled", 0, "fill_color", 0xff00007f, "stroked", 1, "stroke_color", 0x0000ff7f, NULL); + // Pen indicators + pc->c0 = ControlManager::getManager().createControl(sp_desktop_controls(SP_EVENT_CONTEXT_DESKTOP(ec)), Inkscape::CTRL_TYPE_ADJ_HANDLE); + ControlManager::getManager().track(pc->c0); + + pc->c1 = ControlManager::getManager().createControl(sp_desktop_controls(SP_EVENT_CONTEXT_DESKTOP(ec)), Inkscape::CTRL_TYPE_ADJ_HANDLE); + ControlManager::getManager().track(pc->c1); + pc->cl0 = sp_canvas_item_new(sp_desktop_controls(SP_EVENT_CONTEXT_DESKTOP(ec)), SP_TYPE_CTRLLINE, NULL); sp_ctrlline_set_rgba32(SP_CTRLLINE(pc->cl0), 0x0000007f); pc->cl1 = sp_canvas_item_new(sp_desktop_controls(SP_EVENT_CONTEXT_DESKTOP(ec)), SP_TYPE_CTRLLINE, NULL); @@ -283,6 +278,10 @@ sp_pen_context_setup(SPEventContext *ec) sp_canvas_item_hide(pc->cl0); sp_canvas_item_hide(pc->cl1); + if (pc->green_anchor) { + ControlManager::getManager().updateItem(pc->green_anchor->ctrl); + } + sp_event_context_read(ec, "mode"); pc->anchor_statusbar = false; @@ -295,8 +294,7 @@ sp_pen_context_setup(SPEventContext *ec) } } -static void -pen_cancel (SPPenContext *const pc) +static void pen_cancel (SPPenContext *const pc) { pc->num_clicks = 0; pc->state = SP_PEN_CONTEXT_STOP; @@ -314,8 +312,7 @@ pen_cancel (SPPenContext *const pc) /** * Finalization callback. */ -static void -sp_pen_context_finish(SPEventContext *ec) +static void sp_pen_context_finish(SPEventContext *ec) { SPPenContext *pc = SP_PEN_CONTEXT(ec); @@ -333,8 +330,7 @@ sp_pen_context_finish(SPEventContext *ec) /** * Callback that sets key to value in pen context. */ -static void -sp_pen_context_set(SPEventContext *ec, Inkscape::Preferences::Entry *val) +static void sp_pen_context_set(SPEventContext *ec, Inkscape::Preferences::Entry *val) { SPPenContext *pc = SP_PEN_CONTEXT(ec); Glib::ustring name = val->getEntryName(); @@ -351,8 +347,7 @@ sp_pen_context_set(SPEventContext *ec, Inkscape::Preferences::Entry *val) /** * Snaps new node relative to the previous node. */ -static void -spdc_endpoint_snap(SPPenContext const *const pc, Geom::Point &p, guint const state) +static void spdc_endpoint_snap(SPPenContext const *const pc, Geom::Point &p, guint const state) { if ((state & GDK_CONTROL_MASK) && !pc->polylines_paraxial) { //CTRL enables angular snapping if (pc->npoints > 0) { @@ -376,8 +371,7 @@ spdc_endpoint_snap(SPPenContext const *const pc, Geom::Point &p, guint const sta /** * Snaps new node's handle relative to the new node. */ -static void -spdc_endpoint_snap_handle(SPPenContext const *const pc, Geom::Point &p, guint const state) +static void spdc_endpoint_snap_handle(SPPenContext const *const pc, Geom::Point &p, guint const state) { g_return_if_fail(( pc->npoints == 2 || pc->npoints == 5 )); @@ -392,8 +386,7 @@ spdc_endpoint_snap_handle(SPPenContext const *const pc, Geom::Point &p, guint co } } -static gint -sp_pen_context_item_handler(SPEventContext *ec, SPItem *item, GdkEvent *event) +static gint sp_pen_context_item_handler(SPEventContext *ec, SPItem *item, GdkEvent *event) { SPPenContext *const pc = SP_PEN_CONTEXT(ec); @@ -421,8 +414,7 @@ sp_pen_context_item_handler(SPEventContext *ec, SPItem *item, GdkEvent *event) /** * Callback to handle all pen events. */ -static gint -sp_pen_context_root_handler(SPEventContext *ec, GdkEvent *event) +static gint sp_pen_context_root_handler(SPEventContext *ec, GdkEvent *event) { SPPenContext *const pc = SP_PEN_CONTEXT(ec); @@ -490,7 +482,7 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const } if (!pc->grab ) { - /* Grab mouse, so release will not pass unnoticed */ + // Grab mouse, so release will not pass unnoticed pc->grab = SP_CANVAS_ITEM(desktop->acetate); sp_canvas_item_grab(pc->grab, ( GDK_KEY_PRESS_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | @@ -501,19 +493,19 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const pen_drag_origin_w = event_w; pen_within_tolerance = true; - /* Test whether we hit any anchor. */ + // Test whether we hit any anchor. SPDrawAnchor * const anchor = spdc_test_inside(pc, event_w); switch (pc->mode) { case SP_PEN_CONTEXT_MODE_CLICK: - /* In click mode we add point on release */ + // In click mode we add point on release switch (pc->state) { case SP_PEN_CONTEXT_POINT: case SP_PEN_CONTEXT_CONTROL: case SP_PEN_CONTEXT_CLOSE: break; case SP_PEN_CONTEXT_STOP: - /* This is allowed, if we just canceled curve */ + // This is allowed, if we just canceled curve pc->state = SP_PEN_CONTEXT_POINT; break; default: @@ -523,7 +515,7 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const case SP_PEN_CONTEXT_MODE_DRAG: switch (pc->state) { case SP_PEN_CONTEXT_STOP: - /* This is allowed, if we just canceled curve */ + // This is allowed, if we just canceled curve case SP_PEN_CONTEXT_POINT: if (pc->npoints == 0) { @@ -544,11 +536,11 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const // TODO: Perhaps it would be nicer to rearrange the following case // distinction so that the case of a waiting LPE is treated separately - /* Set start anchor */ + // Set start anchor pc->sa = anchor; if (anchor && !sp_pen_context_has_waiting_LPE(pc)) { - /* Adjust point to anchor if needed; if we have a waiting LPE, we need - a fresh path to be created so don't continue an existing one */ + // Adjust point to anchor if needed; if we have a waiting LPE, we need + // a fresh path to be created so don't continue an existing one p = anchor->dp; desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Continuing selected path")); } else { @@ -557,23 +549,26 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const // anchor, which is handled by the sibling branch above) Inkscape::Selection * const selection = sp_desktop_selection(desktop); if (!(bevent.state & GDK_SHIFT_MASK) || sp_pen_context_has_waiting_LPE(pc)) { - /* if we have a waiting LPE, we need a fresh path to be created - so don't append to an existing one */ + // if we have a waiting LPE, we need a fresh path to be created + // so don't append to an existing one selection->clear(); desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Creating new path")); } else if (selection->singleItem() && SP_IS_PATH(selection->singleItem())) { desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Appending to selected path")); } - /* Create green anchor */ + // Create green anchor p = event_dt; spdc_endpoint_snap(pc, p, bevent.state); pc->green_anchor = sp_draw_anchor_new(pc, pc->green_curve, TRUE, p); + { + ControlManager::getManager().updateItem(pc->green_anchor->ctrl); + } } spdc_pen_set_initial_point(pc, p); } else { - /* Set end anchor */ + // Set end anchor pc->ea = anchor; Geom::Point p; if (anchor) { @@ -592,7 +587,7 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const } else { p = event_dt; - spdc_endpoint_snap(pc, p, bevent.state); /* Snap node only if not hitting anchor. */ + spdc_endpoint_snap(pc, p, bevent.state); // Snap node only if not hitting anchor. spdc_pen_set_subsequent_point(pc, p, true); } } @@ -641,8 +636,7 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const /** * Handle motion_notify event. */ -static gint -pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion const &mevent) +static gint pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion const &mevent) { gint ret = FALSE; @@ -673,10 +667,10 @@ pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion const &mevent) // motion notify coordinates as given (no snapping back to origin) pen_within_tolerance = false; - /* Find desktop coordinates */ + // Find desktop coordinates Geom::Point p = dt->w2d(event_w); - /* Test, whether we hit any anchor */ + // Test, whether we hit any anchor SPDrawAnchor *anchor = spdc_test_inside(pc, event_w); switch (pc->mode) { @@ -684,7 +678,7 @@ pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion const &mevent) switch (pc->state) { case SP_PEN_CONTEXT_POINT: if ( pc->npoints != 0 ) { - /* Only set point, if we are already appending */ + // Only set point, if we are already appending spdc_endpoint_snap(pc, p, mevent.state); spdc_pen_set_subsequent_point(pc, p, true); ret = TRUE; @@ -697,13 +691,13 @@ pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion const &mevent) break; case SP_PEN_CONTEXT_CONTROL: case SP_PEN_CONTEXT_CLOSE: - /* Placing controls is last operation in CLOSE state */ + // Placing controls is last operation in CLOSE state spdc_endpoint_snap(pc, p, mevent.state); spdc_pen_set_ctrl(pc, p, mevent.state); ret = TRUE; break; case SP_PEN_CONTEXT_STOP: - /* This is perfectly valid */ + // This is perfectly valid break; default: break; @@ -713,9 +707,9 @@ pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion const &mevent) switch (pc->state) { case SP_PEN_CONTEXT_POINT: if ( pc->npoints > 0 ) { - /* Only set point, if we are already appending */ + // Only set point, if we are already appending - if (!anchor) { /* Snap node only if not hitting anchor */ + if (!anchor) { // Snap node only if not hitting anchor spdc_endpoint_snap(pc, p, mevent.state); spdc_pen_set_subsequent_point(pc, p, true, mevent.state); } else { @@ -749,7 +743,7 @@ pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion const &mevent) break; case SP_PEN_CONTEXT_CONTROL: case SP_PEN_CONTEXT_CLOSE: - /* Placing controls is last operation in CLOSE state */ + // Placing controls is last operation in CLOSE state // snap the handle spdc_endpoint_snap_handle(pc, p, mevent.state); @@ -763,7 +757,7 @@ pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion const &mevent) ret = TRUE; break; case SP_PEN_CONTEXT_STOP: - /* This is perfectly valid */ + // This is perfectly valid break; default: if (!sp_event_context_knot_mouseover(pc)) { @@ -784,8 +778,7 @@ pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion const &mevent) /** * Handle mouse button release event. */ -static gint -pen_handle_button_release(SPPenContext *const pc, GdkEventButton const &revent) +static gint pen_handle_button_release(SPPenContext *const pc, GdkEventButton const &revent) { if (pc->events_disabled) { // skip event processing if events are disabled @@ -800,10 +793,10 @@ pen_handle_button_release(SPPenContext *const pc, GdkEventButton const &revent) Geom::Point const event_w(revent.x, revent.y); - /* Find desktop coordinates */ + // Find desktop coordinates Geom::Point p = pc->desktop->w2d(event_w); - /* Test whether we hit any anchor. */ + // Test whether we hit any anchor. SPDrawAnchor *anchor = spdc_test_inside(pc, event_w); switch (pc->mode) { @@ -811,14 +804,14 @@ pen_handle_button_release(SPPenContext *const pc, GdkEventButton const &revent) switch (pc->state) { case SP_PEN_CONTEXT_POINT: if ( pc->npoints == 0 ) { - /* Start new thread only with button release */ + // Start new thread only with button release if (anchor) { p = anchor->dp; } pc->sa = anchor; spdc_pen_set_initial_point(pc, p); } else { - /* Set end anchor here */ + // Set end anchor here pc->ea = anchor; if (anchor) { p = anchor->dp; @@ -828,15 +821,15 @@ pen_handle_button_release(SPPenContext *const pc, GdkEventButton const &revent) ret = TRUE; break; case SP_PEN_CONTEXT_CONTROL: - /* End current segment */ + // End current segment spdc_endpoint_snap(pc, p, revent.state); spdc_pen_finish_segment(pc, p, revent.state); pc->state = SP_PEN_CONTEXT_POINT; ret = TRUE; break; case SP_PEN_CONTEXT_CLOSE: - /* End current segment */ - if (!anchor) { /* Snap node only if not hitting anchor */ + // End current segment + if (!anchor) { // Snap node only if not hitting anchor spdc_endpoint_snap(pc, p, revent.state); } spdc_pen_finish_segment(pc, p, revent.state); @@ -845,7 +838,7 @@ pen_handle_button_release(SPPenContext *const pc, GdkEventButton const &revent) ret = TRUE; break; case SP_PEN_CONTEXT_STOP: - /* This is allowed, if we just canceled curve */ + // This is allowed, if we just canceled curve pc->state = SP_PEN_CONTEXT_POINT; ret = TRUE; break; @@ -872,7 +865,7 @@ pen_handle_button_release(SPPenContext *const pc, GdkEventButton const &revent) } break; case SP_PEN_CONTEXT_STOP: - /* This is allowed, if we just cancelled curve */ + // This is allowed, if we just cancelled curve break; default: break; @@ -885,7 +878,7 @@ pen_handle_button_release(SPPenContext *const pc, GdkEventButton const &revent) } if (pc->grab) { - /* Release grab now */ + // Release grab now sp_canvas_item_ungrab(pc->grab, revent.time); pc->grab = NULL; } @@ -917,8 +910,7 @@ pen_handle_button_release(SPPenContext *const pc, GdkEventButton const &revent) return ret; } -static gint -pen_handle_2button_press(SPPenContext *const pc, GdkEventButton const &bevent) +static gint pen_handle_2button_press(SPPenContext *const pc, GdkEventButton const &bevent) { gint ret = FALSE; // only end on LMB double click. Otherwise horizontal scrolling causes ending of the path @@ -929,8 +921,7 @@ pen_handle_2button_press(SPPenContext *const pc, GdkEventButton const &bevent) return ret; } -void -pen_redraw_all (SPPenContext *const pc) +void pen_redraw_all (SPPenContext *const pc) { // green if (pc->green_bpaths) { @@ -984,8 +975,7 @@ pen_redraw_all (SPPenContext *const pc) } } -void -pen_lastpoint_move (SPPenContext *const pc, gdouble x, gdouble y) +void pen_lastpoint_move (SPPenContext *const pc, gdouble x, gdouble y) { if (pc->npoints != 5) return; @@ -1006,14 +996,12 @@ pen_lastpoint_move (SPPenContext *const pc, gdouble x, gdouble y) pen_redraw_all(pc); } -void -pen_lastpoint_move_screen (SPPenContext *const pc, gdouble x, gdouble y) +void pen_lastpoint_move_screen (SPPenContext *const pc, gdouble x, gdouble y) { pen_lastpoint_move (pc, x / pc->desktop->current_zoom(), y / pc->desktop->current_zoom()); } -void -pen_lastpoint_tocurve (SPPenContext *const pc) +void pen_lastpoint_tocurve (SPPenContext *const pc) { if (pc->npoints != 5) return; @@ -1028,8 +1016,7 @@ pen_lastpoint_tocurve (SPPenContext *const pc) pen_redraw_all(pc); } -void -pen_lastpoint_toline (SPPenContext *const pc) +void pen_lastpoint_toline (SPPenContext *const pc) { if (pc->npoints != 5) return; @@ -1040,8 +1027,7 @@ pen_lastpoint_toline (SPPenContext *const pc) } -static gint -pen_handle_key_press(SPPenContext *const pc, GdkEvent *event) +static gint pen_handle_key_press(SPPenContext *const pc, GdkEvent *event) { gint ret = FALSE; @@ -1111,7 +1097,7 @@ pen_handle_key_press(SPPenContext *const pc, GdkEvent *event) } break; -/* TODO: this is not yet enabled?? looks like some traces of the Geometry tool +/*TODO: this is not yet enabled?? looks like some traces of the Geometry tool case GDK_KEY_P: case GDK_KEY_p: if (MOD__SHIFT_ONLY) { @@ -1200,15 +1186,15 @@ pen_handle_key_press(SPPenContext *const pc, GdkEvent *event) // do nothing; this event should be handled upstream } } else { - /* Reset red curve */ + // Reset red curve pc->red_curve->reset(); - /* Destroy topmost green bpath */ + // Destroy topmost green bpath if (pc->green_bpaths) { if (pc->green_bpaths->data) gtk_object_destroy(GTK_OBJECT(pc->green_bpaths->data)); pc->green_bpaths = g_slist_remove(pc->green_bpaths, pc->green_bpaths->data); } - /* Get last segment */ + // Get last segment if ( pc->green_curve->is_empty() ) { g_warning("pen_handle_key_press, case GDK_KP_Delete: Green curve is empty"); break; @@ -1242,16 +1228,15 @@ pen_handle_key_press(SPPenContext *const pc, GdkEvent *event) return ret; } -static void -spdc_reset_colors(SPPenContext *pc) +static void spdc_reset_colors(SPPenContext *pc) { - /* Red */ + // Red pc->red_curve->reset(); sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->red_bpath), NULL); - /* Blue */ + // Blue pc->blue_curve->reset(); sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->blue_bpath), NULL); - /* Green */ + // Green while (pc->green_bpaths) { gtk_object_destroy(GTK_OBJECT(pc->green_bpaths->data)); pc->green_bpaths = g_slist_remove(pc->green_bpaths, pc->green_bpaths->data); @@ -1267,8 +1252,7 @@ spdc_reset_colors(SPPenContext *pc) } -static void -spdc_pen_set_initial_point(SPPenContext *const pc, Geom::Point const p) +static void spdc_pen_set_initial_point(SPPenContext *const pc, Geom::Point const p) { g_assert( pc->npoints == 0 ); @@ -1285,8 +1269,7 @@ spdc_pen_set_initial_point(SPPenContext *const pc, Geom::Point const p) * This type of message always shows angle/distance as the last * two parameters ("angle %3.2f°, distance %s"). */ -static void -spdc_pen_set_angle_distance_status_message(SPPenContext *const pc, Geom::Point const p, int pc_point_to_compare, gchar const *message) +static void spdc_pen_set_angle_distance_status_message(SPPenContext *const pc, Geom::Point const p, int pc_point_to_compare, gchar const *message) { g_assert(pc != NULL); g_assert((pc_point_to_compare == 0) || (pc_point_to_compare == 3)); // exclude control handles @@ -1304,11 +1287,10 @@ spdc_pen_set_angle_distance_status_message(SPPenContext *const pc, Geom::Point c g_string_free(dist, FALSE); } -static void -spdc_pen_set_subsequent_point(SPPenContext *const pc, Geom::Point const p, bool statusbar, guint status) +static void spdc_pen_set_subsequent_point(SPPenContext *const pc, Geom::Point const p, bool statusbar, guint status) { g_assert( pc->npoints != 0 ); - /* todo: Check callers to see whether 2 <= npoints is guaranteed. */ + // todo: Check callers to see whether 2 <= npoints is guaranteed. pc->p[2] = p; pc->p[3] = p; @@ -1350,8 +1332,7 @@ spdc_pen_set_subsequent_point(SPPenContext *const pc, Geom::Point const p, bool } } -static void -spdc_pen_set_ctrl(SPPenContext *const pc, Geom::Point const p, guint const state) +static void spdc_pen_set_ctrl(SPPenContext *const pc, Geom::Point const p, guint const state) { sp_canvas_item_show(pc->c1); sp_canvas_item_show(pc->cl1); @@ -1393,8 +1374,7 @@ spdc_pen_set_ctrl(SPPenContext *const pc, Geom::Point const p, guint const state } } -static void -spdc_pen_finish_segment(SPPenContext *const pc, Geom::Point const p, guint const state) +static void spdc_pen_finish_segment(SPPenContext *const pc, Geom::Point const p, guint const state) { if (pc->polylines_paraxial) { pen_last_paraxial_dir = pen_next_paraxial_direction(pc, p, pc->p[0], state); @@ -1420,8 +1400,7 @@ spdc_pen_finish_segment(SPPenContext *const pc, Geom::Point const p, guint const } } -static void -spdc_pen_finish(SPPenContext *const pc, gboolean const closed) +static void spdc_pen_finish(SPPenContext *const pc, gboolean const closed) { if (pc->expecting_clicks_for_LPE > 1) { // don't let the path be finished before we have collected the required number of mouse clicks @@ -1459,20 +1438,17 @@ spdc_pen_finish(SPPenContext *const pc, gboolean const closed) pen_enable_events(pc); } -static void -pen_disable_events(SPPenContext *const pc) { +static void pen_disable_events(SPPenContext *const pc) { pc->events_disabled++; } -static void -pen_enable_events(SPPenContext *const pc) { +static void pen_enable_events(SPPenContext *const pc) { g_return_if_fail(pc->events_disabled != 0); pc->events_disabled--; } -void -sp_pen_context_wait_for_LPE_mouse_clicks(SPPenContext *pc, Inkscape::LivePathEffect::EffectType effect_type, +void sp_pen_context_wait_for_LPE_mouse_clicks(SPPenContext *pc, Inkscape::LivePathEffect::EffectType effect_type, unsigned int num_clicks, bool use_polylines) { if (effect_type == Inkscape::LivePathEffect::INVALID_LPE) @@ -1484,8 +1460,7 @@ sp_pen_context_wait_for_LPE_mouse_clicks(SPPenContext *pc, Inkscape::LivePathEff pc->polylines_paraxial = false; // TODO: think if this is correct for all cases } -void -sp_pen_context_cancel_waiting_for_LPE(SPPenContext *pc) +void sp_pen_context_cancel_waiting_for_LPE(SPPenContext *pc) { pc->waiting_LPE_type = Inkscape::LivePathEffect::INVALID_LPE; pc->expecting_clicks_for_LPE = 0; @@ -1494,11 +1469,11 @@ sp_pen_context_cancel_waiting_for_LPE(SPPenContext *pc) static int pen_next_paraxial_direction(const SPPenContext *const pc, Geom::Point const &pt, Geom::Point const &origin, guint state) { - /* - * after the first mouse click we determine whether the mouse pointer is closest to a - * horizontal or vertical segment; for all subsequent mouse clicks, we use the direction - * orthogonal to the last one; pressing Shift toggles the direction - */ + // + // after the first mouse click we determine whether the mouse pointer is closest to a + // horizontal or vertical segment; for all subsequent mouse clicks, we use the direction + // orthogonal to the last one; pressing Shift toggles the direction + // // num_clicks is not reliable because spdc_pen_finish_segment is sometimes called too early // (on first mouse release), in which case num_clicks immediately becomes 1. // if (pc->num_clicks == 0) { diff --git a/src/pen-context.h b/src/pen-context.h index 1026369d1..1dfd6e184 100644 --- a/src/pen-context.h +++ b/src/pen-context.h @@ -47,7 +47,10 @@ struct SPPenContext : public SPDrawContext { Inkscape::LivePathEffect::Effect *waiting_LPE; // if NULL, waiting_LPE_type in SPDrawContext is taken into account SPLPEItem *waiting_item; - SPCanvasItem *c0, *c1, *cl0, *cl1; + SPCanvasItem *c0; + SPCanvasItem *c1; + SPCanvasItem *cl0; + SPCanvasItem *cl1; unsigned int events_disabled : 1; }; diff --git a/src/preferences-skeleton.h b/src/preferences-skeleton.h index 2b674d015..8935d7ace 100644 --- a/src/preferences-skeleton.h +++ b/src/preferences-skeleton.h @@ -243,6 +243,7 @@ static char const preferences_skeleton[] = " <group id=\"rotationsnapsperpi\" value=\"12\"/>\n" " <group id=\"cursortolerance\" value=\"8.0\"/>\n" " <group id=\"dragtolerance\" value=\"4.0\"/>\n" +" <group id=\"grabsize\" value=\"3\"/>\n" " <group\n" " id=\"displayprofile\"\n" " enable=\"0\"\n" diff --git a/src/shape-editor.cpp b/src/shape-editor.cpp index 2034b9d2d..f2339770c 100644 --- a/src/shape-editor.cpp +++ b/src/shape-editor.cpp @@ -33,6 +33,8 @@ #include "shape-editor.h" +using Inkscape::createKnotHolder; + ShapeEditor::ShapeEditor(SPDesktop *dt) { this->desktop = dt; this->knotholder = NULL; @@ -184,7 +186,7 @@ void ShapeEditor::set_item(SPItem *item, SubType type, bool keep_knotholder) { case SH_KNOTHOLDER: if (!this->knotholder) { // only recreate knotholder if none is present - this->knotholder = sp_item_knot_holder(item, desktop); + this->knotholder = createKnotHolder(item, desktop); } if (this->knotholder) { this->knotholder->update_knots(); diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 36a53dada..2903a97fa 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -1,6 +1,7 @@ set(ui_SRC clipboard.cpp + control-manager.cpp previewholder.cpp uxmanager.cpp @@ -121,6 +122,7 @@ set(ui_SRC # ------- # Headers clipboard.h + control-manager.h icon-names.h previewable.h previewfillable.h diff --git a/src/ui/Makefile_insert b/src/ui/Makefile_insert index 19ecef0fc..59b290dc4 100644 --- a/src/ui/Makefile_insert +++ b/src/ui/Makefile_insert @@ -3,6 +3,8 @@ ink_common_sources += \ ui/clipboard.cpp \ ui/clipboard.h \ + ui/control-manager.cpp \ + ui/control-manager.h \ ui/icon-names.h \ ui/previewable.h \ ui/previewfillable.h \ diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 103d3a039..8c13ae760 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -520,21 +520,22 @@ void InkscapePreferences::initPageUI() _page_ui.add_line( false, _("Language (requires restart):"), _ui_languages, "", _("Set the language for menus and number formats"), false); - Glib::ustring sizeLabels[] = {_("Large"), _("Small"), _("Smaller")}; - int sizeValues[] = {0, 1, 2}; - - _misc_small_tools.init( "/toolbox/tools/small", sizeLabels, sizeValues, G_N_ELEMENTS(sizeLabels), 0 ); - _page_ui.add_line( false, _("Toolbox icon size:"), _misc_small_tools, "", - _("Set the size for the tool icons (requires restart)"), false); + { + Glib::ustring sizeLabels[] = {_("Large"), _("Small"), _("Smaller")}; + int sizeValues[] = {0, 1, 2}; - _misc_small_toolbar.init( "/toolbox/small", sizeLabels, sizeValues, G_N_ELEMENTS(sizeLabels), 0 ); - _page_ui.add_line( false, _("Control bar icon size:"), _misc_small_toolbar, "", - _("Set the size for the icons in tools' control bars to use (requires restart)"), false); + _misc_small_tools.init( "/toolbox/tools/small", sizeLabels, sizeValues, G_N_ELEMENTS(sizeLabels), 0 ); + _page_ui.add_line( false, _("Toolbox icon size:"), _misc_small_tools, "", + _("Set the size for the tool icons (requires restart)"), false); - _misc_small_secondary.init( "/toolbox/secondary", sizeLabels, sizeValues, G_N_ELEMENTS(sizeLabels), 1 ); - _page_ui.add_line( false, _("Secondary toolbar icon size:"), _misc_small_secondary, "", - _("Set the size for the icons in secondary toolbars to use (requires restart)"), false); + _misc_small_toolbar.init( "/toolbox/small", sizeLabels, sizeValues, G_N_ELEMENTS(sizeLabels), 0 ); + _page_ui.add_line( false, _("Control bar icon size:"), _misc_small_toolbar, "", + _("Set the size for the icons in tools' control bars to use (requires restart)"), false); + _misc_small_secondary.init( "/toolbox/secondary", sizeLabels, sizeValues, G_N_ELEMENTS(sizeLabels), 1 ); + _page_ui.add_line( false, _("Secondary toolbar icon size:"), _misc_small_secondary, "", + _("Set the size for the icons in secondary toolbars to use (requires restart)"), false); + } _ui_colorsliders_top.init( _("Work-around color sliders not drawing"), "/options/workarounds/colorsontop", false); _page_ui.add_line( false, "", _ui_colorsliders_top, "", @@ -768,6 +769,10 @@ void InkscapePreferences::initPageIO() _page_mouse.add_line( false, _("Click/drag threshold:"), _mouse_thres, _("pixels"), _("Maximum mouse drag (in screen pixels) which is considered a click, not a drag"), false); + _mouse_grabsize.init("/options/grabsize/value", 1, 7, 1, 2, 3, 0); + _page_mouse.add_line(false, _("Handle size"), _mouse_grabsize, "", + _("Set the relative size of node handles."), true); + _mouse_use_ext_input.init( _("Use pressure-sensitive tablet (requires restart)"), "/options/useextinput/value", true); _page_mouse.add_line(false, "",_mouse_use_ext_input, "", _("Use the capabilities of a tablet or other pressure-sensitive device. Disable this only if you have problems with the tablet (you can still use it as a mouse)")); diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h index 1d03ab706..101831086 100644 --- a/src/ui/dialog/inkscape-preferences.h +++ b/src/ui/dialog/inkscape-preferences.h @@ -166,6 +166,7 @@ protected: UI::Widget::PrefSpinButton _mouse_sens; UI::Widget::PrefSpinButton _mouse_thres; + UI::Widget::PrefSlider _mouse_grabsize; UI::Widget::PrefCheckButton _mouse_use_ext_input; UI::Widget::PrefCheckButton _mouse_switch_on_ext_input; diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp index a7b97c21a..92ed82845 100644 --- a/src/widgets/gradient-toolbar.cpp +++ b/src/widgets/gradient-toolbar.cpp @@ -62,17 +62,17 @@ using Inkscape::DocumentUndo; using Inkscape::UI::ToolboxFactory; void gr_apply_gradient_to_item( SPItem *item, SPGradient *gr, SPGradientType new_type, guint new_fill, bool do_fill, bool do_stroke ); -void gr_apply_gradient (Inkscape::Selection *selection, GrDrag *drag, SPGradient *gr); +void gr_apply_gradient(Inkscape::Selection *selection, GrDrag *drag, SPGradient *gr); gboolean gr_vector_list(GtkWidget *combo_box, SPDesktop *desktop, bool selection_empty, SPGradient *gr_selected, bool gr_multi); -void gr_get_dt_selected_gradient (Inkscape::Selection *selection, SPGradient *&gr_selected); +void gr_get_dt_selected_gradient(Inkscape::Selection *selection, SPGradient *&gr_selected); 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 sp_gradient_vector_widget_load_gradient(GtkWidget *widget, SPGradient *gradient); 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); static void select_drag_by_stop( GtkWidget *combo_box, SPGradient *gradient, SPEventContext *ev); -static SPGradient *gr_get_selected_gradient (GtkWidget *widget); -static void gr_stop_set_offset (GtkComboBox *widget, GtkWidget *data); +static SPGradient *gr_get_selected_gradient(GtkWidget *widget); +static void gr_stop_set_offset(GtkComboBox *widget, GtkWidget *data); void add_toolbar_widget(GtkWidget *tbl, GtkWidget *widget); static GtkWidget * gr_ege_select_one_get_combo(GtkWidget *widget, const gchar *name); void check_renderer(GtkWidget *combo); @@ -123,7 +123,7 @@ to all objects in selection. If there was no previous gradient on an item, uses fill/stroke setting from preferences to create new default (linear: left/right; radial: centered) gradient. */ -void gr_apply_gradient (Inkscape::Selection *selection, GrDrag *drag, SPGradient *gr) +void gr_apply_gradient(Inkscape::Selection *selection, GrDrag *drag, SPGradient *gr) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); SPGradientType new_type = static_cast<SPGradientType>(prefs->getInt("/tools/gradient/newgradient", SP_GRADIENT_TYPE_LINEAR)); @@ -136,14 +136,14 @@ void gr_apply_gradient (Inkscape::Selection *selection, GrDrag *drag, SPGradient GrDragger *dragger = static_cast<GrDragger*>(drag->selected->data); for (GSList const* i = dragger->draggables; i != NULL; i = i->next) { // for all draggables of dragger GrDraggable *draggable = (GrDraggable *) i->data; - gr_apply_gradient_to_item (draggable->item, gr, new_type, new_fill, draggable->fill_or_stroke, !draggable->fill_or_stroke); + gr_apply_gradient_to_item(draggable->item, gr, new_type, new_fill, draggable->fill_or_stroke, !draggable->fill_or_stroke); } return; } // If no drag or no dragger selected, act on selection for (GSList const* i = selection->itemList(); i != NULL; i = i->next) { - gr_apply_gradient_to_item (SP_ITEM(i->data), gr, new_type, new_fill, new_fill, !new_fill); + gr_apply_gradient_to_item(SP_ITEM(i->data), gr, new_type, new_fill, new_fill, !new_fill); } } @@ -154,10 +154,10 @@ gboolean gr_vector_list(GtkWidget *combo_box, SPDesktop *desktop, bool selection return sensitive; } - SPDocument *document = sp_desktop_document (desktop); + SPDocument *document = sp_desktop_document(desktop); GtkTreeIter iter; - GtkListStore *store = (GtkListStore *)gtk_combo_box_get_model (GTK_COMBO_BOX(combo_box)); + GtkListStore *store = (GtkListStore *)gtk_combo_box_get_model(GTK_COMBO_BOX(combo_box)); blocked = TRUE; @@ -169,51 +169,49 @@ gboolean gr_vector_list(GtkWidget *combo_box, SPDesktop *desktop, bool selection for (const GSList *i = gradients; i != NULL; i = i->next) { SPGradient *grad = SP_GRADIENT(i->data); if ( grad->hasStops() && !grad->isSolid() ) { - gl = g_slist_prepend (gl, i->data); + gl = g_slist_prepend(gl, i->data); } } - gl = g_slist_reverse (gl); + gl = g_slist_reverse(gl); guint pos = 0; if (!gl) { // The document has no gradients - gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, 0, _("No gradient"), 1, NULL, 2, NULL, -1); + gtk_list_store_append(store, &iter); + gtk_list_store_set(store, &iter, 0, _("No gradient"), 1, NULL, 2, NULL, -1); sensitive = FALSE; } else if (selection_empty) { // Document has gradients, but nothing is currently selected. - gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, 0, _("Nothing selected"), 1, NULL, 2, NULL, -1); + gtk_list_store_append(store, &iter); + gtk_list_store_set(store, &iter, 0, _("Nothing selected"), 1, NULL, 2, NULL, -1); sensitive = FALSE; } else { if (gr_selected == NULL) { - - gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, 0, _("No gradient"), 1, NULL, 2, NULL, -1); + gtk_list_store_append(store, &iter); + gtk_list_store_set(store, &iter, 0, _("No gradient"), 1, NULL, 2, NULL, -1); sensitive = FALSE; } if (gr_multi) { - - gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, 0, _("Multiple gradients"), 1, NULL, 2, NULL, -1); + gtk_list_store_append(store, &iter); + gtk_list_store_set(store, &iter, 0, _("Multiple gradients"), 1, NULL, 2, NULL, -1); sensitive = FALSE; } guint idx = 0; while (gl) { - SPGradient *gradient = SP_GRADIENT (gl->data); - gl = g_slist_remove (gl, gradient); + SPGradient *gradient = SP_GRADIENT(gl->data); + gl = g_slist_remove(gl, gradient); gchar *label = gr_prepare_label(gradient); - GdkPixbuf *pixb = sp_gradient_to_pixbuf (gradient, 64, 16); - gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, 0, label, 1, pixb, 2, gradient, -1); - g_free (label); + GdkPixbuf *pixb = sp_gradient_to_pixbuf(gradient, 64, 16); + gtk_list_store_append(store, &iter); + gtk_list_store_set(store, &iter, 0, label, 1, pixb, 2, gradient, -1); + g_free(label); if (gradient == gr_selected) { pos = idx; @@ -226,10 +224,10 @@ gboolean gr_vector_list(GtkWidget *combo_box, SPDesktop *desktop, bool selection /* Select the current gradient, or the Multi/Nothing line */ if (gr_multi || gr_selected == NULL) { - gtk_combo_box_set_active (GTK_COMBO_BOX(combo_box) , 0); + gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box) , 0); } else { - gtk_combo_box_set_active (GTK_COMBO_BOX(combo_box) , pos); + gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box) , pos); } blocked = FALSE; @@ -240,7 +238,7 @@ gboolean gr_vector_list(GtkWidget *combo_box, SPDesktop *desktop, bool selection * Get the gradient of the selected desktop item * This is gradient containing the repeat settings, not the underlying "getVector" href linked gradient. */ -void gr_get_dt_selected_gradient (Inkscape::Selection *selection, SPGradient *&gr_selected) +void gr_get_dt_selected_gradient(Inkscape::Selection *selection, SPGradient *&gr_selected) { SPGradient *gradient = 0; @@ -456,28 +454,28 @@ static GtkWidget * gr_ege_select_one_get_combo(GtkWidget *widget, const gchar *n return combo_box; } -static void gr_tb_selection_modified (Inkscape::Selection *selection, guint /*flags*/, gpointer data) +static void gr_tb_selection_modified(Inkscape::Selection *selection, guint /*flags*/, gpointer data) { - gr_tb_selection_changed (selection, data); + gr_tb_selection_changed(selection, data); } -static void gr_drag_selection_changed (gpointer /*dragger*/, gpointer data) +static void gr_drag_selection_changed(gpointer /*dragger*/, gpointer data) { - gr_tb_selection_changed (NULL, data); + gr_tb_selection_changed(NULL, data); } -static void gr_defs_release (SPObject */*defs*/, GtkWidget *widget) +static void gr_defs_release(SPObject * /*defs*/, GtkWidget *widget) { - gr_tb_selection_changed (NULL, (gpointer) widget); + gr_tb_selection_changed(NULL, (gpointer) widget); } -static void gr_defs_modified (SPObject */*defs*/, guint /*flags*/, GtkWidget *widget) +static void gr_defs_modified(SPObject * /*defs*/, guint /*flags*/, GtkWidget *widget) { - gr_tb_selection_changed (NULL, (gpointer) widget); + gr_tb_selection_changed(NULL, (gpointer) widget); } -static void gr_disconnect_sigc (GObject */*obj*/, sigc::connection *connection) { +static void gr_disconnect_sigc(GObject * /*obj*/, sigc::connection *connection) { connection->disconnect(); delete connection; } @@ -489,9 +487,9 @@ static SPStop *get_selected_stop( GtkWidget *vb) GtkWidget *cb = gr_ege_select_one_get_combo(vb, "gradient_stops_combo_action"); if ( cb ) { GtkTreeIter iter; - if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX(cb), &iter)) { - GtkListStore *store = (GtkListStore *)gtk_combo_box_get_model (GTK_COMBO_BOX(cb)); - gtk_tree_model_get (GTK_TREE_MODEL(store), &iter, 2, &stop, -1); + if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(cb), &iter)) { + GtkListStore *store = (GtkListStore *)gtk_combo_box_get_model(GTK_COMBO_BOX(cb)); + gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, 2, &stop, -1); } } @@ -499,7 +497,7 @@ static SPStop *get_selected_stop( GtkWidget *vb) } -static void sp_gradient_vector_gradient_release(SPObject */*object*/, GtkWidget *widget) +static void sp_gradient_vector_gradient_release(SPObject * /*object*/, GtkWidget *widget) { sp_gradient_vector_widget_load_gradient(widget, NULL); } @@ -587,8 +585,7 @@ static void sp_gradient_vector_widget_load_gradient(GtkWidget *widget, SPGradien blocked = FALSE; } -static void -gr_add_stop (GtkWidget */*button*/,GtkWidget *vb) +static void gr_add_stop(GtkWidget * /*button*/, GtkWidget *vb) { SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data(G_OBJECT(vb), "desktop")); if (!desktop) { @@ -604,13 +601,12 @@ gr_add_stop (GtkWidget */*button*/,GtkWidget *vb) SPGradientContext *rc = SP_GRADIENT_CONTEXT(ev); if (rc) { - sp_gradient_context_add_stops_between_selected_stops (rc); + sp_gradient_context_add_stops_between_selected_stops(rc); } } -static void -gr_remove_stop (GtkWidget */*button*/, GtkWidget *vb) +static void gr_remove_stop(GtkWidget * /*button*/, GtkWidget *vb) { SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data(G_OBJECT(vb), "desktop")); @@ -635,8 +631,7 @@ gr_remove_stop (GtkWidget */*button*/, GtkWidget *vb) } -static void -gr_linked_changed (GtkToggleAction *act, gpointer data) +static void gr_linked_changed(GtkToggleAction *act, gpointer /*data*/) { gboolean active = gtk_toggle_action_get_active( act ); if ( active ) { @@ -649,12 +644,11 @@ gr_linked_changed (GtkToggleAction *act, gpointer data) prefs->setBool("/options/forkgradientvectors/value", !active); } -static void -gr_reverse (GtkWidget */*button*/, gpointer data) +static void gr_reverse(GtkWidget * /*button*/, gpointer data) { SPDesktop *desktop = static_cast<SPDesktop *>(data); - Inkscape::Selection *selection = sp_desktop_selection (desktop); - SPEventContext *ev = sp_desktop_event_context (desktop); + Inkscape::Selection *selection = sp_desktop_selection(desktop); + SPEventContext *ev = sp_desktop_event_context(desktop); if (!ev) { return; @@ -667,12 +661,12 @@ gr_reverse (GtkWidget */*button*/, gpointer data) drag->selected_reverse_vector(); } else { // If no drag or no dragger selected, act on selection (both fill and stroke gradients) for (GSList const* i = selection->itemList(); i != NULL; i = i->next) { - sp_item_gradient_reverse_vector (SP_ITEM(i->data), true); - sp_item_gradient_reverse_vector (SP_ITEM(i->data), false); + sp_item_gradient_reverse_vector(SP_ITEM(i->data), true); + sp_item_gradient_reverse_vector(SP_ITEM(i->data), false); } } // we did an undoable action - DocumentUndo::done(sp_desktop_document (desktop), SP_VERB_CONTEXT_GRADIENT, + DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_GRADIENT, _("Invert gradient")); } @@ -718,7 +712,7 @@ static void select_stop_by_drag(GtkWidget *combo_box, SPGradient *gradient, SPEv if (!drag || !drag->selected) { blocked = TRUE; - gtk_combo_box_set_active (GTK_COMBO_BOX(combo_box) , 0); + gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box) , 0); gr_stop_set_offset(GTK_COMBO_BOX(combo_box), data); blocked = FALSE; return; @@ -739,14 +733,14 @@ static void select_stop_by_drag(GtkWidget *combo_box, SPGradient *gradient, SPEv if (n > 1) { // Mulitple stops selected - GtkListStore *store = (GtkListStore *)gtk_combo_box_get_model (GTK_COMBO_BOX(combo_box)); + GtkListStore *store = (GtkListStore *)gtk_combo_box_get_model(GTK_COMBO_BOX(combo_box)); if (!store) { return; } GtkTreeIter iter; - gtk_list_store_prepend (store, &iter); - gtk_list_store_set (store, &iter, 0, _("Multiple stops"), 1, NULL, 2, NULL, -1); - gtk_combo_box_set_active (GTK_COMBO_BOX(combo_box) , 0); + gtk_list_store_prepend(store, &iter); + gtk_list_store_set(store, &iter, 0, _("Multiple stops"), 1, NULL, 2, NULL, -1); + gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box) , 0); EgeAdjustmentAction* act = (EgeAdjustmentAction *)g_object_get_data( G_OBJECT(data), "offset_action"); if (act) { @@ -794,7 +788,7 @@ static void select_stop_in_list( GtkWidget *combo_box, SPGradient *gradient, SPS if (SP_IS_STOP(ochild)) { if (ochild == new_stop) { blocked = block; - gtk_combo_box_set_active (GTK_COMBO_BOX(combo_box) , i); + gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box) , i); gr_stop_set_offset(GTK_COMBO_BOX(combo_box), data); blocked = FALSE; return; @@ -812,7 +806,7 @@ static gboolean update_stop_list( GtkWidget *stop_combo, SPGradient *gradient, S return sensitive; } - GtkListStore *store = (GtkListStore *)gtk_combo_box_get_model (GTK_COMBO_BOX(stop_combo)); + GtkListStore *store = (GtkListStore *)gtk_combo_box_get_model(GTK_COMBO_BOX(stop_combo)); if (!store) { return sensitive; } @@ -824,9 +818,9 @@ static gboolean update_stop_list( GtkWidget *stop_combo, SPGradient *gradient, S GtkTreeIter iter; if (!SP_IS_GRADIENT(gradient)) { - gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, 0, _("No gradient"), 1, NULL, 2, NULL, -1); - gtk_combo_box_set_active (GTK_COMBO_BOX(stop_combo) , 0); + gtk_list_store_append(store, &iter); + gtk_list_store_set(store, &iter, 0, _("No gradient"), 1, NULL, 2, NULL, -1); + gtk_combo_box_set_active(GTK_COMBO_BOX(stop_combo) , 0); sensitive = FALSE; blocked = FALSE; return sensitive; @@ -842,8 +836,8 @@ static gboolean update_stop_list( GtkWidget *stop_combo, SPGradient *gradient, S } } if (!sl) { - gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, 0, _("No stops in gradient"), 1, NULL, 2, NULL, -1); + gtk_list_store_append(store, &iter); + gtk_list_store_set(store, &iter, 0, _("No stops in gradient"), 1, NULL, 2, NULL, -1); sensitive = FALSE; } else { @@ -855,8 +849,8 @@ static gboolean update_stop_list( GtkWidget *stop_combo, SPGradient *gradient, S Inkscape::UI::Widget::ColorPreview *cpv = Gtk::manage(new Inkscape::UI::Widget::ColorPreview(sp_stop_get_rgba32(stop))); GdkPixbuf *pb = cpv->toPixbuf(32, 16); - gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, 0, repr->attribute("id"), 1, pb, 2, stop, -1); + gtk_list_store_append(store, &iter); + gtk_list_store_set(store, &iter, 0, repr->attribute("id"), 1, pb, 2, stop, -1); sensitive = FALSE; } } @@ -869,7 +863,7 @@ static gboolean update_stop_list( GtkWidget *stop_combo, SPGradient *gradient, S } if (new_stop == NULL) { - gtk_combo_box_set_active (GTK_COMBO_BOX(stop_combo) , 0); + gtk_combo_box_set_active(GTK_COMBO_BOX(stop_combo) , 0); } else { select_stop_in_list(stop_combo, gradient, new_stop, widget, TRUE); } @@ -879,7 +873,7 @@ static gboolean update_stop_list( GtkWidget *stop_combo, SPGradient *gradient, S return sensitive; } -static SPGradient *gr_get_selected_gradient (GtkWidget *widget) +static SPGradient *gr_get_selected_gradient(GtkWidget *widget) { SPGradient *gr = NULL; EgeSelectOneAction* act1 = (EgeSelectOneAction *)g_object_get_data( G_OBJECT(widget), "gradient_select_combo_action"); @@ -887,8 +881,8 @@ static SPGradient *gr_get_selected_gradient (GtkWidget *widget) gint n = ege_select_one_action_get_active(act1); GtkTreeModel *model = ege_select_one_action_get_model(act1); GtkTreeIter iter; - if (gtk_tree_model_iter_nth_child (model ,&iter, NULL, n)) { - gtk_tree_model_get (model, &iter, 2, &gr, -1); + if (gtk_tree_model_iter_nth_child(model, &iter, NULL, n)) { + gtk_tree_model_get(model, &iter, 2, &gr, -1); return gr; } } @@ -896,17 +890,18 @@ static SPGradient *gr_get_selected_gradient (GtkWidget *widget) return gr; } -/*static void -gr_edit (GtkWidget *button, GtkWidget *widget) +/* +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); + GtkWidget *dialog = sp_gradient_vector_editor_new(gr); + gtk_widget_show(dialog); } -}*/ +} +*/ -static void gr_stop_set_offset (GtkComboBox */*widget*/, GtkWidget *data) +static void gr_stop_set_offset(GtkComboBox * /*widget*/, GtkWidget *data) { SPStop *stop = get_selected_stop(data); if (!stop) { @@ -925,19 +920,19 @@ static void gr_stop_set_offset (GtkComboBox */*widget*/, GtkWidget *data) SPStop *prev = NULL; prev = stop->getPrevStop(); if (prev != NULL ) { - gtk_adjustment_set_lower (adj, prev->offset); + gtk_adjustment_set_lower(adj, prev->offset); } else { isEndStop = true; - gtk_adjustment_set_lower (adj, 0); + gtk_adjustment_set_lower(adj, 0); } SPStop *next = NULL; next = stop->getNextStop(); if (next != NULL ) { - gtk_adjustment_set_upper (adj, next->offset); + gtk_adjustment_set_upper(adj, next->offset); } else { isEndStop = true; - gtk_adjustment_set_upper (adj, 1.0); + gtk_adjustment_set_upper(adj, 1.0); } blocked = TRUE; @@ -970,7 +965,7 @@ static void gr_new_fillstroke_changed( EgeSelectOneAction *act, GObject * /*tbl* /* * User selected a gradient from the combobox */ -void gr_gradient_combo_changed (EgeSelectOneAction *act, gpointer data) +void gr_gradient_combo_changed(EgeSelectOneAction *act, gpointer data) { if (blocked) { return; @@ -980,42 +975,42 @@ void gr_gradient_combo_changed (EgeSelectOneAction *act, gpointer data) gint n = ege_select_one_action_get_active(act); GtkTreeModel *model = ege_select_one_action_get_model(act); GtkTreeIter iter; - if (gtk_tree_model_iter_nth_child (model ,&iter, NULL, n)) { - gtk_tree_model_get (model, &iter, 2, &gr, -1); + if (gtk_tree_model_iter_nth_child(model, &iter, NULL, n)) { + gtk_tree_model_get(model, &iter, 2, &gr, -1); } if (gr) { gr = sp_gradient_ensure_vector_normalized(gr); SPDesktop *desktop = static_cast<SPDesktop *>(data); - Inkscape::Selection *selection = sp_desktop_selection (desktop); - SPEventContext *ev = sp_desktop_event_context (desktop); + Inkscape::Selection *selection = sp_desktop_selection(desktop); + SPEventContext *ev = sp_desktop_event_context(desktop); - gr_apply_gradient (selection, ev? ev->get_drag() : NULL, gr); + gr_apply_gradient(selection, ev? ev->get_drag() : NULL, gr); - DocumentUndo::done(sp_desktop_document (desktop), SP_VERB_CONTEXT_GRADIENT, + DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_GRADIENT, _("Assign gradient to object")); } } -void gr_spread_change (EgeSelectOneAction *act, GtkWidget *widget) +void gr_spread_change(EgeSelectOneAction *act, GtkWidget *widget) { if (blocked) { return; } SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data(G_OBJECT(widget), "desktop")); - Inkscape::Selection *selection = sp_desktop_selection (desktop); + Inkscape::Selection *selection = sp_desktop_selection(desktop); SPGradient *gradient = 0; gr_get_dt_selected_gradient(selection, gradient); if (gradient) { - SPGradientSpread spread = (SPGradientSpread) ege_select_one_action_get_active (act); + SPGradientSpread spread = (SPGradientSpread) ege_select_one_action_get_active(act); gradient->setSpread(spread); gradient->updateRepr(); - DocumentUndo::done(sp_desktop_document (desktop), SP_VERB_CONTEXT_GRADIENT, + DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_GRADIENT, _("Set gradient repeat")); } } @@ -1024,14 +1019,14 @@ void gr_spread_change (EgeSelectOneAction *act, GtkWidget *widget) /* * User selected a stop from the combobox */ -static void gr_stop_combo_changed (GtkComboBox * /*widget*/, GtkWidget *data) +static void gr_stop_combo_changed(GtkComboBox * /*widget*/, GtkWidget *data) { if (blocked) { return; } SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data(G_OBJECT(data), "desktop")); - SPEventContext *ev = sp_desktop_event_context (desktop); + SPEventContext *ev = sp_desktop_event_context(desktop); SPGradient *gr = gr_get_selected_gradient(data); select_drag_by_stop(data, gr, ev); @@ -1050,7 +1045,7 @@ static void gr_stop_offset_adjustment_changed(GtkAdjustment *adj, GObject *tbl) SPStop *stop = get_selected_stop(GTK_WIDGET(tbl)); if (stop) { - stop->offset = gtk_adjustment_get_value (adj); + stop->offset = gtk_adjustment_get_value(adj); sp_repr_set_css_double(stop->getRepr(), "offset", stop->offset); DocumentUndo::maybeDone(stop->document, "gradient:stop:offset", SP_VERB_CONTEXT_GRADIENT, @@ -1069,16 +1064,16 @@ void check_renderer(GtkWidget *combo) gpointer rendered = g_object_get_data( G_OBJECT(combo), "renderers" ); if (!rendered) { - gtk_cell_layout_clear(GTK_CELL_LAYOUT (combo)); + gtk_cell_layout_clear(GTK_CELL_LAYOUT(combo)); - GtkCellRenderer *renderer = gtk_cell_renderer_pixbuf_new (); - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, FALSE); - gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer, "pixbuf", 1, NULL); + GtkCellRenderer *renderer = gtk_cell_renderer_pixbuf_new(); + gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), renderer, FALSE); + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), renderer, "pixbuf", 1, NULL); gtk_cell_renderer_set_padding(renderer, 5, 0); - renderer = gtk_cell_renderer_text_new (); - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE); - gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer, "text", 0, NULL); + renderer = gtk_cell_renderer_text_new(); + gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), renderer, TRUE); + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), renderer, "text", 0, NULL); g_object_set_data(G_OBJECT(combo), "renderers", renderer); } @@ -1155,11 +1150,11 @@ void sp_gradient_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, /* Gradient Select list*/ { - GtkListStore *store = gtk_list_store_new (3, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_POINTER); + GtkListStore *store = gtk_list_store_new(3, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_POINTER); GtkTreeIter iter; - gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, 0, _("No gradient"), 1, NULL, 2, NULL, -1); + gtk_list_store_append(store, &iter); + gtk_list_store_set(store, &iter, 0, _("No gradient"), 1, NULL, 2, NULL, -1); EgeSelectOneAction* act1 = ege_select_one_action_new( "GradientSelectGradientAction", _("Select"), ("Choose a gradient"), NULL, GTK_TREE_MODEL(store) ); g_object_set( act1, "short_label", _("Select:"), NULL ); @@ -1202,11 +1197,11 @@ void sp_gradient_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, /* Gradient Stop list */ { - GtkListStore *store = gtk_list_store_new (3, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_POINTER); + GtkListStore *store = gtk_list_store_new(3, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_POINTER); GtkTreeIter iter; - gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, 0, _("No gradient"), 1, NULL, 2, NULL, -1); + gtk_list_store_append(store, &iter); + gtk_list_store_set(store, &iter, 0, _("No gradient"), 1, NULL, 2, NULL, -1); EgeSelectOneAction* act1 = ege_select_one_action_new( "GradientEditStopsAction", _("Stops"), _("Select a stop for the current gradient"), NULL, GTK_TREE_MODEL(store) ); g_object_set( act1, "short_label", _("Edit:"), NULL ); @@ -1294,8 +1289,8 @@ void sp_gradient_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(itact), !linkedmode ); } - Inkscape::Selection *selection = sp_desktop_selection (desktop); - SPDocument *document = sp_desktop_document (desktop); + Inkscape::Selection *selection = sp_desktop_selection(desktop); + SPDocument *document = sp_desktop_document(desktop); g_object_set_data(holder, "desktop", desktop); |
