From: cilix42 Date: Mon, 18 Aug 2008 00:43:01 +0000 (+0000) Subject: Add button whether to display limiting bounding box; add 'all inactive' toggle button... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=e6024a226198c640d87b6ea5c39e2d479d8de715;p=inkscape.git Add button whether to display limiting bounding box; add 'all inactive' toggle button as a workaround that not all toggle buttons can be inactive in an EgeSelectOneAction --- diff --git a/share/icons/icons.svg b/share/icons/icons.svg index 9b6b8d362..a13f7fecd 100644 --- a/share/icons/icons.svg +++ b/share/icons/icons.svg @@ -4958,9 +4958,9 @@ 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/ 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" /> + diff --git a/src/lpe-tool-context.cpp b/src/lpe-tool-context.cpp index f9fc3ad71..881aa47e9 100644 --- a/src/lpe-tool-context.cpp +++ b/src/lpe-tool-context.cpp @@ -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); diff --git a/src/pen-context.cpp b/src/pen-context.cpp index 74498c6c0..b575e94f3 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -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; diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index e7b6a84c8..71c797bff 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -443,6 +443,8 @@ static gchar const * ui_descr = " " " " + " " + " " " " " " @@ -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(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 */ /** {