Code

Add button whether to display limiting bounding box; add 'all inactive' toggle button...
authorcilix42 <cilix42@users.sourceforge.net>
Mon, 18 Aug 2008 00:43:01 +0000 (00:43 +0000)
committercilix42 <cilix42@users.sourceforge.net>
Mon, 18 Aug 2008 00:43:01 +0000 (00:43 +0000)
share/icons/icons.svg
src/lpe-tool-context.cpp
src/pen-context.cpp
src/widgets/toolbox.cpp

index 9b6b8d36224bbb9ca2b8ddc901be9af40465ebc2..a13f7fecd0539a1ff150cb344796f396571ecffb 100644 (file)
      inkscape:window-x="0"
      inkscape:window-height="738"
      inkscape:window-width="1024"
-     inkscape:cy="1097.5924"
-     inkscape:cx="601.19459"
-     inkscape:zoom="1.4142136"
+     inkscape:cy="1138.636"
+     inkscape:cx="700.76921"
+     inkscape:zoom="5.6568543"
      gridtolerance="6"
      snaptogrid="false"
      showgrid="true"
@@ -17178,4 +17178,12 @@ http://www.inkscape.org/</dc:description>
        d="m 352.20456,433.15821 c -17.90493,17.90622 -39.36169,32.2447 -62.75073,41.93467 -23.38904,9.68997 -48.6918,14.72379 -73.99963,14.72229"
        style="fill:none;stroke:#282828;stroke-width:24.9614296;stroke-linecap:square;stroke-linejoin:bevel;stroke-miterlimit:4.26999998;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:23.2" />
   </g>
+  <rect
+     style="opacity:1;color:#000000;fill:none;stroke:#0000ff;stroke-width:2.30013371;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:2.30013366, 2.30013366;stroke-dashoffset:0;marker:none;marker-start:none;marker-mid:none;marker-end:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+     id="lpetool_show_bbox"
+     width="10.660022"
+     height="16.847206"
+     x="715.56531"
+     y="86.075531"
+     inkscape:label="lpetool_show_bbox" />
 </svg>
index f9fc3ad71b0487967a1b4adc3e9fe87f4bbd8f85..881aa47e94047a48eef173c3b676ac188e2d283c 100644 (file)
@@ -43,9 +43,10 @@ static gint sp_lpetool_context_root_handler(SPEventContext *ec, GdkEvent *event)
 
 void sp_lpetool_context_selection_changed(Inkscape::Selection *selection, gpointer data);
 
-const int num_subtools = 6;
+const int num_subtools = 7;
 
 Inkscape::LivePathEffect::EffectType lpesubtools[] = {
+    Inkscape::LivePathEffect::INVALID_LPE, // this must be here to account for the "all inactive" action
     Inkscape::LivePathEffect::LINE_SEGMENT,
     Inkscape::LivePathEffect::CIRCLE_3PTS,
     Inkscape::LivePathEffect::CIRCLE_WITH_RADIUS,
@@ -305,6 +306,14 @@ sp_lpetool_context_root_handler(SPEventContext *event_context, GdkEvent *event)
 void
 lpetool_context_reset_limiting_bbox(SPLPEToolContext *lc)
 {
+    if (lc->canvas_bbox) {
+        gtk_object_destroy(GTK_OBJECT(lc->canvas_bbox));
+        lc->canvas_bbox = NULL;
+    }
+
+    if (prefs_get_int_attribute("tools.lpetool", "show_bbox", 1) == 0)
+        return;
+
     SPDocument *document = sp_desktop_document(lc->desktop);
     Geom::Coord w = sp_document_width(document);
     Geom::Coord h = sp_document_height(document);
index 74498c6c0a803fc63b7ab2b350d7cac25d61e6d2..b575e94f3a97a4a1f0a627a58783190a4f7c4e48 100644 (file)
@@ -1384,9 +1384,11 @@ 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)
+        return;
+
     g_print ("Now waiting for %s to be applied\n",
              Inkscape::LivePathEffect::LPETypeConverter.get_label(effect_type).c_str());
-    g_return_if_fail(effect_type != Inkscape::LivePathEffect::INVALID_LPE);
 
     pc->waiting_LPE_type = effect_type;
     pc->expecting_clicks_for_LPE = num_clicks;
index e7b6a84c8b2d69ba90f1b0ae27cbf9250130f778..71c797bffd1452e40dfc57393d94cf36dfcc6b99 100644 (file)
@@ -443,6 +443,8 @@ static gchar const * ui_descr =
 
         "  <toolbar name='LPEToolToolbar'>"
         "    <toolitem action='LPEToolModeAction' />"
+        "    <separator />"
+        "    <toolitem action='LPEShowBBoxAction' />"
         "  </toolbar>"
 
         "  <toolbar name='DropperToolbar'>"
@@ -4797,8 +4799,8 @@ static void sp_lpetool_mode_changed(EgeSelectOneAction *act, GObject *tbl)
     if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
         prefs_set_int_attribute( "tools.lpetool", "mode", lpeToolMode );
     }
