From: cilix42 Date: Sun, 20 Jan 2008 15:44:52 +0000 (+0000) Subject: Ctrl+click in pen/pencil tool: Created dots are now selected; Alt is used for randomn... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=58adcec645c8073a243d02ab1a3ffca507269814;p=inkscape.git Ctrl+click in pen/pencil tool: Created dots are now selected; Alt is used for randomness, Shift doubles dot size; clearer preferences labels --- diff --git a/src/pen-context.cpp b/src/pen-context.cpp index 6eb534e54..cae8afbc9 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -409,7 +409,7 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const if (pc->npoints == 0) { if (bevent.state & GDK_CONTROL_MASK) { - freehand_create_single_dot(event_context, event_dt, "tools.freehand.pen", bevent.state & GDK_SHIFT_MASK); + freehand_create_single_dot(event_context, event_dt, "tools.freehand.pen", bevent.state); ret = TRUE; break; } diff --git a/src/pencil-context.cpp b/src/pencil-context.cpp index 691dcb098..97d49b6ab 100644 --- a/src/pencil-context.cpp +++ b/src/pencil-context.cpp @@ -229,7 +229,7 @@ pencil_handle_button_press(SPPencilContext *const pc, GdkEventButton const &beve default: /* Set first point of sequence */ if (bevent.state & GDK_CONTROL_MASK) { - freehand_create_single_dot(event_context, p, "tools.freehand.pencil", bevent.state & GDK_SHIFT_MASK); + freehand_create_single_dot(event_context, p, "tools.freehand.pencil", bevent.state); ret = true; break; } diff --git a/src/sp-path.cpp b/src/sp-path.cpp index 29a5910b9..26396c8f0 100644 --- a/src/sp-path.cpp +++ b/src/sp-path.cpp @@ -41,6 +41,7 @@ #include "style.h" #include "message-stack.h" #include "prefs-utils.h" +#include "selection.h" #define noPATH_VERBOSE @@ -512,7 +513,7 @@ sp_path_get_curve_reference (SPPath *path) } /* Create a single dot represented by a circle */ -void freehand_create_single_dot(SPEventContext *ec, NR::Point const &pt, char const *tool, bool randomize) { +void freehand_create_single_dot(SPEventContext *ec, NR::Point const &pt, char const *tool, guint event_state) { g_return_if_fail(!strcmp(tool, "tools.freehand.pen") || !strcmp(tool, "tools.freehand.pencil")); SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(ec); @@ -547,13 +548,17 @@ void freehand_create_single_dot(SPEventContext *ec, NR::Point const &pt, char co NR::Matrix const i2d (sp_item_i2d_affine (item)); NR::Point pp = pt * i2d; double rad = 0.5 * prefs_get_double_attribute(tool, "dot-size", 3.0); - if (randomize) { + 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. */ double s = g_random_double_range(-0.5, 0.5); rad *= (1 + s); } + if (event_state & GDK_SHIFT_MASK) { + // double the point size + rad *= 2; + } sp_repr_set_svg_double (repr, "sodipodi:cx", pp[NR::X]); sp_repr_set_svg_double (repr, "sodipodi:cy", pp[NR::Y]); @@ -561,6 +566,8 @@ void freehand_create_single_dot(SPEventContext *ec, NR::Point const &pt, char co sp_repr_set_svg_double (repr, "sodipodi:ry", rad * stroke_width); item->updateRepr(); + sp_desktop_selection(desktop)->set(item); + unsigned int tool_code = !strcmp(tool, "tools.freehand.pencil") ? SP_VERB_CONTEXT_PENCIL : SP_VERB_CONTEXT_PEN; desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Creating single dot")); diff --git a/src/sp-path.h b/src/sp-path.h index ce701d251..27e09c704 100644 --- a/src/sp-path.h +++ b/src/sp-path.h @@ -39,7 +39,7 @@ SPCurve* sp_path_get_original_curve (SPPath *path); SPCurve* sp_path_get_curve_for_edit (SPPath *path); const SPCurve* sp_path_get_curve_reference (SPPath *path); -void freehand_create_single_dot(SPEventContext *ec, NR::Point const &pt, char const *tool, bool randomize = false); +void freehand_create_single_dot(SPEventContext *ec, NR::Point const &pt, char const *tool, guint event_state); #endif diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 2f3119108..34e97a713 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -239,7 +239,7 @@ void InkscapePreferences::AddDotSizeSpinbutton(DialogPage& p, const std::string& { PrefSpinButton* sb = Gtk::manage( new PrefSpinButton); sb->init ( prefs_path, "dot-size", 0.0, 1000.0, 0.1, 10.0, def_value, false, false); - p.add_line( false, _("Dot size:"), *sb, "times current stroke width", + p.add_line( false, _("Ctrl+click dot size:"), *sb, "times current stroke width", _("Size of dots created with Ctrl+click (relative to current stroke width)"), false ); } @@ -416,13 +416,13 @@ void InkscapePreferences::initPageTools() _page_pencil.add_line( false, _("Tolerance:"), _t_pencil_tolerance, "", _("This value affects the amount of smoothing applied to freehand lines; lower values produce more uneven paths with more nodes"), false ); - this->AddDotSizeSpinbutton(_page_pencil, "tools.freehand.pencil", 3.0); this->AddNewObjectsStyle(_page_pencil, "tools.freehand.pencil"); + this->AddDotSizeSpinbutton(_page_pencil, "tools.freehand.pencil", 3.0); //Pen this->AddPage(_page_pen, _("Pen"), iter_tools, PREFS_PAGE_TOOLS_PEN); this->AddSelcueCheckbox(_page_pen, "tools.freehand.pen", true); - this->AddDotSizeSpinbutton(_page_pen, "tools.freehand.pen", 3.0); this->AddNewObjectsStyle(_page_pen, "tools.freehand.pen"); + this->AddDotSizeSpinbutton(_page_pen, "tools.freehand.pen", 3.0); //Calligraphy this->AddPage(_page_calligraphy, _("Calligraphy"), iter_tools, PREFS_PAGE_TOOLS_CALLIGRAPHY); this->AddSelcueCheckbox(_page_calligraphy, "tools.calligraphic", false);