summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 494c671)
raw | patch | inline | side by side (parent: 494c671)
author | cilix42 <cilix42@users.sourceforge.net> | |
Mon, 18 Aug 2008 00:34:25 +0000 (00:34 +0000) | ||
committer | cilix42 <cilix42@users.sourceforge.net> | |
Mon, 18 Aug 2008 00:34:25 +0000 (00:34 +0000) |
13 files changed:
src/Makefile_insert | patch | blob | history | |
src/lpe-tool-context.cpp | [new file with mode: 0644] | patch | blob |
src/lpe-tool-context.h | [new file with mode: 0644] | patch | blob |
src/pen-context.cpp | patch | blob | history | |
src/pen-context.h | patch | blob | history | |
src/preferences-skeleton.h | patch | blob | history | |
src/tools-switch.cpp | patch | blob | history | |
src/tools-switch.h | patch | blob | history | |
src/ui/dialog/inkscape-preferences.cpp | patch | blob | history | |
src/ui/dialog/inkscape-preferences.h | patch | blob | history | |
src/verbs.cpp | patch | blob | history | |
src/verbs.h | patch | blob | history | |
src/widgets/toolbox.cpp | patch | blob | history |
diff --git a/src/Makefile_insert b/src/Makefile_insert
index f4aba89b9b120e9f4d6b9d5a9f8ab4d03c1abd6a..8769597985933bf4ba945a065705cb97f0300775 100644 (file)
--- a/src/Makefile_insert
+++ b/src/Makefile_insert
layer-fns.cpp layer-fns.h \
layer-manager.cpp layer-manager.h \
line-geometry.cpp line-geometry.h \
+ lpe-tool-context.cpp lpe-tool-context.h \
macros.h \
main-cmdlineact.cpp main-cmdlineact.h \
media.cpp media.h \
diff --git a/src/lpe-tool-context.cpp b/src/lpe-tool-context.cpp
--- /dev/null
+++ b/src/lpe-tool-context.cpp
@@ -0,0 +1,401 @@
+/*
+ * LPEToolContext: a context for a generic tool composed of subtools that are given by LPEs
+ *
+ * Authors:
+ * Maximilian Albert <maximilian.albert@gmail.com>
+ * Lauris Kaplinski <lauris@kaplinski.com>
+ *
+ * Copyright (C) 1998 The Free Software Foundation
+ * Copyright (C) 1999-2005 authors
+ * Copyright (C) 2001-2002 Ximian, Inc.
+ * Copyright (C) 2008 Maximilian Albert
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "config.h"
+
+#include "forward.h"
+#include "pixmaps/cursor-pencil.xpm"
+#include <gtk/gtk.h>
+#include "desktop.h"
+#include "message-context.h"
+#include "prefs-utils.h"
+
+/**
+
+#include <gdk/gdkkeysyms.h>
+#include <glibmm/i18n.h>
+#include <string>
+#include <cstring>
+#include <numeric>
+
+#include "svg/svg.h"
+#include "display/canvas-bpath.h"
+#include "display/bezier-utils.h"
+
+#include <glib/gmem.h>
+#include "macros.h"
+#include "document.h"
+#include "selection.h"
+#include "desktop-events.h"
+#include "desktop-handles.h"
+#include "desktop-affine.h"
+#include "desktop-style.h"
+#include "xml/repr.h"
+#include "context-fns.h"
+#include "sp-item.h"
+#include "inkscape.h"
+#include "color.h"
+#include "rubberband.h"
+#include "splivarot.h"
+#include "sp-item-group.h"
+#include "sp-shape.h"
+#include "sp-path.h"
+#include "sp-text.h"
+#include "display/canvas-bpath.h"
+#include "display/canvas-arena.h"
+#include "livarot/Shape.h"
+#include <2geom/isnan.h>
+#include <2geom/pathvector.h>
+**/
+
+#include "lpe-tool-context.h"
+
+static void sp_lpetool_context_class_init(SPLPEToolContextClass *klass);
+static void sp_lpetool_context_init(SPLPEToolContext *erc);
+static void sp_lpetool_context_dispose(GObject *object);
+
+static void sp_lpetool_context_setup(SPEventContext *ec);
+static void sp_lpetool_context_set(SPEventContext *ec, gchar const *key, gchar const *val);
+static gint sp_lpetool_context_root_handler(SPEventContext *ec, GdkEvent *event);
+
+
+static SPEventContextClass *lpetool_parent_class = 0;
+
+GType sp_lpetool_context_get_type(void)
+{
+ static GType type = 0;
+ if (!type) {
+ GTypeInfo info = {
+ sizeof(SPLPEToolContextClass),
+ 0, // base_init
+ 0, // base_finalize
+ (GClassInitFunc)sp_lpetool_context_class_init,
+ 0, // class_finalize
+ 0, // class_data
+ sizeof(SPLPEToolContext),
+ 0, // n_preallocs
+ (GInstanceInitFunc)sp_lpetool_context_init,
+ 0 // value_table
+ };
+ type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "SPLPEToolContext", &info, static_cast<GTypeFlags>(0));
+ }
+ return type;
+}
+
+static void
+sp_lpetool_context_class_init(SPLPEToolContextClass *klass)
+{
+ GObjectClass *object_class = (GObjectClass *) klass;
+ SPEventContextClass *event_context_class = (SPEventContextClass *) klass;
+
+ lpetool_parent_class = (SPEventContextClass*)g_type_class_peek_parent(klass);
+
+ object_class->dispose = sp_lpetool_context_dispose;
+
+ event_context_class->setup = sp_lpetool_context_setup;
+ event_context_class->set = sp_lpetool_context_set;
+ event_context_class->root_handler = sp_lpetool_context_root_handler;
+}
+
+static void
+sp_lpetool_context_init(SPLPEToolContext *erc)
+{
+ erc->cursor_shape = cursor_pencil_xpm;
+ erc->hot_x = 4;
+ erc->hot_y = 4;
+}
+
+static void
+sp_lpetool_context_dispose(GObject *object)
+{
+ //SPLPEToolContext *erc = SP_LPETOOL_CONTEXT(object);
+
+ G_OBJECT_CLASS(lpetool_parent_class)->dispose(object);
+}
+
+static void
+sp_lpetool_context_setup(SPEventContext *ec)
+{
+ SPLPEToolContext *erc = SP_LPETOOL_CONTEXT(ec);
+
+ if (((SPEventContextClass *) lpetool_parent_class)->setup)
+ ((SPEventContextClass *) lpetool_parent_class)->setup(ec);
+
+ erc->_message_context = new Inkscape::MessageContext((ec->desktop)->messageStack());
+
+ if (prefs_get_int_attribute("tools.lpetool", "selcue", 0) != 0) {
+ ec->enableSelectionCue();
+ }
+// TODO temp force:
+ ec->enableSelectionCue();
+}
+
+static void
+sp_lpetool_context_set(SPEventContext *ec, gchar const *key, gchar const *val)
+{
+ //pass on up to parent class to handle common attributes.
+ if ( lpetool_parent_class->set ) {
+ lpetool_parent_class->set(ec, key, val);
+ }
+}
+
+/**
+void
+sp_erc_update_toolbox (SPDesktop *desktop, const gchar *id, double value)
+{
+ desktop->setToolboxAdjustmentValue (id, value);
+}
+**/
+
+gint
+sp_lpetool_context_root_handler(SPEventContext *event_context,
+ GdkEvent *event)
+{
+ //SPLPEToolContext *dc = SP_LPETOOL_CONTEXT(event_context);
+ //SPDesktop *desktop = event_context->desktop;
+
+ gint ret = FALSE;
+
+ /**
+ switch (event->type) {
+ case GDK_BUTTON_PRESS:
+ if (event->button.button == 1 && !event_context->space_panning) {
+
+ SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(dc);
+
+ if (Inkscape::have_viable_layer(desktop, dc->_message_context) == false) {
+ return TRUE;
+ }
+
+ NR::Point const button_w(event->button.x,
+ event->button.y);
+ NR::Point const button_dt(desktop->w2d(button_w));
+ sp_lpetool_reset(dc, button_dt);
+ sp_lpetool_extinput(dc, event);
+ sp_lpetool_apply(dc, button_dt);
+ dc->accumulated->reset();
+ if (dc->repr) {
+ dc->repr = NULL;
+ }
+
+ Inkscape::Rubberband::get()->start(desktop, button_dt);
+ Inkscape::Rubberband::get()->setMode(RUBBERBAND_MODE_TOUCHPATH);
+
+ // initialize first point
+ dc->npoints = 0;
+
+ sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
+ ( GDK_KEY_PRESS_MASK |
+ GDK_BUTTON_RELEASE_MASK |
+ GDK_POINTER_MOTION_MASK |
+ GDK_BUTTON_PRESS_MASK ),
+ NULL,
+ event->button.time);
+
+ ret = TRUE;
+
+ sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 3);
+ dc->is_drawing = true;
+ }
+ break;
+ case GDK_MOTION_NOTIFY:
+ {
+ NR::Point const motion_w(event->motion.x,
+ event->motion.y);
+ NR::Point motion_dt(desktop->w2d(motion_w));
+ sp_lpetool_extinput(dc, event);
+
+ dc->_message_context->clear();
+
+ if ( dc->is_drawing && (event->motion.state & GDK_BUTTON1_MASK) && !event_context->space_panning) {
+ dc->dragging = TRUE;
+
+ dc->_message_context->set(Inkscape::NORMAL_MESSAGE, _("<b>Drawing</b> an lpetool stroke"));
+
+ if (!sp_lpetool_apply(dc, motion_dt)) {
+ ret = TRUE;
+ break;
+ }
+
+ if ( dc->cur != dc->last ) {
+ sp_lpetool_brush(dc);
+ g_assert( dc->npoints > 0 );
+ fit_and_split(dc, FALSE);
+ }
+ ret = TRUE;
+ }
+ Inkscape::Rubberband::get()->move(motion_dt);
+ }
+ break;
+
+
+ case GDK_BUTTON_RELEASE:
+ {
+ NR::Point const motion_w(event->button.x, event->button.y);
+ NR::Point const motion_dt(desktop->w2d(motion_w));
+
+ sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), event->button.time);
+ sp_canvas_end_forced_full_redraws(desktop->canvas);
+ dc->is_drawing = false;
+
+ if (dc->dragging && event->button.button == 1 && !event_context->space_panning) {
+ dc->dragging = FALSE;
+
+ NR::Maybe<NR::Rect> const b = Inkscape::Rubberband::get()->getRectangle();
+
+ sp_lpetool_apply(dc, motion_dt);
+
+ // Remove all temporary line segments
+ while (dc->segments) {
+ gtk_object_destroy(GTK_OBJECT(dc->segments->data));
+ dc->segments = g_slist_remove(dc->segments, dc->segments->data);
+ }
+
+ // Create object
+ fit_and_split(dc, TRUE);
+ accumulate_lpetool(dc);
+ set_to_accumulated(dc); // performs document_done
+
+ // reset accumulated curve
+ dc->accumulated->reset();
+
+ clear_current(dc);
+ if (dc->repr) {
+ dc->repr = NULL;
+ }
+
+ Inkscape::Rubberband::get()->stop();
+ dc->_message_context->clear();
+ ret = TRUE;
+ }
+ break;
+ }
+
+ case GDK_KEY_PRESS:
+ switch (get_group0_keyval (&event->key)) {
+ case GDK_Up:
+ case GDK_KP_Up:
+ if (!MOD__CTRL_ONLY) {
+ dc->angle += 5.0;
+ if (dc->angle > 90.0)
+ dc->angle = 90.0;
+ sp_erc_update_toolbox (desktop, "lpetool-angle", dc->angle);
+ ret = TRUE;
+ }
+ break;
+ case GDK_Down:
+ case GDK_KP_Down:
+ if (!MOD__CTRL_ONLY) {
+ dc->angle -= 5.0;
+ if (dc->angle < -90.0)
+ dc->angle = -90.0;
+ sp_erc_update_toolbox (desktop, "lpetool-angle", dc->angle);
+ ret = TRUE;
+ }
+ break;
+ case GDK_Right:
+ case GDK_KP_Right:
+ if (!MOD__CTRL_ONLY) {
+ dc->width += 0.01;
+ if (dc->width > 1.0)
+ dc->width = 1.0;
+ sp_erc_update_toolbox (desktop, "altx-lpetool", dc->width * 100); // the same spinbutton is for alt+x
+ ret = TRUE;
+ }
+ break;
+ case GDK_Left:
+ case GDK_KP_Left:
+ if (!MOD__CTRL_ONLY) {
+ dc->width -= 0.01;
+ if (dc->width < 0.01)
+ dc->width = 0.01;
+ sp_erc_update_toolbox (desktop, "altx-lpetool", dc->width * 100);
+ ret = TRUE;
+ }
+ break;
+ case GDK_Home:
+ case GDK_KP_Home:
+ dc->width = 0.01;
+ sp_erc_update_toolbox (desktop, "altx-lpetool", dc->width * 100);
+ ret = TRUE;
+ break;
+ case GDK_End:
+ case GDK_KP_End:
+ dc->width = 1.0;
+ sp_erc_update_toolbox (desktop, "altx-lpetool", dc->width * 100);
+ ret = TRUE;
+ break;
+ case GDK_x:
+ case GDK_X:
+ if (MOD__ALT_ONLY) {
+ desktop->setToolboxFocusTo ("altx-lpetool");
+ ret = TRUE;
+ }
+ break;
+ case GDK_Escape:
+ Inkscape::Rubberband::get()->stop();
+ if (dc->is_drawing) {
+ // if drawing, cancel, otherwise pass it up for deselecting
+ lpetool_cancel (dc);
+ ret = TRUE;
+ }
+ break;
+ case GDK_z:
+ case GDK_Z:
+ if (MOD__CTRL_ONLY && dc->is_drawing) {
+ // if drawing, cancel, otherwise pass it up for undo
+ lpetool_cancel (dc);
+ ret = TRUE;
+ }
+ break;
+ default:
+ break;
+ }
+ break;
+
+ case GDK_KEY_RELEASE:
+ switch (get_group0_keyval(&event->key)) {
+ case GDK_Control_L:
+ case GDK_Control_R:
+ dc->_message_context->clear();
+ break;
+ default:
+ break;
+ }
+
+ default:
+ break;
+ }
+ **/
+
+ if (!ret) {
+ if (((SPEventContextClass *) lpetool_parent_class)->root_handler) {
+ ret = ((SPEventContextClass *) lpetool_parent_class)->root_handler(event_context, event);
+ }
+ }
+
+ return ret;
+}
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
diff --git a/src/lpe-tool-context.h b/src/lpe-tool-context.h
--- /dev/null
+++ b/src/lpe-tool-context.h
@@ -0,0 +1,48 @@
+#ifndef SP_LPETOOL_CONTEXT_H_SEEN
+#define SP_LPETOOL_CONTEXT_H_SEEN
+
+/*
+ * LPEToolContext: a context for a generic tool composed of subtools that are given by LPEs
+ *
+ * Authors:
+ * Maximilian Albert <maximilian.albert@gmail.com>
+ * Lauris Kaplinski <lauris@kaplinski.com>
+ *
+ * Copyright (C) 1998 The Free Software Foundation
+ * Copyright (C) 1999-2002 authors
+ * Copyright (C) 2001-2002 Ximian, Inc.
+ * Copyright (C) 2008 Maximilian Albert
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "event-context.h"
+
+#define SP_TYPE_LPETOOL_CONTEXT (sp_lpetool_context_get_type())
+#define SP_LPETOOL_CONTEXT(o) (GTK_CHECK_CAST((o), SP_TYPE_LPETOOL_CONTEXT, SPLPEToolContext))
+#define SP_LPETOOL_CONTEXT_CLASS(k) (GTK_CHECK_CLASS_CAST((k), SP_TYPE_LPETOOL_CONTEXT, SPLPEToolContextClass))
+#define SP_IS_LPETOOL_CONTEXT(o) (GTK_CHECK_TYPE((o), SP_TYPE_LPETOOL_CONTEXT))
+#define SP_IS_LPETOOL_CONTEXT_CLASS(k) (GTK_CHECK_CLASS_TYPE((k), SP_TYPE_LPETOOL_CONTEXT))
+
+class SPLPEToolContext;
+class SPLPEToolContextClass;
+
+struct SPLPEToolContext : public SPEventContext {
+};
+
+struct SPLPEToolContextClass : public SPEventContextClass{};
+
+GType sp_lpetool_context_get_type(void);
+
+#endif // SP_LPETOOL_CONTEXT_H_SEEN
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
diff --git a/src/pen-context.cpp b/src/pen-context.cpp
index 8e1f6947b13dc0d2eff727ace1e792bea8332655..22f83a21941f9c7b1647614b3d58e5135d62687b 100644 (file)
--- a/src/pen-context.cpp
+++ b/src/pen-context.cpp
#include "helper/units.h"
#include "macros.h"
#include "context-fns.h"
+#include "tools-switch.h"
static void sp_pen_context_class_init(SPPenContextClass *klass);
static void sp_pen_context_init(SPPenContext *pc);
diff --git a/src/pen-context.h b/src/pen-context.h
index 24afa701c609230f4914bb78a2e2720513c41270..a358126acad8e5074d0f636160637c095d96126e 100644 (file)
--- a/src/pen-context.h
+++ b/src/pen-context.h
void sp_pen_context_set_polyline_mode(SPPenContext *const pc);
void sp_pen_context_wait_for_LPE_mouse_clicks(SPPenContext *pc, Inkscape::LivePathEffect::EffectType effect_type,
unsigned int num_clicks, bool use_polylines = true);
+void sp_pen_context_put_into_waiting_mode(SPDesktop *desktop, Inkscape::LivePathEffect::EffectType effect_type,
+ unsigned int num_clicks, bool use_polylines = true);
#endif /* !SEEN_PEN_CONTEXT_H */
index 1b9561aced6d2a332bf280971a9c0fa3bbbe2c6a..dfbbd61eeaa405eec8b43ef3cf7973c718d76e82 100644 (file)
" mass=\"0.02\" drag=\"1\" angle=\"30\" width=\"0.15\" thinning=\"0.1\" flatness=\"0.9\" cap_rounding=\"0.0\" usecurrent=\"0\"\n"
" tracebackground=\"0\" usepressure=\"1\" usetilt=\"0\" selcue=\"1\">\n"
" </eventcontext>\n"
+" <eventcontext id=\"lpetool\" mode=\"0\" style=\"fill:#ff0000;fill-opacity:1;fill-rule:nonzero;stroke:none;\">\n"
+" </eventcontext>\n"
" <eventcontext id=\"text\" usecurrent=\"0\" gradientdrag=\"1\"\n"
" font_sample=\"AaBbCcIiPpQq12369$\342\202\254\302\242?.;/()\"\n"
" style=\"fill:black;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;font-style:normal;font-weight:normal;font-size:40px;\" selcue=\"1\"/>\n"
diff --git a/src/tools-switch.cpp b/src/tools-switch.cpp
index 4c51f4e106a43b3cd9edae77b598916f37727ffb..6ee162f1db6f8a89a8c1fbf1391ce23aa425ea54 100644 (file)
--- a/src/tools-switch.cpp
+++ b/src/tools-switch.cpp
#include "eraser-context.h"
#include "pen-context.h"
#include "pencil-context.h"
+#include "lpe-tool-context.h"
#include "text-context.h"
#include "sp-text.h"
#include "sp-flowtext.h"
"tools.connector",
"tools.paintbucket",
"tools.eraser",
+ "tools.lpetool",
NULL
};
"connector",
"paintbucket",
"eraser",
+ "lpetool",
NULL
};
inkscape_eventcontext_set(sp_desktop_event_context(dt));
dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("<b>Drag</b> to erase."));
break;
+ case TOOLS_LPETOOL:
+ dt->set_event_context(SP_TYPE_LPETOOL_CONTEXT, tool_names[num]);
+ dt->activate_guides(false);
+ inkscape_eventcontext_set(sp_desktop_event_context(dt));
+ dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Choose a subtool from the toolbar"));
+ break;
}
}
diff --git a/src/tools-switch.h b/src/tools-switch.h
index f5a3220ca32b012b865fb92b211ce48fa5d41999..2026c1a3d257591a086a73c6c7bf4720178696ff 100644 (file)
--- a/src/tools-switch.h
+++ b/src/tools-switch.h
TOOLS_DROPPER,
TOOLS_CONNECTOR,
TOOLS_PAINTBUCKET,
- TOOLS_ERASER
+ TOOLS_ERASER,
+ TOOLS_LPETOOL
};
int tools_isactive(SPDesktop *dt, unsigned num);
index ecedf6003031e89c59155d87c6f191373a56fe0b..8a2a44ccc5f1543488c5994c57cdbad07296c3aa 100644 (file)
this->AddPage(_page_eraser, _("Eraser"), iter_tools, PREFS_PAGE_TOOLS_ERASER);
this->AddNewObjectsStyle(_page_eraser, "tools.eraser");
+ //LPETool
+ this->AddPage(_page_lpetool, _("LPE Tool"), iter_tools, PREFS_PAGE_TOOLS_LPETOOL);
+ this->AddNewObjectsStyle(_page_lpetool, "tools.lpetool");
+
//Text
this->AddPage(_page_text, _("Text"), iter_tools, PREFS_PAGE_TOOLS_TEXT);
this->AddSelcueCheckbox(_page_text, "tools.text", true);
index 6efebb7427a7373ef7e3cf5a424dbe2d9ef9a4c0..ab4f7881056bc1054d8710bc03ee6279c54aece5 100644 (file)
PREFS_PAGE_TOOLS_CALLIGRAPHY,
PREFS_PAGE_TOOLS_PAINTBUCKET,
PREFS_PAGE_TOOLS_ERASER,
+ PREFS_PAGE_TOOLS_LPETOOL,
PREFS_PAGE_TOOLS_TEXT,
PREFS_PAGE_TOOLS_GRADIENT,
PREFS_PAGE_TOOLS_CONNECTOR,
_page_importexport, _page_cms, _page_grids, _page_svgoutput, _page_misc,
_page_ui, _page_autosave, _page_bitmaps;
DialogPage _page_selector, _page_node, _page_tweak, _page_zoom, _page_shapes, _page_pencil, _page_pen,
- _page_calligraphy, _page_text, _page_gradient, _page_connector, _page_dropper;
+ _page_calligraphy, _page_text, _page_gradient, _page_connector, _page_dropper, _page_lpetool;
DialogPage _page_rectangle, _page_3dbox, _page_ellipse, _page_star, _page_spiral, _page_paintbucket, _page_eraser;
PrefSpinButton _mouse_sens, _mouse_thres;
diff --git a/src/verbs.cpp b/src/verbs.cpp
index 5947ac2cf817f70c8acd8ba455c8975dd225fc43..a9840667e7a4c150e25882c25b7c982436baf902 100644 (file)
--- a/src/verbs.cpp
+++ b/src/verbs.cpp
case SP_VERB_CONTEXT_ERASER:
tools_switch_current(TOOLS_ERASER);
break;
+ case SP_VERB_CONTEXT_LPETOOL:
+ tools_switch_current(TOOLS_LPETOOL);
+ break;
case SP_VERB_CONTEXT_SELECT_PREFS:
prefs_set_int_attribute("dialogs.preferences", "page", PREFS_PAGE_TOOLS_SELECTOR);
prefs_set_int_attribute("dialogs.preferences", "page", PREFS_PAGE_TOOLS_ERASER);
dt->_dlg_mgr->showDialog("InkscapePreferences");
break;
+ case SP_VERB_CONTEXT_LPETOOL_PREFS:
+ g_print ("TODO: Create preferences page for LPETool\n");
+ prefs_set_int_attribute("dialogs.preferences", "page", PREFS_PAGE_TOOLS_LPETOOL);
+ dt->_dlg_mgr->showDialog("InkscapePreferences");
+ break;
default:
break;
N_("Edit Live Path Effect parameters"), "draw_lpe"),
new ContextVerb(SP_VERB_CONTEXT_ERASER, "ToolEraser", N_("Eraser"),
N_("Erase existing paths"), "draw_erase"),
+ new ContextVerb(SP_VERB_CONTEXT_LPETOOL, "ToolLPETool", N_("LPE Tool"),
+ N_("Write something sensible here"), "draw_lpetool"),
/* Tool prefs */
new ContextVerb(SP_VERB_CONTEXT_SELECT_PREFS, "SelectPrefs", N_("Selector Preferences"),
N_("Open Preferences for the Selector tool"), NULL),
N_("Open Preferences for the Paint Bucket tool"), NULL),
new ContextVerb(SP_VERB_CONTEXT_ERASER_PREFS, "EraserPrefs", N_("Eraser Preferences"),
N_("Open Preferences for the Eraser tool"), NULL),
+ new ContextVerb(SP_VERB_CONTEXT_LPETOOL_PREFS, "LPEToolPrefs", N_("LPE Tool Preferences"),
+ N_("Open Preferences for the LPETool tool"), NULL),
/* Zoom/View */
new ZoomVerb(SP_VERB_ZOOM_IN, "ZoomIn", N_("Zoom In"), N_("Zoom in"), "zoom_in"),
diff --git a/src/verbs.h b/src/verbs.h
index bb3cd3a3bf14f6b276501bd4f7dd6f1290dcbed6..2362f23aac6398f6cd7291fa63d880d137e1c7cc 100644 (file)
--- a/src/verbs.h
+++ b/src/verbs.h
SP_VERB_CONTEXT_PAINTBUCKET,
SP_VERB_CONTEXT_LPE, /* not really a tool but used for editing LPE parameters on-canvas for example */
SP_VERB_CONTEXT_ERASER,
+ SP_VERB_CONTEXT_LPETOOL, /* note that this is very different from SP_VERB_CONTEXT_LPE above! */
/* Tool preferences */
SP_VERB_CONTEXT_SELECT_PREFS,
SP_VERB_CONTEXT_NODE_PREFS,
SP_VERB_CONTEXT_CONNECTOR_PREFS,
SP_VERB_CONTEXT_PAINTBUCKET_PREFS,
SP_VERB_CONTEXT_ERASER_PREFS,
+ SP_VERB_CONTEXT_LPETOOL_PREFS,
/* Zooming and desktop settings */
SP_VERB_ZOOM_IN,
SP_VERB_ZOOM_OUT,
index a7591608fb7f8b44c397ccb02d6912b579bb7655..18becfdb66b32b13ece1cdc44b105ee39ec9c62a 100644 (file)
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
static void sp_connector_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder);
static void sp_paintbucket_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder);
static void sp_eraser_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder);
+static void sp_lpetool_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder);
namespace { GtkWidget *sp_text_toolbox_new (SPDesktop *desktop); }
{ "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 },
{ "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 },
SP_VERB_CONTEXT_CALLIGRAPHIC_PREFS, "tools.calligraphic", N_("Style of new calligraphic strokes")},
{ "SPEraserContext", "eraser_toolbox", 0, sp_eraser_toolbox_prep,"EraserToolbar",
SP_VERB_CONTEXT_ERASER_PREFS, "tools.eraser", _("TBD")},
+ { "SPLPEToolContext", "lpetool_toolbox", 0, sp_lpetool_toolbox_prep, "LPEToolToolbar",
+ SP_VERB_CONTEXT_LPETOOL_PREFS, "tools.lpetool", _("TBD")},
{ "SPTextContext", "text_toolbox", sp_text_toolbox_new, 0, 0,
SP_VERB_INVALID, 0, 0},
{ "SPDropperContext", "dropper_toolbox", 0, sp_dropper_toolbox_prep, "DropperToolbar",
" <toolitem action='EraserModeAction' />"
" </toolbar>"
+ " <toolbar name='LPEToolToolbar'>"
+ " <toolitem action='LPEToolModeAction' />"
+ " </toolbar>"
+
" <toolbar name='DropperToolbar'>"
" <toolitem action='DropperOpacityAction' />"
" <toolitem action='DropperPickAlphaAction' />"
" <toolitem action='ToolPen' />"
" <toolitem action='ToolCalligraphic' />"
" <toolitem action='ToolEraser' />"
+ " <toolitem action='ToolLPETool' />"
" <toolitem action='ToolPaintBucket' />"
" <toolitem action='ToolText' />"
" <toolitem action='ToolConnector' />"
}
-static void sp_erasertb_mode_changed( EgeSelectOneAction *act, GObject *tbl )
-{
- SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" );
- gint eraserMode = (ege_select_one_action_get_active( act ) != 0) ? 1 : 0;
- if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
- prefs_set_int_attribute( "tools.eraser", "mode", eraserMode );
- }
-
- // 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) );
-
- if ( eraserMode != 0 ) {
- } else {
- }
- // TODO finish implementation
-
- g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
- }
-}
-
static void sp_arctb_open_state_changed( EgeSelectOneAction *act, GObject *tbl )
{
SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" );
@@ -4790,6 +4777,104 @@ static void sp_dropper_toolbox_prep(SPDesktop */*desktop*/, GtkActionGroup* main
}
+//########################
+//## LPETool ##
+//########################
+
+static void sp_lpetool_mode_changed(EgeSelectOneAction *act, GObject *tbl)
+{
+ SPDesktop *desktop = (SPDesktop *) g_object_get_data(tbl, "desktop");
+ gint lpeToolMode = (ege_select_one_action_get_active(act) != 0) ? 1 : 0;
+ if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
+ prefs_set_int_attribute( "tools.lpetool", "mode", lpeToolMode );
+ }
+
+ // 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) );
+
+ switch (lpeToolMode) {
+ case 0:
+ // angle bisector
+ g_print ("angle bisector\n");
+ break;
+ case 1:
+ // circle through 3 points
+ g_print ("circle through 3 points\n");
+ sp_pen_context_put_into_waiting_mode(desktop, Inkscape::LivePathEffect::CIRCLE_3PTS, 3);
+ break;
+ default:
+ // don't do anything
+ break;
+ }
+ // TODO finish implementation
+
+ g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
+ }
+}
+
+static void sp_lpetool_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
+{
+ {
+ GtkListStore* model = gtk_list_store_new( 3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING );
+
+ GtkTreeIter iter;
+ gtk_list_store_append( model, &iter );
+ gtk_list_store_set( model, &iter,
+ 0, _("Angle bisector"),
+ 1, _("Angle bisector"),
+ 2, "delete_object",
+ -1 );
+
+ gtk_list_store_append( model, &iter );
+ gtk_list_store_set( model, &iter,
+ 0, _("Circle through 3 points"),
+ 1, _("Circle through 3 points"),
+ 2, "difference",
+ -1 );
+
+ EgeSelectOneAction* act = ege_select_one_action_new( "LPEToolModeAction", (""), (""), NULL, GTK_TREE_MODEL(model) );
+ gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
+ g_object_set_data( holder, "lpetool_mode_action", act );
+
+ ege_select_one_action_set_appearance( act, "full" );
+ ege_select_one_action_set_radio_action_type( act, INK_RADIO_ACTION_TYPE );
+ g_object_set( G_OBJECT(act), "icon-property", "iconId", NULL );
+ ege_select_one_action_set_icon_column( act, 2 );
+ ege_select_one_action_set_tooltip_column( act, 1 );
+
+ gint lpeToolMode = (prefs_get_int_attribute("tools.lpetool", "mode", 0) != 0) ? 1 : 0;
+ ege_select_one_action_set_active( act, lpeToolMode );
+ g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(sp_lpetool_mode_changed), holder );
+ }
+}
+
+//########################
+//## Eraser ##
+//########################
+
+static void sp_erasertb_mode_changed( EgeSelectOneAction *act, GObject *tbl )
+{
+ SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" );
+ gint eraserMode = (ege_select_one_action_get_active( act ) != 0) ? 1 : 0;
+ if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
+ prefs_set_int_attribute( "tools.eraser", "mode", eraserMode );
+ }
+
+ // 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) );
+
+ if ( eraserMode != 0 ) {
+ } else {
+ }
+ // TODO finish implementation
+
+ g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
+ }
+}
static void sp_eraser_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
{