-    EffectType type = lpesubtools[lpeToolMode];
-    SPPenContext *pc = SP_PEN_CONTEXT(desktop->event_context);
+    //EffectType type = lpesubtools[lpeToolMode];
+    //SPPenContext *pc = SP_PEN_CONTEXT(desktop->event_context);
 
     // only take action if run by the attr_changed listener
     if (!g_object_get_data( tbl, "freeze" )) {
@@ -4878,6 +4880,19 @@ sp_lpetool_toolbox_sel_changed(Inkscape::Selection *selection, GObject *tbl)
     g_print ("\n");
 }
 
+static void
+lpetool_toggle_show_bbox (GtkToggleAction *act, gpointer data) {
+    SPDesktop *desktop = static_cast<SPDesktop *>(data);
+
+    bool show = gtk_toggle_action_get_active( act );
+    prefs_set_int_attribute ("tools.lpetool", "show_bbox",  show ? 1 : 0);
+
+    if (tools_isactive(desktop, TOOLS_LPETOOL)) {
+        SPLPEToolContext *lc = SP_LPETOOL_CONTEXT(desktop->event_context);
+        lpetool_context_reset_limiting_bbox(lc);
+    }
+}
+
 static void sp_lpetool_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
 {
     /** Automatically create a list of LPEs that get added to the toolbar **/
@@ -4886,8 +4901,17 @@ static void sp_lpetool_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActi
 
         GtkTreeIter iter;
 
+        // the first toggle button represents the state that no subtool is active (remove this when
+        // this can be modeled by EgeSelectOneAction or some other action)
+        gtk_list_store_append( model, &iter );
+        gtk_list_store_set( model, &iter,
+                            0, _("All inactive"),
+                            1, _("No geometric tool is active"),
+                            2, _("all_inactive"),
+                            -1 );
+
         Inkscape::LivePathEffect::EffectType type;
-        for (int i = 0; i < num_subtools; ++i) {
+        for (int i = 1; i < num_subtools; ++i) { // we start with i = 1 because INVALID_LPE was already added
             type =  lpesubtools[i];
             gtk_list_store_append( model, &iter );
             gtk_list_store_set( model, &iter,
@@ -4912,6 +4936,18 @@ static void sp_lpetool_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActi
         g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(sp_lpetool_mode_changed), holder );
     }
 
+    /* Show limiting bounding box */
+    {
+        InkToggleAction* act = ink_toggle_action_new( "LPEShowBBoxAction",
+                                                      _("Show limiting bounding box"),
+                                                      _("Show bounding box (is used to cut infinite lines)"),
+                                                      "lpetool_show_bbox",
+                                                      Inkscape::ICON_SIZE_DECORATION );
+        gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
+        g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(lpetool_toggle_show_bbox), desktop );
+        gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs_get_int_attribute( "tools.lpetool", "show_bbox", 1 ) );
+    }
+
     /* Test action */
     /**
     {