diff options
| author | Maximilian Albert <maximilian.albert@gmail.com> | 2008-08-18 00:43:01 +0000 |
|---|---|---|
| committer | cilix42 <cilix42@users.sourceforge.net> | 2008-08-18 00:43:01 +0000 |
| commit | b3a7532b050af92cfab11723604b27f2b1b46f6d (patch) | |
| tree | 121dbc0386eaad347e0d5124bce8e5ef094685cf /src | |
| parent | Slightly enlarge icon for geometric tool (diff) | |
| download | inkscape-b3a7532b050af92cfab11723604b27f2b1b46f6d.tar.gz inkscape-b3a7532b050af92cfab11723604b27f2b1b46f6d.zip | |
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
(bzr r6673)
Diffstat (limited to 'src')
| -rw-r--r-- | src/lpe-tool-context.cpp | 11 | ||||
| -rw-r--r-- | src/pen-context.cpp | 4 | ||||
| -rw-r--r-- | src/widgets/toolbox.cpp | 42 |
3 files changed, 52 insertions, 5 deletions
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 = " <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 */ /** { |
