diff options
| author | Maximilian Albert <maximilian.albert@gmail.com> | 2008-08-18 00:47:13 +0000 |
|---|---|---|
| committer | cilix42 <cilix42@users.sourceforge.net> | 2008-08-18 00:47:13 +0000 |
| commit | 890556d030ed1c2877f15709807ce5e9178fe793 (patch) | |
| tree | 320fd56a67afc55dcb98ce129b2c509fd46adf26 /src/widgets/toolbox.cpp | |
| parent | Some debugging messages (diff) | |
| download | inkscape-890556d030ed1c2877f15709807ce5e9178fe793.tar.gz inkscape-890556d030ed1c2877f15709807ce5e9178fe793.zip | |
Toggle button in geometry toolbar to set limiting bounding box for LPELineSegment
(bzr r6685)
Diffstat (limited to 'src/widgets/toolbox.cpp')
| -rw-r--r-- | src/widgets/toolbox.cpp | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 5676529c3..9f8cf1822 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -446,6 +446,7 @@ static gchar const * ui_descr = " <toolitem action='LPEToolModeAction' />" " <separator />" " <toolitem action='LPEShowBBoxAction' />" + " <toolitem action='LPEBBoxFromSelectionAction' />" " <separator />" " <toolitem action='LPELineSegmentAction' />" " </toolbar>" @@ -4849,7 +4850,7 @@ sp_lpetool_toolbox_sel_changed(Inkscape::Selection *selection, GObject *tbl) g_object_set_data(tbl, "currentlpe", lpe); g_object_set_data(tbl, "currentlpeitem", lpeitem); gtk_action_set_sensitive(w, TRUE); - ege_select_one_action_set_active(act, lpels->end_type->get_value()); + ege_select_one_action_set_active(EGE_SELECT_ONE_ACTION(w), lpels->end_type.get_value()); } else { g_print (" - unsetting item\n"); g_object_set_data(tbl, "currentlpe", NULL); @@ -4880,6 +4881,33 @@ lpetool_toggle_show_bbox (GtkToggleAction *act, gpointer data) { } static void +lpetool_toggle_set_bbox (GtkToggleAction *act, gpointer data) { + g_print ("lpetool_toggle_set_bbox()\n"); + SPDesktop *desktop = static_cast<SPDesktop *>(data); + Inkscape::Selection *selection = desktop->selection; + + boost::optional<NR::Rect> bbox = selection->bounds(); + + if (bbox) { + Geom::Point A(bbox->min()); + Geom::Point B(bbox->max()); + + A *= desktop->doc2dt(); + B *= desktop->doc2dt(); + + // TODO: should we provide a way to store points in prefs? + prefs_set_double_attribute ("tools.lpetool", "bbox_upperleftx", A[Geom::X]); + prefs_set_double_attribute ("tools.lpetool", "bbox_upperlefty", A[Geom::Y]); + prefs_set_double_attribute ("tools.lpetool", "bbox_lowerrightx", B[Geom::X]); + prefs_set_double_attribute ("tools.lpetool", "bbox_lowerrighty", B[Geom::Y]); + + lpetool_context_reset_limiting_bbox(SP_LPETOOL_CONTEXT(desktop->event_context)); + } + + gtk_toggle_action_set_active(act, false); +} + +static void sp_line_segment_build_list(GObject *tbl) { g_object_set_data(tbl, "line_segment_list_blocked", GINT_TO_POINTER(TRUE)); @@ -4991,6 +5019,19 @@ static void sp_lpetool_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActi gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs_get_int_attribute( "tools.lpetool", "show_bbox", 1 ) ); } + /* Set limiting bounding box to bbox of current selection */ + { + InkToggleAction* act = ink_toggle_action_new( "LPEBBoxFromSelectionAction", + _("Get limiting bounding box from selection"), + _("Set limiting bounding box (used to cut infinite lines) to the bounding box of current selection"), + "lpetool_set_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_set_bbox), desktop ); + gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), FALSE ); + } + + /* Combo box to choose line segment type */ { GtkListStore* model = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT); |
