Code

Ctrl+click in pen/pencil tool: Created dots are now selected; Alt is used for randomn...
authorcilix42 <cilix42@users.sourceforge.net>
Sun, 20 Jan 2008 15:44:52 +0000 (15:44 +0000)
committercilix42 <cilix42@users.sourceforge.net>
Sun, 20 Jan 2008 15:44:52 +0000 (15:44 +0000)
src/pen-context.cpp
src/pencil-context.cpp
src/sp-path.cpp
src/sp-path.h
src/ui/dialog/inkscape-preferences.cpp

index 6eb534e54aa9b7423079b8632a78416222eff8ff..cae8afbc932b7f77260edd436dd7ab93948a8215 100644 (file)
@@ -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;
                             }
index 691dcb0986c7e3917a5901cb8b6a2a89ed9b59ac..97d49b6ab5d2f97d627a98c601d475aa4e7c5d82 100644 (file)
@@ -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;
                 }
index 29a5910b94184f23759470fc20433af942f6baaa..26396c8f0a07657d36b368631fd7383e10d50344 100644 (file)
@@ -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"));
index ce701d251a60e4627f42578a722d86318c09bcf4..27e09c704d50e8681a760883c30e5e19846b9aec 100644 (file)
@@ -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
 
index 2f31191081e5e92bc75aeed20b0c7a24c9b6210d..34e97a71372789c4e35634d1e1abcd8d4a85d81f 100644 (file)
@@ -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);