index 84a4f68e6213830b7a507344c9c851371079ad76..71c797bffd1452e40dfc57393d94cf36dfcc6b99 100644 (file)
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
#include "connector-context.h"
#include "node-context.h"
#include "pen-context.h"
+#include "lpe-tool-context.h"
#include "shape-editor.h"
#include "tweak-context.h"
#include "sp-rect.h"
{ "SPPencilContext", "pencil_tool", SP_VERB_CONTEXT_PENCIL, SP_VERB_CONTEXT_PENCIL_PREFS },
{ "SPPenContext", "pen_tool", SP_VERB_CONTEXT_PEN, SP_VERB_CONTEXT_PEN_PREFS },
{ "SPDynaDrawContext", "dyna_draw_tool", SP_VERB_CONTEXT_CALLIGRAPHIC, SP_VERB_CONTEXT_CALLIGRAPHIC_PREFS },
- { "SPEraserContext", "eraser_tool", SP_VERB_CONTEXT_ERASER, SP_VERB_CONTEXT_ERASER_PREFS },
{ "SPLPEToolContext", "lpetool_tool", SP_VERB_CONTEXT_LPETOOL, SP_VERB_CONTEXT_LPETOOL_PREFS },
+ { "SPEraserContext", "eraser_tool", SP_VERB_CONTEXT_ERASER, SP_VERB_CONTEXT_ERASER_PREFS },
{ "SPFloodContext", "paintbucket_tool", SP_VERB_CONTEXT_PAINTBUCKET, SP_VERB_CONTEXT_PAINTBUCKET_PREFS },
{ "SPTextContext", "text_tool", SP_VERB_CONTEXT_TEXT, SP_VERB_CONTEXT_TEXT_PREFS },
{ "SPConnectorContext","connector_tool", SP_VERB_CONTEXT_CONNECTOR, SP_VERB_CONTEXT_CONNECTOR_PREFS },
" <toolbar name='LPEToolToolbar'>"
" <toolitem action='LPEToolModeAction' />"
+ " <separator />"
+ " <toolitem action='LPEShowBBoxAction' />"
" </toolbar>"
" <toolbar name='DropperToolbar'>"
@@ -4783,12 +4786,7 @@ static void sp_dropper_toolbox_prep(SPDesktop */*desktop*/, GtkActionGroup* main
//## LPETool ##
//########################
-/* This is the list of subtools from which the toolbar of the LPETool is built automatically */
-static Inkscape::LivePathEffect::EffectType lpesubtools[] = {
- Inkscape::LivePathEffect::ANGLE_BISECTOR,
- Inkscape::LivePathEffect::CIRCLE_3PTS,
- Inkscape::LivePathEffect::PERP_BISECTOR
-};
+// the subtools from which the toolbar is built automatically are listed in lpe-tool-context.h
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" )) {
// in turn, prevent listener from responding
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) );
+ // this is now done in sp_lpetool_context_root_handler()
+ /**
// activate the LPE corresponding to the chosen subtool
if (type != INVALID_LPE) {
+ //lc->tool_state = LPETOOL_STATE_PEN;
sp_pen_context_wait_for_LPE_mouse_clicks(pc, type, Effect::acceptsNumClicks(type));
}
// TODO: how can we take LPEs into account that don't expect any 'pre-clicks'?
+ **/
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
}
sp_lpetool_toolbox_sel_changed(Inkscape::Selection *selection, GObject *tbl)
{
using namespace Inkscape::LivePathEffect;
- g_print ("sp_node_toolbox_sel_changed()\n");
+ g_print ("sp_lpetool_toolbox_sel_changed()");
{
GtkAction* w = GTK_ACTION( g_object_get_data( tbl, "lpetool_test_action" ) );
SPItem *item = selection->singleItem();
if (item && SP_IS_LPE_ITEM(item)) {
+ g_print (" - item found\n");
SPLPEItem *lpeitem = SP_LPE_ITEM(item);
Effect* lpe = sp_lpe_item_get_current_lpe(lpeitem);
if (lpe && lpe->effectType() == ANGLE_BISECTOR) {
@@ -4868,11 +4871,26 @@ sp_lpetool_toolbox_sel_changed(Inkscape::Selection *selection, GObject *tbl)
gtk_action_set_sensitive(w, FALSE);
}
} else {
+ g_print (" - unsetting item\n");
g_object_set_data(tbl, "currentlpe", NULL);
g_object_set_data(tbl, "currentlpeitem", NULL);
gtk_action_set_sensitive(w, FALSE);
}
}
+ 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)
@@ -4883,15 +4901,24 @@ static void sp_lpetool_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActi
GtkTreeIter iter;
- Inkscape::LivePathEffect::EffectType type;
- for (int i = 0; i < 3; ++i) {
- type = lpesubtools[i];
+ // 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, Inkscape::LivePathEffect::LPETypeConverter.get_label(type).c_str(),
- 1, Inkscape::LivePathEffect::LPETypeConverter.get_label(type).c_str(),
- 2, Inkscape::LivePathEffect::LPETypeConverter.get_key(type).c_str(),
+ 0, _("All inactive"),
+ 1, _("No geometric tool is active"),
+ 2, _("all_inactive"),
-1 );
+
+ Inkscape::LivePathEffect::EffectType type;
+ 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,
+ 0, Inkscape::LivePathEffect::LPETypeConverter.get_label(type).c_str(),
+ 1, Inkscape::LivePathEffect::LPETypeConverter.get_label(type).c_str(),
+ 2, Inkscape::LivePathEffect::LPETypeConverter.get_key(type).c_str(),
+ -1 );
}
EgeSelectOneAction* act = ege_select_one_action_new( "LPEToolModeAction", (""), (""), NULL, GTK_TREE_MODEL(model) );
@@ -4909,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 */
/**
{