From dbda80349e95767e390a178cda7c05787fbce1fe Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Fri, 5 Apr 2013 17:51:29 +0200 Subject: Merged Group and subclasses. (bzr r11608.1.77) --- src/ui/dialog/object-attributes.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/object-attributes.cpp b/src/ui/dialog/object-attributes.cpp index 027c9ae56..9a7b91c57 100644 --- a/src/ui/dialog/object-attributes.cpp +++ b/src/ui/dialog/object-attributes.cpp @@ -124,16 +124,20 @@ void ObjectAttributes::widget_setup (void) } blocked = true; + + // CPPIFY SPObject *obj = SP_OBJECT(item); //to get the selected item - GObjectClass *klass = G_OBJECT_GET_CLASS(obj); //to deduce the object's type - GType type = G_TYPE_FROM_CLASS(klass); +// GObjectClass *klass = G_OBJECT_GET_CLASS(obj); //to deduce the object's type +// GType type = G_TYPE_FROM_CLASS(klass); const SPAttrDesc *desc; - if (type == SP_TYPE_ANCHOR) +// if (type == SP_TYPE_ANCHOR) + if (SP_IS_ANCHOR(item)) { desc = anchor_desc; } - else if (type == SP_TYPE_IMAGE) +// else if (type == SP_TYPE_IMAGE) + else if (SP_IS_IMAGE(item)) { Inkscape::XML::Node *ir = obj->getRepr(); const gchar *href = ir->attribute("xlink:href"); -- cgit v1.2.3 From b0cc47554b385fb68643d07efe6e42366c7121ad Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 6 Apr 2013 01:36:16 +0200 Subject: Merged PaintServer and subclasses; moved Gradient classes to own files. (bzr r11608.1.82) --- src/ui/clipboard.cpp | 5 ++--- src/ui/dialog/swatches.cpp | 1 - src/ui/widget/selected-style.cpp | 4 ++-- src/ui/widget/style-swatch.cpp | 4 ++-- 4 files changed, 6 insertions(+), 8 deletions(-) (limited to 'src/ui') diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index f2b9fb02a..0fbc09df8 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -61,9 +61,8 @@ #include "sp-shape.h" #include "sp-gradient.h" #include "sp-gradient-reference.h" -#include "sp-gradient-fns.h" -#include "sp-linear-gradient-fns.h" -#include "sp-radial-gradient-fns.h" +#include "sp-linear-gradient.h" +#include "sp-radial-gradient.h" #include "sp-clippath.h" #include "sp-mask.h" #include "sp-textpath.h" diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index 90cb1cdc9..2884de173 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -42,7 +42,6 @@ #include "path-prefix.h" #include "preferences.h" #include "sp-item.h" -#include "sp-gradient-fns.h" #include "sp-gradient.h" #include "sp-gradient-vector.h" #include "style.h" diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index 18dbb984b..8cb0c5588 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -24,8 +24,8 @@ #include "style.h" #include "desktop-style.h" #include "sp-namedview.h" -#include "sp-linear-gradient-fns.h" -#include "sp-radial-gradient-fns.h" +#include "sp-linear-gradient.h" +#include "sp-radial-gradient.h" #include "sp-pattern.h" #include "ui/dialog/dialog-manager.h" #include "ui/dialog/fill-and-stroke.h" diff --git a/src/ui/widget/style-swatch.cpp b/src/ui/widget/style-swatch.cpp index a89f42575..2880961be 100644 --- a/src/ui/widget/style-swatch.cpp +++ b/src/ui/widget/style-swatch.cpp @@ -20,8 +20,8 @@ #include "ui/widget/color-preview.h" #include "style.h" -#include "sp-linear-gradient-fns.h" -#include "sp-radial-gradient-fns.h" +#include "sp-linear-gradient.h" +#include "sp-radial-gradient.h" #include "sp-pattern.h" #include "xml/repr.h" #include "xml/sp-css-attr.h" -- cgit v1.2.3 From e58cac52b258e64c2cc88b0044bf9cfbaecedce2 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Tue, 9 Apr 2013 00:23:07 +0200 Subject: Started conversion of SPEventContext tree; added virtual pads to all classes. (bzr r11608.1.89) --- src/ui/tool/node-tool.cpp | 60 +++++++++++++++++++++++++++++++++++++---------- src/ui/tool/node-tool.h | 20 +++++++++++++++- 2 files changed, 67 insertions(+), 13 deletions(-) (limited to 'src/ui') diff --git a/src/ui/tool/node-tool.cpp b/src/ui/tool/node-tool.cpp index e743e0efc..9a51870af 100644 --- a/src/ui/tool/node-tool.cpp +++ b/src/ui/tool/node-tool.cpp @@ -104,7 +104,7 @@ using Inkscape::ControlManager; -namespace { +//namespace { SPCanvasGroup *create_control_group(SPDesktop *d); void ink_node_tool_dispose(GObject *object); @@ -122,7 +122,7 @@ void ink_node_tool_mouseover_changed(InkNodeTool *nt, Inkscape::UI::ControlPoint void handleControlUiStyleChange(InkNodeTool *nt); -} // anonymous namespace +//} // anonymous namespace G_DEFINE_TYPE(InkNodeTool, ink_node_tool, SP_TYPE_EVENT_CONTEXT); @@ -140,9 +140,17 @@ ink_node_tool_class_init(InkNodeToolClass *klass) event_context_class->item_handler = ink_node_tool_item_handler; } +CInkNodeTool::CInkNodeTool(InkNodeTool* inknodetool) : CEventContext(inknodetool) { + this->inknodetool = inknodetool; +} + static void ink_node_tool_init(InkNodeTool *nt) { + nt->cinknodetool = new CInkNodeTool(nt); + delete nt->ceventcontext; + nt->ceventcontext = nt->cinknodetool; + SPEventContext *event_context = SP_EVENT_CONTEXT(nt); event_context->cursor_shape = cursor_node_xpm; @@ -161,7 +169,7 @@ ink_node_tool_init(InkNodeTool *nt) new (&nt->_shape_editors) ShapeEditors(); } -namespace { +//namespace { SPCanvasGroup *create_control_group(SPDesktop *d) { @@ -216,10 +224,17 @@ void ink_node_tool_dispose(GObject *object) void ink_node_tool_setup(SPEventContext *ec) { + ec->ceventcontext->setup(); +} + +void CInkNodeTool::setup() { + SPEventContext* ec = this->speventcontext; + InkNodeTool *nt = INK_NODE_TOOL(ec); - if (SP_EVENT_CONTEXT_CLASS(ink_node_tool_parent_class)->setup) - SP_EVENT_CONTEXT_CLASS(ink_node_tool_parent_class)->setup(ec); +// if (SP_EVENT_CONTEXT_CLASS(ink_node_tool_parent_class)->setup) +// SP_EVENT_CONTEXT_CLASS(ink_node_tool_parent_class)->setup(ec); + CEventContext::setup(); nt->_node_message_context = new Inkscape::MessageContext((ec->desktop)->messageStack()); @@ -322,6 +337,12 @@ void ink_node_tool_setup(SPEventContext *ec) void ink_node_tool_set(SPEventContext *ec, Inkscape::Preferences::Entry *value) { + ec->ceventcontext->set(value); +} + +void CInkNodeTool::set(Inkscape::Preferences::Entry* value) { + SPEventContext* ec = this->speventcontext; + InkNodeTool *nt = INK_NODE_TOOL(ec); Glib::ustring entry_name = value->getEntryName(); @@ -355,8 +376,9 @@ void ink_node_tool_set(SPEventContext *ec, Inkscape::Preferences::Entry *value) nt->edit_masks = value->getBool(); ink_node_tool_selection_changed(nt, nt->desktop->selection); } else { - if (SP_EVENT_CONTEXT_CLASS(ink_node_tool_parent_class)->set) - SP_EVENT_CONTEXT_CLASS(ink_node_tool_parent_class)->set(ec, value); +// if (SP_EVENT_CONTEXT_CLASS(ink_node_tool_parent_class)->set) +// SP_EVENT_CONTEXT_CLASS(ink_node_tool_parent_class)->set(ec, value); + CEventContext::set(value); } } @@ -444,6 +466,12 @@ void ink_node_tool_selection_changed(InkNodeTool *nt, Inkscape::Selection *sel) gint ink_node_tool_root_handler(SPEventContext *event_context, GdkEvent *event) { + return event_context->ceventcontext->root_handler(event); +} + +gint CInkNodeTool::root_handler(GdkEvent* event) { + SPEventContext* event_context = this->speventcontext; + /* things to handle here: * 1. selection of items * 2. passing events to manipulators @@ -537,8 +565,9 @@ gint ink_node_tool_root_handler(SPEventContext *event_context, GdkEvent *event) default: break; } - if (SP_EVENT_CONTEXT_CLASS(ink_node_tool_parent_class)->root_handler) - return SP_EVENT_CONTEXT_CLASS(ink_node_tool_parent_class)->root_handler(event_context, event); +// if (SP_EVENT_CONTEXT_CLASS(ink_node_tool_parent_class)->root_handler) +// return SP_EVENT_CONTEXT_CLASS(ink_node_tool_parent_class)->root_handler(event_context, event); + CEventContext::root_handler(event); return FALSE; } @@ -603,8 +632,15 @@ void ink_node_tool_update_tip(InkNodeTool *nt, GdkEvent *event) gint ink_node_tool_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event) { - if (SP_EVENT_CONTEXT_CLASS(ink_node_tool_parent_class)->item_handler) - return SP_EVENT_CONTEXT_CLASS(ink_node_tool_parent_class)->item_handler(event_context, item, event); + return event_context->ceventcontext->item_handler(item, event); +} + +gint CInkNodeTool::item_handler(SPItem* item, GdkEvent* event) { + + +// if (SP_EVENT_CONTEXT_CLASS(ink_node_tool_parent_class)->item_handler) +// return SP_EVENT_CONTEXT_CLASS(ink_node_tool_parent_class)->item_handler(event_context, item, event); + CEventContext::item_handler(item, event); return FALSE; } @@ -679,7 +715,7 @@ void handleControlUiStyleChange(InkNodeTool *nt) nt->_multipath->updateHandles(); } -} // anonymous namespace +//} // anonymous namespace /* Local Variables: diff --git a/src/ui/tool/node-tool.h b/src/ui/tool/node-tool.h index 341faf329..7223b11b3 100644 --- a/src/ui/tool/node-tool.h +++ b/src/ui/tool/node-tool.h @@ -41,8 +41,13 @@ typedef std::auto_ptr SelectorPtr; typedef std::auto_ptr PathSharedDataPtr; typedef boost::ptr_map ShapeEditors; -struct InkNodeTool : public SPEventContext +class CInkNodeTool; + +class InkNodeTool : public SPEventContext { +public: + CInkNodeTool* cinknodetool; + sigc::connection _selection_changed_connection; sigc::connection _mouseover_changed_connection; sigc::connection _selection_modified_connection; @@ -74,6 +79,19 @@ struct InkNodeToolClass { SPEventContextClass parent_class; }; +class CInkNodeTool : public CEventContext { +public: + CInkNodeTool(InkNodeTool* inknodetool); + + virtual void setup(); + virtual void set(Inkscape::Preferences::Entry* val); + virtual gint root_handler(GdkEvent* event); + virtual gint item_handler(SPItem* item, GdkEvent* event); + +private: + InkNodeTool* inknodetool; +}; + GType ink_node_tool_get_type (void); #endif -- cgit v1.2.3 From 1d8f1753cd8cab38d19fcc26a4ad70ba2e794ac8 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Tue, 9 Apr 2013 22:12:07 +0200 Subject: Added constructors to EventContext tree / some missing virtual pads. (bzr r11608.1.90) --- src/ui/tool/node-tool.cpp | 36 +++++++++++++++++++++++++++++------- src/ui/tool/node-tool.h | 1 + 2 files changed, 30 insertions(+), 7 deletions(-) (limited to 'src/ui') diff --git a/src/ui/tool/node-tool.cpp b/src/ui/tool/node-tool.cpp index 9a51870af..8d8db772a 100644 --- a/src/ui/tool/node-tool.cpp +++ b/src/ui/tool/node-tool.cpp @@ -134,23 +134,39 @@ ink_node_tool_class_init(InkNodeToolClass *klass) object_class->dispose = ink_node_tool_dispose; - event_context_class->setup = ink_node_tool_setup; - event_context_class->set = ink_node_tool_set; - event_context_class->root_handler = ink_node_tool_root_handler; - event_context_class->item_handler = ink_node_tool_item_handler; +// event_context_class->setup = ink_node_tool_setup; +// event_context_class->set = ink_node_tool_set; +// event_context_class->root_handler = ink_node_tool_root_handler; +// event_context_class->item_handler = ink_node_tool_item_handler; } CInkNodeTool::CInkNodeTool(InkNodeTool* inknodetool) : CEventContext(inknodetool) { this->inknodetool = inknodetool; } -static void -ink_node_tool_init(InkNodeTool *nt) -{ +InkNodeTool::InkNodeTool() : SPEventContext() { + InkNodeTool* nt = this; + nt->cinknodetool = new CInkNodeTool(nt); delete nt->ceventcontext; nt->ceventcontext = nt->cinknodetool; + nt->show_handles = 0; + nt->single_node_transform_handles = 0; + nt->show_transform_handles = 0; + nt->cursor_drag = 0; + nt->_node_message_context = 0; + nt->live_objects = 0; + nt->edit_clipping_paths = 0; + nt->live_outline = 0; + nt->flashed_item = 0; + nt->_transform_handle_group = 0; + nt->show_path_direction = 0; + nt->_last_over = 0; + nt->edit_masks = 0; + nt->show_outline = 0; + nt->flash_tempitem = 0; + SPEventContext *event_context = SP_EVENT_CONTEXT(nt); event_context->cursor_shape = cursor_node_xpm; @@ -169,6 +185,12 @@ ink_node_tool_init(InkNodeTool *nt) new (&nt->_shape_editors) ShapeEditors(); } +static void +ink_node_tool_init(InkNodeTool *nt) +{ + new (nt) InkNodeTool(); +} + //namespace { SPCanvasGroup *create_control_group(SPDesktop *d) diff --git a/src/ui/tool/node-tool.h b/src/ui/tool/node-tool.h index 7223b11b3..f997aee11 100644 --- a/src/ui/tool/node-tool.h +++ b/src/ui/tool/node-tool.h @@ -46,6 +46,7 @@ class CInkNodeTool; class InkNodeTool : public SPEventContext { public: + InkNodeTool(); CInkNodeTool* cinknodetool; sigc::connection _selection_changed_connection; -- cgit v1.2.3 From 8de8047c5e30af8598646d7a66c62dbf290f7c51 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Wed, 10 Apr 2013 16:10:04 +0200 Subject: Removed old SPObject factory. (bzr r11608.1.91) --- src/ui/dialog/document-properties.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index d335fb303..043100488 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -33,7 +33,6 @@ #include "io/sys.h" #include "preferences.h" #include "sp-namedview.h" -#include "sp-object-repr.h" #include "sp-root.h" #include "sp-script.h" #include "ui/widget/color-picker.h" -- cgit v1.2.3 From fbb85064cfaaf03cc09bacedb16a8561f61f2b3d Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 13 Apr 2013 00:37:18 +0200 Subject: Added prefPaths to contexts; modified SPFactory (bzr r11608.1.94) --- src/ui/tool/node-tool.cpp | 2 ++ src/ui/tool/node-tool.h | 2 ++ 2 files changed, 4 insertions(+) (limited to 'src/ui') diff --git a/src/ui/tool/node-tool.cpp b/src/ui/tool/node-tool.cpp index 8d8db772a..8887d4334 100644 --- a/src/ui/tool/node-tool.cpp +++ b/src/ui/tool/node-tool.cpp @@ -124,6 +124,8 @@ void handleControlUiStyleChange(InkNodeTool *nt); //} // anonymous namespace +const std::string InkNodeTool::prefsPath = "/tools/nodes"; + G_DEFINE_TYPE(InkNodeTool, ink_node_tool, SP_TYPE_EVENT_CONTEXT); static void diff --git a/src/ui/tool/node-tool.h b/src/ui/tool/node-tool.h index f997aee11..b5ce65513 100644 --- a/src/ui/tool/node-tool.h +++ b/src/ui/tool/node-tool.h @@ -74,6 +74,8 @@ public: unsigned single_node_transform_handles : 1; unsigned edit_clipping_paths : 1; unsigned edit_masks : 1; + + static const std::string prefsPath; }; struct InkNodeToolClass { -- cgit v1.2.3 From fbdc8b84ff670c684dafc7d7d403ed01e7077e70 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 13 Apr 2013 18:13:17 +0200 Subject: Replaced casting macros for EventContext tree; added contructors. (bzr r11608.1.96) --- src/ui/tool/node-tool.cpp | 16 ++++++++++++++++ src/ui/tool/node-tool.h | 7 +++++-- 2 files changed, 21 insertions(+), 2 deletions(-) (limited to 'src/ui') diff --git a/src/ui/tool/node-tool.cpp b/src/ui/tool/node-tool.cpp index 8887d4334..e30dde1ae 100644 --- a/src/ui/tool/node-tool.cpp +++ b/src/ui/tool/node-tool.cpp @@ -124,6 +124,21 @@ void handleControlUiStyleChange(InkNodeTool *nt); //} // anonymous namespace + +#include "sp-factory.h" + +namespace { + SPEventContext* createNodesContext() { + return new InkNodeTool(); + } + + bool nodesContextRegistered = ToolFactory::instance().registerObject("/tools/nodes", createNodesContext); +} + +const std::string& CInkNodeTool::getPrefsPath() { + return InkNodeTool::prefsPath; +} + const std::string InkNodeTool::prefsPath = "/tools/nodes"; G_DEFINE_TYPE(InkNodeTool, ink_node_tool, SP_TYPE_EVENT_CONTEXT); @@ -152,6 +167,7 @@ InkNodeTool::InkNodeTool() : SPEventContext() { nt->cinknodetool = new CInkNodeTool(nt); delete nt->ceventcontext; nt->ceventcontext = nt->cinknodetool; + types.insert(typeid(InkNodeTool)); nt->show_handles = 0; nt->single_node_transform_handles = 0; diff --git a/src/ui/tool/node-tool.h b/src/ui/tool/node-tool.h index b5ce65513..3de68d535 100644 --- a/src/ui/tool/node-tool.h +++ b/src/ui/tool/node-tool.h @@ -17,10 +17,12 @@ #include "event-context.h" #define INK_TYPE_NODE_TOOL (ink_node_tool_get_type ()) -#define INK_NODE_TOOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), INK_TYPE_NODE_TOOL, InkNodeTool)) +//#define INK_NODE_TOOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), INK_TYPE_NODE_TOOL, InkNodeTool)) #define INK_NODE_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), INK_TYPE_NODE_TOOL, InkNodeToolClass)) -#define INK_IS_NODE_TOOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), INK_TYPE_NODE_TOOL)) +//#define INK_IS_NODE_TOOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), INK_TYPE_NODE_TOOL)) #define INK_IS_NODE_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), INK_TYPE_NODE_TOOL)) +#define INK_NODE_TOOL(obj) ((InkNodeTool*)obj) +#define INK_IS_NODE_TOOL(obj) (((SPEventContext*)obj)->types.count(typeid(InkNodeTool))) namespace Inkscape { @@ -91,6 +93,7 @@ public: virtual gint root_handler(GdkEvent* event); virtual gint item_handler(SPItem* item, GdkEvent* event); + virtual const std::string& getPrefsPath(); private: InkNodeTool* inknodetool; }; -- cgit v1.2.3 From 1227ca0189590b281116fcc808bdd8c674b2196c Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 20 Apr 2013 21:16:13 +0200 Subject: Further changes to EventContexts; they work without GObject (bzr r11608.1.97) --- src/ui/tool/node-tool.cpp | 91 +++++++++++++++++++++++++++++------- src/ui/tool/node-tool.h | 16 +++++-- src/ui/tool/transform-handle-set.cpp | 3 +- 3 files changed, 88 insertions(+), 22 deletions(-) (limited to 'src/ui') diff --git a/src/ui/tool/node-tool.cpp b/src/ui/tool/node-tool.cpp index e30dde1ae..a3449d0ce 100644 --- a/src/ui/tool/node-tool.cpp +++ b/src/ui/tool/node-tool.cpp @@ -191,16 +191,22 @@ InkNodeTool::InkNodeTool() : SPEventContext() { event_context->hot_x = 1; event_context->hot_y = 1; - new (&nt->_selection_changed_connection) sigc::connection(); - new (&nt->_selection_modified_connection) sigc::connection(); - new (&nt->_mouseover_changed_connection) sigc::connection(); - new (&nt->_sizeUpdatedConn) sigc::connection(); - //new (&nt->_mgroup) Inkscape::UI::ManipulatorGroup(nt->desktop); - new (&nt->_selected_nodes) CSelPtr(); - new (&nt->_multipath) MultiPathPtr(); - new (&nt->_selector) SelectorPtr(); - new (&nt->_path_data) PathSharedDataPtr(); - new (&nt->_shape_editors) ShapeEditors(); +// new (&nt->_selection_changed_connection) sigc::connection(); +// new (&nt->_selection_modified_connection) sigc::connection(); +// new (&nt->_mouseover_changed_connection) sigc::connection(); +// new (&nt->_sizeUpdatedConn) sigc::connection(); +// //new (&nt->_mgroup) Inkscape::UI::ManipulatorGroup(nt->desktop); +// new (&nt->_selected_nodes) CSelPtr(); +// new (&nt->_multipath) MultiPathPtr(); +// new (&nt->_selector) SelectorPtr(); +// new (&nt->_path_data) PathSharedDataPtr(); +// new (&nt->_shape_editors) ShapeEditors(); + + nt->_selected_nodes = 0; + nt->_multipath = 0; + nt->_selector = 0; + nt->_path_data = 0; + //nt->_shape_editors = 0; } static void @@ -222,6 +228,50 @@ void destroy_group(SPCanvasGroup *g) sp_canvas_item_destroy(SP_CANVAS_ITEM(g)); } +InkNodeTool::~InkNodeTool() { + InkNodeTool *nt = INK_NODE_TOOL(this); + + nt->enableGrDrag(false); + + if (nt->flash_tempitem) { + nt->desktop->remove_temporary_canvasitem(nt->flash_tempitem); + } + + nt->_selection_changed_connection.disconnect(); + nt->_selection_modified_connection.disconnect(); + nt->_mouseover_changed_connection.disconnect(); + nt->_sizeUpdatedConn.disconnect(); + +// nt->_multipath.~MultiPathPtr(); +// nt->_selected_nodes.~CSelPtr(); +// nt->_selector.~SelectorPtr(); +// nt->_shape_editors.~ShapeEditors(); + + delete nt->_multipath; + delete nt->_selected_nodes; + delete nt->_selector; + + Inkscape::UI::PathSharedData &data = *nt->_path_data; + destroy_group(data.node_data.node_group); + destroy_group(data.node_data.handle_group); + destroy_group(data.node_data.handle_line_group); + destroy_group(data.outline_group); + destroy_group(data.dragpoint_group); + destroy_group(nt->_transform_handle_group); + +// nt->_path_data.~PathSharedDataPtr(); +// nt->_selection_changed_connection.~connection(); +// nt->_selection_modified_connection.~connection(); +// nt->_mouseover_changed_connection.~connection(); +// nt->_sizeUpdatedConn.~connection(); + + if (nt->_node_message_context) { + delete nt->_node_message_context; + } + + //G_OBJECT_CLASS(ink_node_tool_parent_class)->dispose(object); +} + void ink_node_tool_dispose(GObject *object) { InkNodeTool *nt = INK_NODE_TOOL(object); @@ -278,12 +328,14 @@ void CInkNodeTool::setup() { nt->_node_message_context = new Inkscape::MessageContext((ec->desktop)->messageStack()); - nt->_path_data.reset(new Inkscape::UI::PathSharedData()); + //nt->_path_data.reset(new Inkscape::UI::PathSharedData()); + nt->_path_data = new Inkscape::UI::PathSharedData(); Inkscape::UI::PathSharedData &data = *nt->_path_data; data.node_data.desktop = nt->desktop; // selector has to be created here, so that its hidden control point is on the bottom - nt->_selector.reset(new Inkscape::UI::Selector(nt->desktop)); + //nt->_selector.reset(new Inkscape::UI::Selector(nt->desktop)); + nt->_selector = new Inkscape::UI::Selector(nt->desktop); // Prepare canvas groups for controls. This guarantees correct z-order, so that // for example a dragpoint won't obscure a node @@ -316,11 +368,16 @@ void CInkNodeTool::setup() { nt->_sizeUpdatedConn = ControlManager::getManager().connectCtrlSizeChanged(sigc::bind(sigc::ptr_fun(&handleControlUiStyleChange), nt)); - nt->_selected_nodes.reset( - new Inkscape::UI::ControlPointSelection(nt->desktop, nt->_transform_handle_group)); - data.node_data.selection = nt->_selected_nodes.get(); - nt->_multipath.reset(new Inkscape::UI::MultiPathManipulator(data, - nt->_selection_changed_connection)); +// nt->_selected_nodes.reset( +// new Inkscape::UI::ControlPointSelection(nt->desktop, nt->_transform_handle_group)); + nt->_selected_nodes = new Inkscape::UI::ControlPointSelection(nt->desktop, nt->_transform_handle_group); + + //data.node_data.selection = nt->_selected_nodes.get(); + data.node_data.selection = nt->_selected_nodes; + + //nt->_multipath.reset(new Inkscape::UI::MultiPathManipulator(data, + // nt->_selection_changed_connection)); + nt->_multipath = new Inkscape::UI::MultiPathManipulator(data, nt->_selection_changed_connection); nt->_selector->signal_point.connect( sigc::bind<0>( diff --git a/src/ui/tool/node-tool.h b/src/ui/tool/node-tool.h index 3de68d535..43c1f3cdf 100644 --- a/src/ui/tool/node-tool.h +++ b/src/ui/tool/node-tool.h @@ -37,10 +37,17 @@ struct PathSharedData; } // namespace UI } // namespace Inkscape -typedef std::auto_ptr MultiPathPtr; -typedef std::auto_ptr CSelPtr; -typedef std::auto_ptr SelectorPtr; -typedef std::auto_ptr PathSharedDataPtr; +//typedef std::auto_ptr MultiPathPtr; +//typedef std::auto_ptr CSelPtr; +//typedef std::auto_ptr SelectorPtr; +//typedef std::auto_ptr PathSharedDataPtr; + + +typedef Inkscape::UI::MultiPathManipulator* MultiPathPtr; +typedef Inkscape::UI::ControlPointSelection* CSelPtr; +typedef Inkscape::UI::Selector* SelectorPtr; +typedef Inkscape::UI::PathSharedData* PathSharedDataPtr; + typedef boost::ptr_map ShapeEditors; class CInkNodeTool; @@ -49,6 +56,7 @@ class InkNodeTool : public SPEventContext { public: InkNodeTool(); + virtual ~InkNodeTool(); CInkNodeTool* cinknodetool; sigc::connection _selection_changed_connection; diff --git a/src/ui/tool/transform-handle-set.cpp b/src/ui/tool/transform-handle-set.cpp index f0bf149f4..479a29d1f 100644 --- a/src/ui/tool/transform-handle-set.cpp +++ b/src/ui/tool/transform-handle-set.cpp @@ -129,7 +129,8 @@ bool TransformHandle::grabbed(GdkEventMotion *) // Collect the snap-candidates, one for each selected node. These will be stored in the _snap_points vector. InkNodeTool *nt = INK_NODE_TOOL(_th._desktop->event_context); - ControlPointSelection *selection = nt->_selected_nodes.get(); + //ControlPointSelection *selection = nt->_selected_nodes.get(); + ControlPointSelection* selection = nt->_selected_nodes; selection->setOriginalPoints(); selection->getOriginalPoints(_snap_points); -- cgit v1.2.3 From 65ba6ad9a82f8f47974eb10665478fd783692bb5 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 20 Apr 2013 23:19:46 +0200 Subject: Merging of EventContext classes complete. (bzr r11608.1.98) --- src/ui/tool/node-tool.cpp | 121 ++++------------------------------- src/ui/tool/node-tool.h | 27 +------- src/ui/tool/transform-handle-set.cpp | 10 +-- 3 files changed, 20 insertions(+), 138 deletions(-) (limited to 'src/ui') diff --git a/src/ui/tool/node-tool.cpp b/src/ui/tool/node-tool.cpp index a3449d0ce..e72b7c5ba 100644 --- a/src/ui/tool/node-tool.cpp +++ b/src/ui/tool/node-tool.cpp @@ -107,12 +107,6 @@ using Inkscape::ControlManager; //namespace { SPCanvasGroup *create_control_group(SPDesktop *d); -void ink_node_tool_dispose(GObject *object); - -void ink_node_tool_setup(SPEventContext *ec); -gint ink_node_tool_root_handler(SPEventContext *event_context, GdkEvent *event); -gint ink_node_tool_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event); -void ink_node_tool_set(SPEventContext *ec, Inkscape::Preferences::Entry *value); void ink_node_tool_update_tip(InkNodeTool *nt, GdkEvent *event); void ink_node_tool_selection_changed(InkNodeTool *nt, Inkscape::Selection *sel); @@ -135,40 +129,15 @@ namespace { bool nodesContextRegistered = ToolFactory::instance().registerObject("/tools/nodes", createNodesContext); } -const std::string& CInkNodeTool::getPrefsPath() { +const std::string& InkNodeTool::getPrefsPath() { return InkNodeTool::prefsPath; } const std::string InkNodeTool::prefsPath = "/tools/nodes"; -G_DEFINE_TYPE(InkNodeTool, ink_node_tool, SP_TYPE_EVENT_CONTEXT); - -static void -ink_node_tool_class_init(InkNodeToolClass *klass) -{ - GObjectClass *object_class = (GObjectClass *) klass; - SPEventContextClass *event_context_class = (SPEventContextClass *) klass; - - object_class->dispose = ink_node_tool_dispose; - -// event_context_class->setup = ink_node_tool_setup; -// event_context_class->set = ink_node_tool_set; -// event_context_class->root_handler = ink_node_tool_root_handler; -// event_context_class->item_handler = ink_node_tool_item_handler; -} - -CInkNodeTool::CInkNodeTool(InkNodeTool* inknodetool) : CEventContext(inknodetool) { - this->inknodetool = inknodetool; -} - InkNodeTool::InkNodeTool() : SPEventContext() { InkNodeTool* nt = this; - nt->cinknodetool = new CInkNodeTool(nt); - delete nt->ceventcontext; - nt->ceventcontext = nt->cinknodetool; - types.insert(typeid(InkNodeTool)); - nt->show_handles = 0; nt->single_node_transform_handles = 0; nt->show_transform_handles = 0; @@ -209,12 +178,6 @@ InkNodeTool::InkNodeTool() : SPEventContext() { //nt->_shape_editors = 0; } -static void -ink_node_tool_init(InkNodeTool *nt) -{ - new (nt) InkNodeTool(); -} - //namespace { SPCanvasGroup *create_control_group(SPDesktop *d) @@ -272,59 +235,14 @@ InkNodeTool::~InkNodeTool() { //G_OBJECT_CLASS(ink_node_tool_parent_class)->dispose(object); } -void ink_node_tool_dispose(GObject *object) -{ - InkNodeTool *nt = INK_NODE_TOOL(object); - - nt->enableGrDrag(false); - - if (nt->flash_tempitem) { - nt->desktop->remove_temporary_canvasitem(nt->flash_tempitem); - } - - nt->_selection_changed_connection.disconnect(); - nt->_selection_modified_connection.disconnect(); - nt->_mouseover_changed_connection.disconnect(); - nt->_sizeUpdatedConn.disconnect(); - nt->_multipath.~MultiPathPtr(); - nt->_selected_nodes.~CSelPtr(); - nt->_selector.~SelectorPtr(); - nt->_shape_editors.~ShapeEditors(); - - Inkscape::UI::PathSharedData &data = *nt->_path_data; - destroy_group(data.node_data.node_group); - destroy_group(data.node_data.handle_group); - destroy_group(data.node_data.handle_line_group); - destroy_group(data.outline_group); - destroy_group(data.dragpoint_group); - destroy_group(nt->_transform_handle_group); - - nt->_path_data.~PathSharedDataPtr(); - nt->_selection_changed_connection.~connection(); - nt->_selection_modified_connection.~connection(); - nt->_mouseover_changed_connection.~connection(); - nt->_sizeUpdatedConn.~connection(); - - if (nt->_node_message_context) { - delete nt->_node_message_context; - } - - G_OBJECT_CLASS(ink_node_tool_parent_class)->dispose(object); -} - -void ink_node_tool_setup(SPEventContext *ec) -{ - ec->ceventcontext->setup(); -} - -void CInkNodeTool::setup() { - SPEventContext* ec = this->speventcontext; +void InkNodeTool::setup() { + SPEventContext* ec = this; InkNodeTool *nt = INK_NODE_TOOL(ec); // if (SP_EVENT_CONTEXT_CLASS(ink_node_tool_parent_class)->setup) // SP_EVENT_CONTEXT_CLASS(ink_node_tool_parent_class)->setup(ec); - CEventContext::setup(); + SPEventContext::setup(); nt->_node_message_context = new Inkscape::MessageContext((ec->desktop)->messageStack()); @@ -432,13 +350,8 @@ void CInkNodeTool::setup() { nt->desktop->emitToolSubselectionChanged(NULL); // sets the coord entry fields to inactive } -void ink_node_tool_set(SPEventContext *ec, Inkscape::Preferences::Entry *value) -{ - ec->ceventcontext->set(value); -} - -void CInkNodeTool::set(Inkscape::Preferences::Entry* value) { - SPEventContext* ec = this->speventcontext; +void InkNodeTool::set(Inkscape::Preferences::Entry* value) { + SPEventContext* ec = this; InkNodeTool *nt = INK_NODE_TOOL(ec); Glib::ustring entry_name = value->getEntryName(); @@ -475,7 +388,7 @@ void CInkNodeTool::set(Inkscape::Preferences::Entry* value) { } else { // if (SP_EVENT_CONTEXT_CLASS(ink_node_tool_parent_class)->set) // SP_EVENT_CONTEXT_CLASS(ink_node_tool_parent_class)->set(ec, value); - CEventContext::set(value); + SPEventContext::set(value); } } @@ -561,13 +474,8 @@ void ink_node_tool_selection_changed(InkNodeTool *nt, Inkscape::Selection *sel) nt->desktop->updateNow(); } -gint ink_node_tool_root_handler(SPEventContext *event_context, GdkEvent *event) -{ - return event_context->ceventcontext->root_handler(event); -} - -gint CInkNodeTool::root_handler(GdkEvent* event) { - SPEventContext* event_context = this->speventcontext; +gint InkNodeTool::root_handler(GdkEvent* event) { + SPEventContext* event_context = this; /* things to handle here: * 1. selection of items @@ -664,7 +572,7 @@ gint CInkNodeTool::root_handler(GdkEvent* event) { // if (SP_EVENT_CONTEXT_CLASS(ink_node_tool_parent_class)->root_handler) // return SP_EVENT_CONTEXT_CLASS(ink_node_tool_parent_class)->root_handler(event_context, event); - CEventContext::root_handler(event); + SPEventContext::root_handler(event); return FALSE; } @@ -727,17 +635,12 @@ void ink_node_tool_update_tip(InkNodeTool *nt, GdkEvent *event) } } -gint ink_node_tool_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event) -{ - return event_context->ceventcontext->item_handler(item, event); -} - -gint CInkNodeTool::item_handler(SPItem* item, GdkEvent* event) { +gint InkNodeTool::item_handler(SPItem* item, GdkEvent* event) { // if (SP_EVENT_CONTEXT_CLASS(ink_node_tool_parent_class)->item_handler) // return SP_EVENT_CONTEXT_CLASS(ink_node_tool_parent_class)->item_handler(event_context, item, event); - CEventContext::item_handler(item, event); + SPEventContext::item_handler(item, event); return FALSE; } diff --git a/src/ui/tool/node-tool.h b/src/ui/tool/node-tool.h index 43c1f3cdf..fb2b41663 100644 --- a/src/ui/tool/node-tool.h +++ b/src/ui/tool/node-tool.h @@ -16,13 +16,8 @@ #include #include "event-context.h" -#define INK_TYPE_NODE_TOOL (ink_node_tool_get_type ()) -//#define INK_NODE_TOOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), INK_TYPE_NODE_TOOL, InkNodeTool)) -#define INK_NODE_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), INK_TYPE_NODE_TOOL, InkNodeToolClass)) -//#define INK_IS_NODE_TOOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), INK_TYPE_NODE_TOOL)) -#define INK_IS_NODE_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), INK_TYPE_NODE_TOOL)) #define INK_NODE_TOOL(obj) ((InkNodeTool*)obj) -#define INK_IS_NODE_TOOL(obj) (((SPEventContext*)obj)->types.count(typeid(InkNodeTool))) +#define INK_IS_NODE_TOOL(obj) (dynamic_cast((const SPEventContext*)obj)) namespace Inkscape { @@ -50,16 +45,13 @@ typedef Inkscape::UI::PathSharedData* PathSharedDataPtr; typedef boost::ptr_map ShapeEditors; -class CInkNodeTool; -class InkNodeTool : public SPEventContext -{ +class InkNodeTool : public SPEventContext { public: InkNodeTool(); virtual ~InkNodeTool(); - CInkNodeTool* cinknodetool; - sigc::connection _selection_changed_connection; + sigc::connection _selection_changed_connection; sigc::connection _mouseover_changed_connection; sigc::connection _selection_modified_connection; sigc::connection _sizeUpdatedConn; @@ -86,15 +78,6 @@ public: unsigned edit_masks : 1; static const std::string prefsPath; -}; - -struct InkNodeToolClass { - SPEventContextClass parent_class; -}; - -class CInkNodeTool : public CEventContext { -public: - CInkNodeTool(InkNodeTool* inknodetool); virtual void setup(); virtual void set(Inkscape::Preferences::Entry* val); @@ -102,12 +85,8 @@ public: virtual gint item_handler(SPItem* item, GdkEvent* event); virtual const std::string& getPrefsPath(); -private: - InkNodeTool* inknodetool; }; -GType ink_node_tool_get_type (void); - #endif /* diff --git a/src/ui/tool/transform-handle-set.cpp b/src/ui/tool/transform-handle-set.cpp index 479a29d1f..348420994 100644 --- a/src/ui/tool/transform-handle-set.cpp +++ b/src/ui/tool/transform-handle-set.cpp @@ -294,7 +294,7 @@ protected: private: static Glib::RefPtr _corner_to_pixbuf(unsigned c) { - sp_select_context_get_type(); + //sp_select_context_get_type(); switch (c % 2) { case 0: return Glib::wrap(handles[1], true); @@ -377,7 +377,7 @@ protected: } private: static Glib::RefPtr _side_to_pixbuf(unsigned c) { - sp_select_context_get_type(); + //sp_select_context_get_type(); switch (c % 2) { case 0: return Glib::wrap(handles[3], true); default: return Glib::wrap(handles[2], true); @@ -457,7 +457,7 @@ protected: private: static Glib::RefPtr _corner_to_pixbuf(unsigned c) { - sp_select_context_get_type(); + //sp_select_context_get_type(); switch (c % 4) { case 0: return Glib::wrap(handles[10], true); case 1: return Glib::wrap(handles[8], true); @@ -604,7 +604,7 @@ protected: private: static Glib::RefPtr _side_to_pixbuf(unsigned s) { - sp_select_context_get_type(); + //sp_select_context_get_type(); switch (s % 4) { case 0: return Glib::wrap(handles[9], true); case 1: return Glib::wrap(handles[7], true); @@ -659,7 +659,7 @@ protected: private: static Glib::RefPtr _get_pixbuf() { - sp_select_context_get_type(); + //sp_select_context_get_type(); return Glib::wrap(handles[12], true); } -- cgit v1.2.3 From 5512f857e2f33f1aa40124dc82b353e5f2e5a0b0 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 20 Apr 2013 23:58:53 +0200 Subject: Moved factories to different files. (bzr r11608.1.100) --- src/ui/tool/node-tool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/tool/node-tool.cpp b/src/ui/tool/node-tool.cpp index e72b7c5ba..f994080b0 100644 --- a/src/ui/tool/node-tool.cpp +++ b/src/ui/tool/node-tool.cpp @@ -119,7 +119,7 @@ void handleControlUiStyleChange(InkNodeTool *nt); //} // anonymous namespace -#include "sp-factory.h" +#include "tool-factory.h" namespace { SPEventContext* createNodesContext() { -- cgit v1.2.3 From 389b871cdea29ace85567863c439eb0537a36f54 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sun, 21 Apr 2013 20:45:27 +0200 Subject: Cleaned up a bit. (bzr r11608.1.102) --- src/ui/clipboard.cpp | 3 +- src/ui/tool/node-tool.cpp | 582 ++++++++++++++++++++++------------------------ src/ui/tool/node-tool.h | 77 +++--- 3 files changed, 322 insertions(+), 340 deletions(-) (limited to 'src/ui') diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 0fbc09df8..822f55a93 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -238,7 +238,8 @@ void ClipboardManagerImpl::copy(SPDesktop *desktop) // Special case for when the color picker ("dropper") is active - copies color under cursor if (tools_isactive(desktop, TOOLS_DROPPER)) { - _setClipboardColor(sp_dropper_context_get_color(desktop->event_context)); + //_setClipboardColor(sp_dropper_context_get_color(desktop->event_context)); + _setClipboardColor(SP_DROPPER_CONTEXT(desktop->event_context)->get_color()); _discardInternalClipboard(); return; } diff --git a/src/ui/tool/node-tool.cpp b/src/ui/tool/node-tool.cpp index f994080b0..f64aa4d2a 100644 --- a/src/ui/tool/node-tool.cpp +++ b/src/ui/tool/node-tool.cpp @@ -104,21 +104,8 @@ using Inkscape::ControlManager; -//namespace { - SPCanvasGroup *create_control_group(SPDesktop *d); -void ink_node_tool_update_tip(InkNodeTool *nt, GdkEvent *event); -void ink_node_tool_selection_changed(InkNodeTool *nt, Inkscape::Selection *sel); -void ink_node_tool_select_area(InkNodeTool *nt, Geom::Rect const &, GdkEventButton *); -void ink_node_tool_select_point(InkNodeTool *nt, Geom::Point const &, GdkEventButton *); -void ink_node_tool_mouseover_changed(InkNodeTool *nt, Inkscape::UI::ControlPoint *p); - -void handleControlUiStyleChange(InkNodeTool *nt); - -//} // anonymous namespace - - #include "tool-factory.h" namespace { @@ -136,50 +123,32 @@ const std::string& InkNodeTool::getPrefsPath() { const std::string InkNodeTool::prefsPath = "/tools/nodes"; InkNodeTool::InkNodeTool() : SPEventContext() { - InkNodeTool* nt = this; - - nt->show_handles = 0; - nt->single_node_transform_handles = 0; - nt->show_transform_handles = 0; - nt->cursor_drag = 0; - nt->_node_message_context = 0; - nt->live_objects = 0; - nt->edit_clipping_paths = 0; - nt->live_outline = 0; - nt->flashed_item = 0; - nt->_transform_handle_group = 0; - nt->show_path_direction = 0; - nt->_last_over = 0; - nt->edit_masks = 0; - nt->show_outline = 0; - nt->flash_tempitem = 0; - - SPEventContext *event_context = SP_EVENT_CONTEXT(nt); - - event_context->cursor_shape = cursor_node_xpm; - event_context->hot_x = 1; - event_context->hot_y = 1; - -// new (&nt->_selection_changed_connection) sigc::connection(); -// new (&nt->_selection_modified_connection) sigc::connection(); -// new (&nt->_mouseover_changed_connection) sigc::connection(); -// new (&nt->_sizeUpdatedConn) sigc::connection(); -// //new (&nt->_mgroup) Inkscape::UI::ManipulatorGroup(nt->desktop); -// new (&nt->_selected_nodes) CSelPtr(); -// new (&nt->_multipath) MultiPathPtr(); -// new (&nt->_selector) SelectorPtr(); -// new (&nt->_path_data) PathSharedDataPtr(); -// new (&nt->_shape_editors) ShapeEditors(); - - nt->_selected_nodes = 0; - nt->_multipath = 0; - nt->_selector = 0; - nt->_path_data = 0; - //nt->_shape_editors = 0; + this->show_handles = false; + this->single_node_transform_handles = false; + this->show_transform_handles = false; + this->cursor_drag = false; + this->_node_message_context = 0; + this->live_objects = false; + this->edit_clipping_paths = false; + this->live_outline = false; + this->flashed_item = 0; + this->_transform_handle_group = 0; + this->show_path_direction = false; + this->_last_over = 0; + this->edit_masks = false; + this->show_outline = false; + this->flash_tempitem = 0; + + this->cursor_shape = cursor_node_xpm; + this->hot_x = 1; + this->hot_y = 1; + + this->_selected_nodes = 0; + this->_multipath = 0; + this->_selector = 0; + this->_path_data = 0; } -//namespace { - SPCanvasGroup *create_control_group(SPDesktop *d) { return reinterpret_cast(sp_canvas_item_new( @@ -192,202 +161,163 @@ void destroy_group(SPCanvasGroup *g) } InkNodeTool::~InkNodeTool() { - InkNodeTool *nt = INK_NODE_TOOL(this); - - nt->enableGrDrag(false); + this->enableGrDrag(false); - if (nt->flash_tempitem) { - nt->desktop->remove_temporary_canvasitem(nt->flash_tempitem); + if (this->flash_tempitem) { + this->desktop->remove_temporary_canvasitem(this->flash_tempitem); } - nt->_selection_changed_connection.disconnect(); - nt->_selection_modified_connection.disconnect(); - nt->_mouseover_changed_connection.disconnect(); - nt->_sizeUpdatedConn.disconnect(); + this->_selection_changed_connection.disconnect(); + //this->_selection_modified_connection.disconnect(); + this->_mouseover_changed_connection.disconnect(); + this->_sizeUpdatedConn.disconnect(); -// nt->_multipath.~MultiPathPtr(); -// nt->_selected_nodes.~CSelPtr(); -// nt->_selector.~SelectorPtr(); -// nt->_shape_editors.~ShapeEditors(); + delete this->_multipath; + delete this->_selected_nodes; + delete this->_selector; - delete nt->_multipath; - delete nt->_selected_nodes; - delete nt->_selector; - - Inkscape::UI::PathSharedData &data = *nt->_path_data; + Inkscape::UI::PathSharedData &data = *this->_path_data; destroy_group(data.node_data.node_group); destroy_group(data.node_data.handle_group); destroy_group(data.node_data.handle_line_group); destroy_group(data.outline_group); destroy_group(data.dragpoint_group); - destroy_group(nt->_transform_handle_group); - -// nt->_path_data.~PathSharedDataPtr(); -// nt->_selection_changed_connection.~connection(); -// nt->_selection_modified_connection.~connection(); -// nt->_mouseover_changed_connection.~connection(); -// nt->_sizeUpdatedConn.~connection(); + destroy_group(this->_transform_handle_group); - if (nt->_node_message_context) { - delete nt->_node_message_context; + if (this->_node_message_context) { + delete this->_node_message_context; } - - //G_OBJECT_CLASS(ink_node_tool_parent_class)->dispose(object); } void InkNodeTool::setup() { - SPEventContext* ec = this; - - InkNodeTool *nt = INK_NODE_TOOL(ec); - -// if (SP_EVENT_CONTEXT_CLASS(ink_node_tool_parent_class)->setup) -// SP_EVENT_CONTEXT_CLASS(ink_node_tool_parent_class)->setup(ec); SPEventContext::setup(); - nt->_node_message_context = new Inkscape::MessageContext((ec->desktop)->messageStack()); + this->_node_message_context = new Inkscape::MessageContext((this->desktop)->messageStack()); + this->_path_data = new Inkscape::UI::PathSharedData(); - //nt->_path_data.reset(new Inkscape::UI::PathSharedData()); - nt->_path_data = new Inkscape::UI::PathSharedData(); - Inkscape::UI::PathSharedData &data = *nt->_path_data; - data.node_data.desktop = nt->desktop; + Inkscape::UI::PathSharedData &data = *this->_path_data; + data.node_data.desktop = this->desktop; // selector has to be created here, so that its hidden control point is on the bottom - //nt->_selector.reset(new Inkscape::UI::Selector(nt->desktop)); - nt->_selector = new Inkscape::UI::Selector(nt->desktop); + this->_selector = new Inkscape::UI::Selector(this->desktop); // Prepare canvas groups for controls. This guarantees correct z-order, so that // for example a dragpoint won't obscure a node - data.outline_group = create_control_group(nt->desktop); - data.node_data.handle_line_group = create_control_group(nt->desktop); - data.dragpoint_group = create_control_group(nt->desktop); - nt->_transform_handle_group = create_control_group(nt->desktop); - data.node_data.node_group = create_control_group(nt->desktop); - data.node_data.handle_group = create_control_group(nt->desktop); - - Inkscape::Selection *selection = sp_desktop_selection (ec->desktop); - nt->_selection_changed_connection.disconnect(); - nt->_selection_changed_connection = - selection->connectChanged( - sigc::bind<0>( - sigc::ptr_fun(&ink_node_tool_selection_changed), - nt)); - /*nt->_selection_modified_connection.disconnect(); - nt->_selection_modified_connection = - selection->connectModified( - sigc::hide(sigc::bind<0>( - sigc::ptr_fun(&ink_node_tool_selection_modified), - nt)));*/ - nt->_mouseover_changed_connection.disconnect(); - nt->_mouseover_changed_connection = - Inkscape::UI::ControlPoint::signal_mouseover_change.connect( - sigc::bind<0>( - sigc::ptr_fun(&ink_node_tool_mouseover_changed), - nt)); - - nt->_sizeUpdatedConn = ControlManager::getManager().connectCtrlSizeChanged(sigc::bind(sigc::ptr_fun(&handleControlUiStyleChange), nt)); + data.outline_group = create_control_group(this->desktop); + data.node_data.handle_line_group = create_control_group(this->desktop); + data.dragpoint_group = create_control_group(this->desktop); + this->_transform_handle_group = create_control_group(this->desktop); + data.node_data.node_group = create_control_group(this->desktop); + data.node_data.handle_group = create_control_group(this->desktop); + + Inkscape::Selection *selection = sp_desktop_selection (this->desktop); + + this->_selection_changed_connection.disconnect(); + this->_selection_changed_connection = + selection->connectChanged(sigc::mem_fun(this, &InkNodeTool::selection_changed)); + + this->_mouseover_changed_connection.disconnect(); + this->_mouseover_changed_connection = + Inkscape::UI::ControlPoint::signal_mouseover_change.connect(sigc::mem_fun(this, &InkNodeTool::mouseover_changed)); + + this->_sizeUpdatedConn = ControlManager::getManager().connectCtrlSizeChanged( + sigc::mem_fun(this, &InkNodeTool::handleControlUiStyleChange) + ); -// nt->_selected_nodes.reset( -// new Inkscape::UI::ControlPointSelection(nt->desktop, nt->_transform_handle_group)); - nt->_selected_nodes = new Inkscape::UI::ControlPointSelection(nt->desktop, nt->_transform_handle_group); - - //data.node_data.selection = nt->_selected_nodes.get(); - data.node_data.selection = nt->_selected_nodes; - - //nt->_multipath.reset(new Inkscape::UI::MultiPathManipulator(data, - // nt->_selection_changed_connection)); - nt->_multipath = new Inkscape::UI::MultiPathManipulator(data, nt->_selection_changed_connection); - - nt->_selector->signal_point.connect( - sigc::bind<0>( - sigc::ptr_fun(&ink_node_tool_select_point), - nt)); - nt->_selector->signal_area.connect( - sigc::bind<0>( - sigc::ptr_fun(&ink_node_tool_select_area), - nt)); - - nt->_multipath->signal_coords_changed.connect( + this->_selected_nodes = new Inkscape::UI::ControlPointSelection(this->desktop, this->_transform_handle_group); + + data.node_data.selection = this->_selected_nodes; + + this->_multipath = new Inkscape::UI::MultiPathManipulator(data, this->_selection_changed_connection); + + this->_selector->signal_point.connect(sigc::mem_fun(this, &InkNodeTool::select_point)); + this->_selector->signal_area.connect(sigc::mem_fun(this, &InkNodeTool::select_area)); + + this->_multipath->signal_coords_changed.connect( sigc::bind( - sigc::mem_fun(*nt->desktop, &SPDesktop::emitToolSubselectionChanged), - (void*) 0)); - nt->_selected_nodes->signal_point_changed.connect( - sigc::hide( sigc::hide( - sigc::bind( - sigc::bind( - sigc::ptr_fun(ink_node_tool_update_tip), - (GdkEvent*)0), - nt)))); - - nt->cursor_drag = false; - nt->show_transform_handles = true; - nt->single_node_transform_handles = false; - nt->flash_tempitem = NULL; - nt->flashed_item = NULL; - nt->_last_over = NULL; + sigc::mem_fun(*this->desktop, &SPDesktop::emitToolSubselectionChanged), + (void*)NULL + ) + ); + + this->_selected_nodes->signal_point_changed.connect( + // Hide both signal parameters and bind the function parameter to 0 + // sigc::signal + // <=> + // void update_tip(GdkEvent *event) + sigc::hide(sigc::hide(sigc::bind( + sigc::mem_fun(this, &InkNodeTool::update_tip), + (GdkEvent*)NULL + ))) + ); + + this->cursor_drag = false; + this->show_transform_handles = true; + this->single_node_transform_handles = false; + this->flash_tempitem = NULL; + this->flashed_item = NULL; + this->_last_over = NULL; // read prefs before adding items to selection to prevent momentarily showing the outline - sp_event_context_read(nt, "show_handles"); - sp_event_context_read(nt, "show_outline"); - sp_event_context_read(nt, "live_outline"); - sp_event_context_read(nt, "live_objects"); - sp_event_context_read(nt, "show_path_direction"); - sp_event_context_read(nt, "show_transform_handles"); - sp_event_context_read(nt, "single_node_transform_handles"); - sp_event_context_read(nt, "edit_clipping_paths"); - sp_event_context_read(nt, "edit_masks"); - - ink_node_tool_selection_changed(nt, selection); - ink_node_tool_update_tip(nt, NULL); + sp_event_context_read(this, "show_handles"); + sp_event_context_read(this, "show_outline"); + sp_event_context_read(this, "live_outline"); + sp_event_context_read(this, "live_objects"); + sp_event_context_read(this, "show_path_direction"); + sp_event_context_read(this, "show_transform_handles"); + sp_event_context_read(this, "single_node_transform_handles"); + sp_event_context_read(this, "edit_clipping_paths"); + sp_event_context_read(this, "edit_masks"); + + this->selection_changed(selection); + this->update_tip(NULL); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + if (prefs->getBool("/tools/nodes/selcue")) { - ec->enableSelectionCue(); + this->enableSelectionCue(); } + if (prefs->getBool("/tools/nodes/gradientdrag")) { - ec->enableGrDrag(); + this->enableGrDrag(); } - nt->desktop->emitToolSubselectionChanged(NULL); // sets the coord entry fields to inactive + this->desktop->emitToolSubselectionChanged(NULL); // sets the coord entry fields to inactive } void InkNodeTool::set(Inkscape::Preferences::Entry* value) { - SPEventContext* ec = this; - - InkNodeTool *nt = INK_NODE_TOOL(ec); Glib::ustring entry_name = value->getEntryName(); if (entry_name == "show_handles") { - nt->show_handles = value->getBool(true); - nt->_multipath->showHandles(nt->show_handles); + this->show_handles = value->getBool(true); + this->_multipath->showHandles(this->show_handles); } else if (entry_name == "show_outline") { - nt->show_outline = value->getBool(); - nt->_multipath->showOutline(nt->show_outline); + this->show_outline = value->getBool(); + this->_multipath->showOutline(this->show_outline); } else if (entry_name == "live_outline") { - nt->live_outline = value->getBool(); - nt->_multipath->setLiveOutline(nt->live_outline); + this->live_outline = value->getBool(); + this->_multipath->setLiveOutline(this->live_outline); } else if (entry_name == "live_objects") { - nt->live_objects = value->getBool(); - nt->_multipath->setLiveObjects(nt->live_objects); + this->live_objects = value->getBool(); + this->_multipath->setLiveObjects(this->live_objects); } else if (entry_name == "show_path_direction") { - nt->show_path_direction = value->getBool(); - nt->_multipath->showPathDirection(nt->show_path_direction); + this->show_path_direction = value->getBool(); + this->_multipath->showPathDirection(this->show_path_direction); } else if (entry_name == "show_transform_handles") { - nt->show_transform_handles = value->getBool(true); - nt->_selected_nodes->showTransformHandles( - nt->show_transform_handles, nt->single_node_transform_handles); + this->show_transform_handles = value->getBool(true); + this->_selected_nodes->showTransformHandles( + this->show_transform_handles, this->single_node_transform_handles); } else if (entry_name == "single_node_transform_handles") { - nt->single_node_transform_handles = value->getBool(); - nt->_selected_nodes->showTransformHandles( - nt->show_transform_handles, nt->single_node_transform_handles); + this->single_node_transform_handles = value->getBool(); + this->_selected_nodes->showTransformHandles( + this->show_transform_handles, this->single_node_transform_handles); } else if (entry_name == "edit_clipping_paths") { - nt->edit_clipping_paths = value->getBool(); - ink_node_tool_selection_changed(nt, nt->desktop->selection); + this->edit_clipping_paths = value->getBool(); + this->selection_changed(this->desktop->selection); } else if (entry_name == "edit_masks") { - nt->edit_masks = value->getBool(); - ink_node_tool_selection_changed(nt, nt->desktop->selection); + this->edit_masks = value->getBool(); + this->selection_changed(this->desktop->selection); } else { -// if (SP_EVENT_CONTEXT_CLASS(ink_node_tool_parent_class)->set) -// SP_EVENT_CONTEXT_CLASS(ink_node_tool_parent_class)->set(ec, value); SPEventContext::set(value); } } @@ -397,7 +327,10 @@ void gather_items(InkNodeTool *nt, SPItem *base, SPObject *obj, Inkscape::UI::Sh std::set &s) { using namespace Inkscape::UI; - if (!obj) return; + + if (!obj) { + return; + } //XML Tree being used directly here while it shouldn't be. if (SP_IS_PATH(obj) && obj->getRepr()->attribute("inkscape:original-d") != NULL) { @@ -417,11 +350,13 @@ void gather_items(InkNodeTool *nt, SPItem *base, SPObject *obj, Inkscape::UI::Sh // TODO add support for objectBoundingBox r.edit_transform = base ? base->i2doc_affine() : Geom::identity(); r.role = role; + if (s.insert(r).second) { // this item was encountered the first time if (nt->edit_clipping_paths && item->clip_ref) { gather_items(nt, item, item->clip_ref->getObject(), SHAPE_ROLE_CLIPPING_PATH, s); } + if (nt->edit_masks && item->mask_ref) { gather_items(nt, item, item->mask_ref->getObject(), SHAPE_ROLE_MASK, s); } @@ -429,8 +364,7 @@ void gather_items(InkNodeTool *nt, SPItem *base, SPObject *obj, Inkscape::UI::Sh } } -void ink_node_tool_selection_changed(InkNodeTool *nt, Inkscape::Selection *sel) -{ +void InkNodeTool::selection_changed(Inkscape::Selection *sel) { using namespace Inkscape::UI; std::set shapes; @@ -439,20 +373,22 @@ void ink_node_tool_selection_changed(InkNodeTool *nt, Inkscape::Selection *sel) for (GSList *i = const_cast(ilist); i; i = i->next) { SPObject *obj = static_cast(i->data); + if (SP_IS_ITEM(obj)) { - gather_items(nt, NULL, static_cast(obj), SHAPE_ROLE_NORMAL, shapes); + gather_items(this, NULL, static_cast(obj), SHAPE_ROLE_NORMAL, shapes); } } // use multiple ShapeEditors for now, to allow editing many shapes at once // needs to be rethought - for (ShapeEditors::iterator i = nt->_shape_editors.begin(); - i != nt->_shape_editors.end(); ) + for (boost::ptr_map::iterator i = this->_shape_editors.begin(); + i != this->_shape_editors.end(); ) { ShapeRecord s; s.item = i->first; + if (shapes.find(s) == shapes.end()) { - nt->_shape_editors.erase(i++); + this->_shape_editors.erase(i++); } else { ++i; } @@ -460,23 +396,22 @@ void ink_node_tool_selection_changed(InkNodeTool *nt, Inkscape::Selection *sel) for (std::set::iterator i = shapes.begin(); i != shapes.end(); ++i) { ShapeRecord const &r = *i; + if ((SP_IS_SHAPE(r.item) || SP_IS_TEXT(r.item)) && - nt->_shape_editors.find(r.item) == nt->_shape_editors.end()) + this->_shape_editors.find(r.item) == this->_shape_editors.end()) { - ShapeEditor *si = new ShapeEditor(nt->desktop); + ShapeEditor *si = new ShapeEditor(this->desktop); si->set_item(r.item, SH_KNOTHOLDER); - nt->_shape_editors.insert(const_cast(r.item), si); + this->_shape_editors.insert(const_cast(r.item), si); } } - nt->_multipath->setItems(shapes); - ink_node_tool_update_tip(nt, NULL); - nt->desktop->updateNow(); + this->_multipath->setItems(shapes); + this->update_tip(NULL); + this->desktop->updateNow(); } gint InkNodeTool::root_handler(GdkEvent* event) { - SPEventContext* event_context = this; - /* things to handle here: * 1. selection of items * 2. passing events to manipulators @@ -484,14 +419,20 @@ gint InkNodeTool::root_handler(GdkEvent* event) { */ using namespace Inkscape::UI; // pull in event helpers - SPDesktop *desktop = event_context->desktop; Inkscape::Selection *selection = desktop->selection; - InkNodeTool *nt = static_cast(event_context); static Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - if (nt->_multipath->event(event_context, event)) return true; - if (nt->_selector->event(event_context, event)) return true; - if (nt->_selected_nodes->event(event_context, event)) return true; + if (this->_multipath->event(this, event)) { + return true; + } + + if (this->_selector->event(this, event)) { + return true; + } + + if (this->_selected_nodes->event(this, event)) { + return true; + } switch (event->type) { @@ -499,33 +440,52 @@ gint InkNodeTool::root_handler(GdkEvent* event) { combine_motion_events(desktop->canvas, event->motion, 0); SPItem *over_item = sp_event_context_find_item (desktop, event_point(event->button), FALSE, TRUE); - if (over_item != nt->_last_over) { - nt->_last_over = over_item; - ink_node_tool_update_tip(nt, event); + + if (over_item != this->_last_over) { + this->_last_over = over_item; + //ink_node_tool_update_tip(nt, event); + this->update_tip(event); } // create pathflash outline if (prefs->getBool("/tools/nodes/pathflash_enabled")) { - if (over_item == nt->flashed_item) break; - if (!prefs->getBool("/tools/nodes/pathflash_selected") && selection->includes(over_item)) break; - if (nt->flash_tempitem) { - desktop->remove_temporary_canvasitem(nt->flash_tempitem); - nt->flash_tempitem = NULL; - nt->flashed_item = NULL; + if (over_item == this->flashed_item) { + break; } - if (!SP_IS_SHAPE(over_item)) break; // for now, handle only shapes - nt->flashed_item = over_item; + if (!prefs->getBool("/tools/nodes/pathflash_selected") && selection->includes(over_item)) { + break; + } + + if (this->flash_tempitem) { + desktop->remove_temporary_canvasitem(this->flash_tempitem); + this->flash_tempitem = NULL; + this->flashed_item = NULL; + } + + if (!SP_IS_SHAPE(over_item)) { + break; // for now, handle only shapes + } + + this->flashed_item = over_item; SPCurve *c = SP_SHAPE(over_item)->getCurveBeforeLPE(); - if (!c) break; // break out when curve doesn't exist + + if (!c) { + break; // break out when curve doesn't exist + } + c->transform(over_item->i2dt_affine()); SPCanvasItem *flash = sp_canvas_bpath_new(sp_desktop_tempgroup(desktop), c); + sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(flash), prefs->getInt("/tools/nodes/highlight_color", 0xff0000ff), 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); + sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(flash), 0, SP_WIND_RULE_NONZERO); - nt->flash_tempitem = desktop->add_temporary_canvasitem(flash, + + this->flash_tempitem = desktop->add_temporary_canvasitem(flash, prefs->getInt("/tools/nodes/pathflash_timeout", 500)); + c->unref(); } } break; // do not return true, because we need to pass this event to the parent context @@ -535,39 +495,49 @@ gint InkNodeTool::root_handler(GdkEvent* event) { switch (get_group0_keyval(&event->key)) { case GDK_KEY_Escape: // deselect everything - if (nt->_selected_nodes->empty()) { + if (this->_selected_nodes->empty()) { Inkscape::SelectionHelper::selectNone(desktop); } else { - nt->_selected_nodes->clear(); + this->_selected_nodes->clear(); } - ink_node_tool_update_tip(nt, event); + //ink_node_tool_update_tip(nt, event); + this->update_tip(event); return TRUE; + case GDK_KEY_a: case GDK_KEY_A: if (held_control(event->key) && held_alt(event->key)) { - nt->_selected_nodes->selectAll(); + this->_selected_nodes->selectAll(); // Ctrl+A is handled in selection-chemistry.cpp via verb - ink_node_tool_update_tip(nt, event); + //ink_node_tool_update_tip(nt, event); + this->update_tip(event); return TRUE; } break; + case GDK_KEY_h: case GDK_KEY_H: if (held_only_control(event->key)) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setBool("/tools/nodes/show_handles", !nt->show_handles); + prefs->setBool("/tools/nodes/show_handles", !this->show_handles); return TRUE; } break; + default: break; } - ink_node_tool_update_tip(nt, event); + //ink_node_tool_update_tip(nt, event); + this->update_tip(event); break; + case GDK_KEY_RELEASE: - ink_node_tool_update_tip(nt, event); + //ink_node_tool_update_tip(nt, event); + this->update_tip(event); break; - default: break; + + default: + break; } // if (SP_EVENT_CONTEXT_CLASS(ink_node_tool_parent_class)->root_handler) @@ -577,97 +547,110 @@ gint InkNodeTool::root_handler(GdkEvent* event) { return FALSE; } -void ink_node_tool_update_tip(InkNodeTool *nt, GdkEvent *event) -{ +void InkNodeTool::update_tip(GdkEvent *event) { using namespace Inkscape::UI; + if (event && (event->type == GDK_KEY_PRESS || event->type == GDK_KEY_RELEASE)) { unsigned new_state = state_after_event(event); - if (new_state == event->key.state) return; + + if (new_state == event->key.state) { + return; + } + if (state_held_shift(new_state)) { - if (nt->_last_over) { - nt->_node_message_context->set(Inkscape::NORMAL_MESSAGE, + if (this->_last_over) { + this->_node_message_context->set(Inkscape::NORMAL_MESSAGE, C_("Node tool tip", "Shift: drag to add nodes to the selection, " "click to toggle object selection")); } else { - nt->_node_message_context->set(Inkscape::NORMAL_MESSAGE, + this->_node_message_context->set(Inkscape::NORMAL_MESSAGE, C_("Node tool tip", "Shift: drag to add nodes to the selection")); } + return; } } - unsigned sz = nt->_selected_nodes->size(); - unsigned total = nt->_selected_nodes->allPoints().size(); + + unsigned sz = this->_selected_nodes->size(); + unsigned total = this->_selected_nodes->allPoints().size(); + if (sz != 0) { char *nodestring = g_strdup_printf( ngettext("%u of %u node selected.", "%u of %u nodes selected.", total), sz, total); - if (nt->_last_over) { + + if (this->_last_over) { // TRANSLATORS: The %s below is where the "%u of %u nodes selected" sentence gets put char *dyntip = g_strdup_printf(C_("Node tool tip", "%s Drag to select nodes, click to edit only this object (more: Shift)"), nodestring); - nt->_node_message_context->set(Inkscape::NORMAL_MESSAGE, dyntip); + this->_node_message_context->set(Inkscape::NORMAL_MESSAGE, dyntip); g_free(dyntip); } else { char *dyntip = g_strdup_printf(C_("Node tool tip", "%s Drag to select nodes, click clear the selection"), nodestring); - nt->_node_message_context->set(Inkscape::NORMAL_MESSAGE, dyntip); + this->_node_message_context->set(Inkscape::NORMAL_MESSAGE, dyntip); g_free(dyntip); } g_free(nodestring); - } else if (!nt->_multipath->empty()) { - if (nt->_last_over) { - nt->_node_message_context->set(Inkscape::NORMAL_MESSAGE, C_("Node tool tip", + } else if (!this->_multipath->empty()) { + if (this->_last_over) { + this->_node_message_context->set(Inkscape::NORMAL_MESSAGE, C_("Node tool tip", "Drag to select nodes, click to edit only this object")); } else { - nt->_node_message_context->set(Inkscape::NORMAL_MESSAGE, C_("Node tool tip", + this->_node_message_context->set(Inkscape::NORMAL_MESSAGE, C_("Node tool tip", "Drag to select nodes, click to clear the selection")); } } else { - if (nt->_last_over) { - nt->_node_message_context->set(Inkscape::NORMAL_MESSAGE, C_("Node tool tip", + if (this->_last_over) { + this->_node_message_context->set(Inkscape::NORMAL_MESSAGE, C_("Node tool tip", "Drag to select objects to edit, click to edit this object (more: Shift)")); } else { - nt->_node_message_context->set(Inkscape::NORMAL_MESSAGE, C_("Node tool tip", + this->_node_message_context->set(Inkscape::NORMAL_MESSAGE, C_("Node tool tip", "Drag to select objects to edit")); } } } gint InkNodeTool::item_handler(SPItem* item, GdkEvent* event) { - - -// if (SP_EVENT_CONTEXT_CLASS(ink_node_tool_parent_class)->item_handler) -// return SP_EVENT_CONTEXT_CLASS(ink_node_tool_parent_class)->item_handler(event_context, item, event); SPEventContext::item_handler(item, event); return FALSE; } -void ink_node_tool_select_area(InkNodeTool *nt, Geom::Rect const &sel, GdkEventButton *event) -{ +void InkNodeTool::select_area(Geom::Rect const &sel, GdkEventButton *event) { using namespace Inkscape::UI; - if (nt->_multipath->empty()) { + + if (this->_multipath->empty()) { // if multipath is empty, select rubberbanded items rather than nodes - Inkscape::Selection *selection = nt->desktop->selection; - GSList *items = sp_desktop_document(nt->desktop)->getItemsInBox(nt->desktop->dkey, sel); + Inkscape::Selection *selection = this->desktop->selection; + GSList *items = sp_desktop_document(this->desktop)->getItemsInBox(this->desktop->dkey, sel); selection->setList(items); g_slist_free(items); } else { - if (!held_shift(*event)) nt->_selected_nodes->clear(); - nt->_selected_nodes->selectArea(sel); + if (!held_shift(*event)) { + this->_selected_nodes->clear(); + } + + this->_selected_nodes->selectArea(sel); } } -void ink_node_tool_select_point(InkNodeTool *nt, Geom::Point const &/*sel*/, GdkEventButton *event) -{ + +void InkNodeTool::select_point(Geom::Point const &sel, GdkEventButton *event) { using namespace Inkscape::UI; // pull in event helpers - if (!event) return; - if (event->button != 1) return; - Inkscape::Selection *selection = nt->desktop->selection; + if (!event) { + return; + } + + if (event->button != 1) { + return; + } - SPItem *item_clicked = sp_event_context_find_item (nt->desktop, event_point(*event), + Inkscape::Selection *selection = this->desktop->selection; + + SPItem *item_clicked = sp_event_context_find_item (this->desktop, event_point(*event), (event->state & GDK_MOD1_MASK) && !(event->state & GDK_CONTROL_MASK), TRUE); if (item_clicked == NULL) { // nothing under cursor @@ -675,10 +658,10 @@ void ink_node_tool_select_point(InkNodeTool *nt, Geom::Point const &/*sel*/, Gdk // if there are nodes selected, the first click should deselect the nodes // and the second should deselect the items if (!state_held_shift(event->state)) { - if (nt->_selected_nodes->empty()) { + if (this->_selected_nodes->empty()) { selection->clear(); } else { - nt->_selected_nodes->clear(); + this->_selected_nodes->clear(); } } } else { @@ -687,32 +670,33 @@ void ink_node_tool_select_point(InkNodeTool *nt, Geom::Point const &/*sel*/, Gdk } else { selection->set(item_clicked); } - nt->desktop->updateNow(); + + this->desktop->updateNow(); } } -void ink_node_tool_mouseover_changed(InkNodeTool *nt, Inkscape::UI::ControlPoint *p) -{ +void InkNodeTool::mouseover_changed(Inkscape::UI::ControlPoint *p) { using Inkscape::UI::CurveDragPoint; + CurveDragPoint *cdp = dynamic_cast(p); - if (cdp && !nt->cursor_drag) { - nt->cursor_shape = cursor_node_d_xpm; - nt->hot_x = 1; - nt->hot_y = 1; - sp_event_context_update_cursor(nt); - nt->cursor_drag = true; - } else if (!cdp && nt->cursor_drag) { - nt->cursor_shape = cursor_node_xpm; - nt->hot_x = 1; - nt->hot_y = 1; - sp_event_context_update_cursor(nt); - nt->cursor_drag = false; + + if (cdp && !this->cursor_drag) { + this->cursor_shape = cursor_node_d_xpm; + this->hot_x = 1; + this->hot_y = 1; + sp_event_context_update_cursor(this); + this->cursor_drag = true; + } else if (!cdp && this->cursor_drag) { + this->cursor_shape = cursor_node_xpm; + this->hot_x = 1; + this->hot_y = 1; + sp_event_context_update_cursor(this); + this->cursor_drag = false; } } -void handleControlUiStyleChange(InkNodeTool *nt) -{ - nt->_multipath->updateHandles(); +void InkNodeTool::handleControlUiStyleChange() { + this->_multipath->updateHandles(); } //} // anonymous namespace diff --git a/src/ui/tool/node-tool.h b/src/ui/tool/node-tool.h index fb2b41663..597f2a347 100644 --- a/src/ui/tool/node-tool.h +++ b/src/ui/tool/node-tool.h @@ -11,7 +11,6 @@ #ifndef SEEN_UI_TOOL_NODE_TOOL_H #define SEEN_UI_TOOL_NODE_TOOL_H -#include #include #include #include "event-context.h" @@ -29,53 +28,20 @@ class MultiPathManipulator; class ControlPointSelection; class Selector; struct PathSharedData; +class ControlPoint; } // namespace UI } // namespace Inkscape -//typedef std::auto_ptr MultiPathPtr; -//typedef std::auto_ptr CSelPtr; -//typedef std::auto_ptr SelectorPtr; -//typedef std::auto_ptr PathSharedDataPtr; - - -typedef Inkscape::UI::MultiPathManipulator* MultiPathPtr; -typedef Inkscape::UI::ControlPointSelection* CSelPtr; -typedef Inkscape::UI::Selector* SelectorPtr; -typedef Inkscape::UI::PathSharedData* PathSharedDataPtr; - -typedef boost::ptr_map ShapeEditors; - - class InkNodeTool : public SPEventContext { public: InkNodeTool(); virtual ~InkNodeTool(); - sigc::connection _selection_changed_connection; - sigc::connection _mouseover_changed_connection; - sigc::connection _selection_modified_connection; - sigc::connection _sizeUpdatedConn; - Inkscape::MessageContext *_node_message_context; - SPItem *flashed_item; - Inkscape::Display::TemporaryItem *flash_tempitem; - CSelPtr _selected_nodes; - MultiPathPtr _multipath; - SelectorPtr _selector; - PathSharedDataPtr _path_data; - SPCanvasGroup *_transform_handle_group; - SPItem *_last_over; - ShapeEditors _shape_editors; - - unsigned cursor_drag : 1; - unsigned show_handles : 1; - unsigned show_outline : 1; - unsigned live_outline : 1; - unsigned live_objects : 1; - unsigned show_path_direction : 1; - unsigned show_transform_handles : 1; - unsigned single_node_transform_handles : 1; - unsigned edit_clipping_paths : 1; - unsigned edit_masks : 1; + Inkscape::UI::ControlPointSelection* _selected_nodes; + Inkscape::UI::MultiPathManipulator* _multipath; + + bool edit_clipping_paths; + bool edit_masks; static const std::string prefsPath; @@ -85,6 +51,37 @@ public: virtual gint item_handler(SPItem* item, GdkEvent* event); virtual const std::string& getPrefsPath(); + +private: + sigc::connection _selection_changed_connection; + sigc::connection _mouseover_changed_connection; + sigc::connection _sizeUpdatedConn; + + Inkscape::MessageContext *_node_message_context; + SPItem *flashed_item; + Inkscape::Display::TemporaryItem *flash_tempitem; + Inkscape::UI::Selector* _selector; + Inkscape::UI::PathSharedData* _path_data; + SPCanvasGroup *_transform_handle_group; + SPItem *_last_over; + boost::ptr_map _shape_editors; + + bool cursor_drag; + bool show_handles; + bool show_outline; + bool live_outline; + bool live_objects; + bool show_path_direction; + bool show_transform_handles; + bool single_node_transform_handles; + + void selection_changed(Inkscape::Selection *sel); + + void select_area(Geom::Rect const &sel, GdkEventButton *event); + void select_point(Geom::Point const &sel, GdkEventButton *event); + void mouseover_changed(Inkscape::UI::ControlPoint *p); + void update_tip(GdkEvent *event); + void handleControlUiStyleChange(); }; #endif -- cgit v1.2.3 From bdde74bbab299f2ee448f1c55469c56a66fb01f7 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sun, 21 Apr 2013 23:58:15 +0200 Subject: Removed some unused files; more refactoring in EventContext tree. (bzr r11608.1.104) --- src/ui/tool/node-tool.cpp | 22 +++++++++++----------- src/ui/tool/node-tool.h | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'src/ui') diff --git a/src/ui/tool/node-tool.cpp b/src/ui/tool/node-tool.cpp index f64aa4d2a..b65ca22b9 100644 --- a/src/ui/tool/node-tool.cpp +++ b/src/ui/tool/node-tool.cpp @@ -285,37 +285,37 @@ void InkNodeTool::setup() { this->desktop->emitToolSubselectionChanged(NULL); // sets the coord entry fields to inactive } -void InkNodeTool::set(Inkscape::Preferences::Entry* value) { - Glib::ustring entry_name = value->getEntryName(); +void InkNodeTool::set(const Inkscape::Preferences::Entry& value) { + Glib::ustring entry_name = value.getEntryName(); if (entry_name == "show_handles") { - this->show_handles = value->getBool(true); + this->show_handles = value.getBool(true); this->_multipath->showHandles(this->show_handles); } else if (entry_name == "show_outline") { - this->show_outline = value->getBool(); + this->show_outline = value.getBool(); this->_multipath->showOutline(this->show_outline); } else if (entry_name == "live_outline") { - this->live_outline = value->getBool(); + this->live_outline = value.getBool(); this->_multipath->setLiveOutline(this->live_outline); } else if (entry_name == "live_objects") { - this->live_objects = value->getBool(); + this->live_objects = value.getBool(); this->_multipath->setLiveObjects(this->live_objects); } else if (entry_name == "show_path_direction") { - this->show_path_direction = value->getBool(); + this->show_path_direction = value.getBool(); this->_multipath->showPathDirection(this->show_path_direction); } else if (entry_name == "show_transform_handles") { - this->show_transform_handles = value->getBool(true); + this->show_transform_handles = value.getBool(true); this->_selected_nodes->showTransformHandles( this->show_transform_handles, this->single_node_transform_handles); } else if (entry_name == "single_node_transform_handles") { - this->single_node_transform_handles = value->getBool(); + this->single_node_transform_handles = value.getBool(); this->_selected_nodes->showTransformHandles( this->show_transform_handles, this->single_node_transform_handles); } else if (entry_name == "edit_clipping_paths") { - this->edit_clipping_paths = value->getBool(); + this->edit_clipping_paths = value.getBool(); this->selection_changed(this->desktop->selection); } else if (entry_name == "edit_masks") { - this->edit_masks = value->getBool(); + this->edit_masks = value.getBool(); this->selection_changed(this->desktop->selection); } else { SPEventContext::set(value); diff --git a/src/ui/tool/node-tool.h b/src/ui/tool/node-tool.h index 597f2a347..df8b5d782 100644 --- a/src/ui/tool/node-tool.h +++ b/src/ui/tool/node-tool.h @@ -46,7 +46,7 @@ public: static const std::string prefsPath; virtual void setup(); - virtual void set(Inkscape::Preferences::Entry* val); + virtual void set(const Inkscape::Preferences::Entry& val); virtual gint root_handler(GdkEvent* event); virtual gint item_handler(SPItem* item, GdkEvent* event); -- cgit v1.2.3 From b2dd3583e7372d23d18bbc6e861f4f645ec3dc37 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Tue, 30 Jul 2013 23:17:21 +0200 Subject: Further refactoring of EventContexts. (bzr r11608.1.109) --- src/ui/dialog/align-and-distribute.cpp | 25 ++++++++++++++++--------- src/ui/tool/node-tool.cpp | 8 ++++---- src/ui/tool/node-tool.h | 33 +++++++++++++++++---------------- 3 files changed, 37 insertions(+), 29 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index 8845b60e5..38f10c59c 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -47,6 +47,7 @@ #include "widgets/icon.h" #include "sp-root.h" #include "document-undo.h" +#include "desktop.h" #include @@ -367,19 +368,25 @@ public : private : Geom::Dim2 _orientation; bool _distribute; - virtual void on_button_click() - { - if (!_dialog.getDesktop()) return; - SPEventContext *event_context = sp_desktop_event_context(_dialog.getDesktop()); - if (!INK_IS_NODE_TOOL (event_context)) return; + virtual void on_button_click() { + if (!_dialog.getDesktop()) { + return; + } + + SPEventContext *event_context = _dialog.getDesktop()->getEventContext(); + + if (!INK_IS_NODE_TOOL(event_context)) { + return; + } + InkNodeTool *nt = INK_NODE_TOOL(event_context); - if (_distribute) + if (_distribute) { nt->_multipath->distributeNodes(_orientation); - else + } else { nt->_multipath->alignNodes(_orientation); - + } } }; @@ -825,7 +832,7 @@ private : static void on_tool_changed(Inkscape::Application */*inkscape*/, SPEventContext */*context*/, AlignAndDistribute *daad) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; - if (desktop && sp_desktop_event_context(desktop)) + if (desktop && desktop->getEventContext()) daad->setMode(tools_active(desktop) == TOOLS_NODES); } diff --git a/src/ui/tool/node-tool.cpp b/src/ui/tool/node-tool.cpp index b65ca22b9..d424c1fdb 100644 --- a/src/ui/tool/node-tool.cpp +++ b/src/ui/tool/node-tool.cpp @@ -411,7 +411,7 @@ void InkNodeTool::selection_changed(Inkscape::Selection *sel) { this->desktop->updateNow(); } -gint InkNodeTool::root_handler(GdkEvent* event) { +bool InkNodeTool::root_handler(GdkEvent* event) { /* things to handle here: * 1. selection of items * 2. passing events to manipulators @@ -613,7 +613,7 @@ void InkNodeTool::update_tip(GdkEvent *event) { } } -gint InkNodeTool::item_handler(SPItem* item, GdkEvent* event) { +bool InkNodeTool::item_handler(SPItem* item, GdkEvent* event) { SPEventContext::item_handler(item, event); return FALSE; @@ -684,13 +684,13 @@ void InkNodeTool::mouseover_changed(Inkscape::UI::ControlPoint *p) { this->cursor_shape = cursor_node_d_xpm; this->hot_x = 1; this->hot_y = 1; - sp_event_context_update_cursor(this); + this->sp_event_context_update_cursor(); this->cursor_drag = true; } else if (!cdp && this->cursor_drag) { this->cursor_shape = cursor_node_xpm; this->hot_x = 1; this->hot_y = 1; - sp_event_context_update_cursor(this); + this->sp_event_context_update_cursor(); this->cursor_drag = false; } } diff --git a/src/ui/tool/node-tool.h b/src/ui/tool/node-tool.h index df8b5d782..313cc0561 100644 --- a/src/ui/tool/node-tool.h +++ b/src/ui/tool/node-tool.h @@ -15,22 +15,23 @@ #include #include "event-context.h" -#define INK_NODE_TOOL(obj) ((InkNodeTool*)obj) -#define INK_IS_NODE_TOOL(obj) (dynamic_cast((const SPEventContext*)obj)) - namespace Inkscape { + namespace Display { + class TemporaryItem; + } + + namespace UI { + class MultiPathManipulator; + class ControlPointSelection; + class Selector; + class ControlPoint; -namespace Display { -class TemporaryItem; -} // namespace Display -namespace UI { -class MultiPathManipulator; -class ControlPointSelection; -class Selector; -struct PathSharedData; -class ControlPoint; -} // namespace UI -} // namespace Inkscape + struct PathSharedData; + } +} + +#define INK_NODE_TOOL(obj) ((InkNodeTool*)obj) +#define INK_IS_NODE_TOOL(obj) (dynamic_cast((const SPEventContext*)obj)) class InkNodeTool : public SPEventContext { public: @@ -47,8 +48,8 @@ public: virtual void setup(); virtual void set(const Inkscape::Preferences::Entry& val); - virtual gint root_handler(GdkEvent* event); - virtual gint item_handler(SPItem* item, GdkEvent* event); + virtual bool root_handler(GdkEvent* event); + virtual bool item_handler(SPItem* item, GdkEvent* event); virtual const std::string& getPrefsPath(); -- cgit v1.2.3 From 989abbac025a8b3349748d19a613a08586c5fdcd Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Wed, 31 Jul 2013 21:11:20 +0200 Subject: Fixed SPObject ctor and dtor; removed singleton.h; some smaller changes. (bzr r11608.1.110) --- src/ui/tool/node-tool.cpp | 22 ++++++++-------------- src/ui/tool/node-tool.h | 1 - src/ui/widget/selected-style.cpp | 14 +++++++------- 3 files changed, 15 insertions(+), 22 deletions(-) (limited to 'src/ui') diff --git a/src/ui/tool/node-tool.cpp b/src/ui/tool/node-tool.cpp index d424c1fdb..4b236e94c 100644 --- a/src/ui/tool/node-tool.cpp +++ b/src/ui/tool/node-tool.cpp @@ -127,7 +127,6 @@ InkNodeTool::InkNodeTool() : SPEventContext() { this->single_node_transform_handles = false; this->show_transform_handles = false; this->cursor_drag = false; - this->_node_message_context = 0; this->live_objects = false; this->edit_clipping_paths = false; this->live_outline = false; @@ -183,16 +182,11 @@ InkNodeTool::~InkNodeTool() { destroy_group(data.outline_group); destroy_group(data.dragpoint_group); destroy_group(this->_transform_handle_group); - - if (this->_node_message_context) { - delete this->_node_message_context; - } } void InkNodeTool::setup() { SPEventContext::setup(); - this->_node_message_context = new Inkscape::MessageContext((this->desktop)->messageStack()); this->_path_data = new Inkscape::UI::PathSharedData(); Inkscape::UI::PathSharedData &data = *this->_path_data; @@ -559,11 +553,11 @@ void InkNodeTool::update_tip(GdkEvent *event) { if (state_held_shift(new_state)) { if (this->_last_over) { - this->_node_message_context->set(Inkscape::NORMAL_MESSAGE, + this->message_context->set(Inkscape::NORMAL_MESSAGE, C_("Node tool tip", "Shift: drag to add nodes to the selection, " "click to toggle object selection")); } else { - this->_node_message_context->set(Inkscape::NORMAL_MESSAGE, + this->message_context->set(Inkscape::NORMAL_MESSAGE, C_("Node tool tip", "Shift: drag to add nodes to the selection")); } @@ -584,30 +578,30 @@ void InkNodeTool::update_tip(GdkEvent *event) { char *dyntip = g_strdup_printf(C_("Node tool tip", "%s Drag to select nodes, click to edit only this object (more: Shift)"), nodestring); - this->_node_message_context->set(Inkscape::NORMAL_MESSAGE, dyntip); + this->message_context->set(Inkscape::NORMAL_MESSAGE, dyntip); g_free(dyntip); } else { char *dyntip = g_strdup_printf(C_("Node tool tip", "%s Drag to select nodes, click clear the selection"), nodestring); - this->_node_message_context->set(Inkscape::NORMAL_MESSAGE, dyntip); + this->message_context->set(Inkscape::NORMAL_MESSAGE, dyntip); g_free(dyntip); } g_free(nodestring); } else if (!this->_multipath->empty()) { if (this->_last_over) { - this->_node_message_context->set(Inkscape::NORMAL_MESSAGE, C_("Node tool tip", + this->message_context->set(Inkscape::NORMAL_MESSAGE, C_("Node tool tip", "Drag to select nodes, click to edit only this object")); } else { - this->_node_message_context->set(Inkscape::NORMAL_MESSAGE, C_("Node tool tip", + this->message_context->set(Inkscape::NORMAL_MESSAGE, C_("Node tool tip", "Drag to select nodes, click to clear the selection")); } } else { if (this->_last_over) { - this->_node_message_context->set(Inkscape::NORMAL_MESSAGE, C_("Node tool tip", + this->message_context->set(Inkscape::NORMAL_MESSAGE, C_("Node tool tip", "Drag to select objects to edit, click to edit this object (more: Shift)")); } else { - this->_node_message_context->set(Inkscape::NORMAL_MESSAGE, C_("Node tool tip", + this->message_context->set(Inkscape::NORMAL_MESSAGE, C_("Node tool tip", "Drag to select objects to edit")); } } diff --git a/src/ui/tool/node-tool.h b/src/ui/tool/node-tool.h index 313cc0561..779cf98e6 100644 --- a/src/ui/tool/node-tool.h +++ b/src/ui/tool/node-tool.h @@ -58,7 +58,6 @@ private: sigc::connection _mouseover_changed_connection; sigc::connection _sizeUpdatedConn; - Inkscape::MessageContext *_node_message_context; SPItem *flashed_item; Inkscape::Display::TemporaryItem *flash_tempitem; Inkscape::UI::Selector* _selector; diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index 8cb0c5588..08589a0b6 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -1351,25 +1351,25 @@ RotateableSwatch::do_motion(double by, guint modifier) { DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey, SP_VERB_DIALOG_FILL_STROKE, (_("Adjust alpha"))); double ch = hsla[3]; - parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting alpha: was %.3g, now %.3g (diff %.3g); with Ctrl to adjust lightness, with Shift to adjust saturation, without modifiers to adjust hue"), ch - diff, ch, diff); + parent->getDesktop()->event_context->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting alpha: was %.3g, now %.3g (diff %.3g); with Ctrl to adjust lightness, with Shift to adjust saturation, without modifiers to adjust hue"), ch - diff, ch, diff); } else if (modifier == 2) { // saturation DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey, SP_VERB_DIALOG_FILL_STROKE, (_("Adjust saturation"))); double ch = hsla[1]; - parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting saturation: was %.3g, now %.3g (diff %.3g); with Ctrl to adjust lightness, with Alt to adjust alpha, without modifiers to adjust hue"), ch - diff, ch, diff); + parent->getDesktop()->event_context->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting saturation: was %.3g, now %.3g (diff %.3g); with Ctrl to adjust lightness, with Alt to adjust alpha, without modifiers to adjust hue"), ch - diff, ch, diff); } else if (modifier == 1) { // lightness DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey, SP_VERB_DIALOG_FILL_STROKE, (_("Adjust lightness"))); double ch = hsla[2]; - parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting lightness: was %.3g, now %.3g (diff %.3g); with Shift to adjust saturation, with Alt to adjust alpha, without modifiers to adjust hue"), ch - diff, ch, diff); + parent->getDesktop()->event_context->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting lightness: was %.3g, now %.3g (diff %.3g); with Shift to adjust saturation, with Alt to adjust alpha, without modifiers to adjust hue"), ch - diff, ch, diff); } else { // hue DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey, SP_VERB_DIALOG_FILL_STROKE, (_("Adjust hue"))); double ch = hsla[0]; - parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting hue: was %.3g, now %.3g (diff %.3g); with Shift to adjust saturation, with Alt to adjust alpha, with Ctrl to adjust lightness"), ch - diff, ch, diff); + parent->getDesktop()->event_context->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting hue: was %.3g, now %.3g (diff %.3g); with Shift to adjust saturation, with Alt to adjust alpha, with Ctrl to adjust lightness"), ch - diff, ch, diff); } } @@ -1424,7 +1424,7 @@ RotateableSwatch::do_release(double by, guint modifier) { undokey = "ssrot1"; } - parent->getDesktop()->event_context->_message_context->clear(); + parent->getDesktop()->event_context->message_context->clear(); startcolor_set = false; } @@ -1490,7 +1490,7 @@ RotateableStrokeWidth::do_motion(double by, guint modifier) { double diff = value_adjust(startvalue, by, modifier, false); DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey, SP_VERB_DIALOG_FILL_STROKE, (_("Adjust stroke width"))); - parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting stroke width: was %.3g, now %.3g (diff %.3g)"), startvalue, startvalue + diff, diff); + parent->getDesktop()->event_context->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting stroke width: was %.3g, now %.3g (diff %.3g)"), startvalue, startvalue + diff, diff); } } @@ -1511,7 +1511,7 @@ RotateableStrokeWidth::do_release(double by, guint modifier) { } else { undokey = "swrot1"; } - parent->getDesktop()->event_context->_message_context->clear(); + parent->getDesktop()->event_context->message_context->clear(); } void -- cgit v1.2.3 From beecbea1b415d5b9536f2309c4f30fc258e346f5 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Wed, 31 Jul 2013 22:51:23 +0200 Subject: Cleaned up a bit; fixed struct vs. class forward declarations. (bzr r11608.1.111) --- src/ui/dialog/svg-fonts-dialog.h | 6 +++--- src/ui/tool/control-point.h | 2 +- src/ui/view/view-widget.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/svg-fonts-dialog.h b/src/ui/dialog/svg-fonts-dialog.h index 01f70654a..e5c4631e4 100644 --- a/src/ui/dialog/svg-fonts-dialog.h +++ b/src/ui/dialog/svg-fonts-dialog.h @@ -34,8 +34,8 @@ class HScale; #endif } -struct SPGlyph; -struct SPGlyphKerning; +class SPGlyph; +class SPGlyphKerning; class SvgFont; class SvgFontDrawingArea : Gtk::DrawingArea{ @@ -52,7 +52,7 @@ private: bool on_expose_event (GdkEventExpose *event); }; -struct SPFont; +class SPFont; namespace Inkscape { namespace UI { diff --git a/src/ui/tool/control-point.h b/src/ui/tool/control-point.h index 27a0f8074..30efe8a27 100644 --- a/src/ui/tool/control-point.h +++ b/src/ui/tool/control-point.h @@ -23,7 +23,7 @@ #include "enums.h" class SPDesktop; -struct SPEventContext; +class SPEventContext; namespace Inkscape { namespace UI { diff --git a/src/ui/view/view-widget.h b/src/ui/view/view-widget.h index 295e7932b..668f9d19a 100644 --- a/src/ui/view/view-widget.h +++ b/src/ui/view/view-widget.h @@ -23,7 +23,7 @@ class View; } // namespace Inkscape class SPViewWidget; -struct SPNamedView; +class SPNamedView; #define SP_TYPE_VIEW_WIDGET (sp_view_widget_get_type ()) #define SP_VIEW_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_VIEW_WIDGET, SPViewWidget)) -- cgit v1.2.3 From dd18c27c36c9138bc68161ad365bfc61b8d135f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20dos=20Santos=20Oliveira?= Date: Thu, 12 Sep 2013 07:23:11 -0300 Subject: Integrating with libdepixelize (bzr r12506.1.1) --- src/ui/CMakeLists.txt | 1 + src/ui/dialog/Makefile_insert | 2 + src/ui/dialog/dialog-manager.cpp | 3 + src/ui/dialog/pixelartdialog.cpp | 490 +++++++++++++++++++++++++++++++++++++++ src/ui/dialog/pixelartdialog.h | 69 ++++++ 5 files changed, 565 insertions(+) create mode 100644 src/ui/dialog/pixelartdialog.cpp create mode 100644 src/ui/dialog/pixelartdialog.h (limited to 'src/ui') diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index c95dd35cc..233e01862 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -71,6 +71,7 @@ set(ui_SRC dialog/text-edit.cpp dialog/tile.cpp dialog/tracedialog.cpp + dialog/pixelartdialog.cpp dialog/transformation.cpp dialog/undo-history.cpp # dialog/whiteboard-connect.cpp diff --git a/src/ui/dialog/Makefile_insert b/src/ui/dialog/Makefile_insert index 09a7ef573..c37767a08 100644 --- a/src/ui/dialog/Makefile_insert +++ b/src/ui/dialog/Makefile_insert @@ -101,6 +101,8 @@ ink_common_sources += \ ui/dialog/tile.h \ ui/dialog/tracedialog.cpp \ ui/dialog/tracedialog.h \ + ui/dialog/pixelartdialog.cpp \ + ui/dialog/pixelartdialog.h \ ui/dialog/transformation.cpp \ ui/dialog/transformation.h \ ui/dialog/undo-history.cpp \ diff --git a/src/ui/dialog/dialog-manager.cpp b/src/ui/dialog/dialog-manager.cpp index 0ce74f54e..17f6ae74d 100644 --- a/src/ui/dialog/dialog-manager.cpp +++ b/src/ui/dialog/dialog-manager.cpp @@ -35,6 +35,7 @@ #include "ui/dialog/symbols.h" #include "ui/dialog/tile.h" #include "ui/dialog/tracedialog.h" +#include "ui/dialog/pixelartdialog.h" #include "ui/dialog/transformation.h" #include "ui/dialog/undo-history.h" #include "ui/dialog/panel-dialog.h" @@ -118,6 +119,7 @@ DialogManager::DialogManager() { registerFactory("Symbols", &create); registerFactory("TileDialog", &create); registerFactory("Trace", &create); + registerFactory("PixelArt", &create); registerFactory("Transformation", &create); registerFactory("UndoHistory", &create); registerFactory("InputDevices", &create); @@ -151,6 +153,7 @@ DialogManager::DialogManager() { registerFactory("Symbols", &create); registerFactory("TileDialog", &create); registerFactory("Trace", &create); + registerFactory("PixelArt", &create); registerFactory("Transformation", &create); registerFactory("UndoHistory", &create); registerFactory("InputDevices", &create); diff --git a/src/ui/dialog/pixelartdialog.cpp b/src/ui/dialog/pixelartdialog.cpp new file mode 100644 index 000000000..6f0845ada --- /dev/null +++ b/src/ui/dialog/pixelartdialog.cpp @@ -0,0 +1,490 @@ +/** + * @file + * Pixel art tracing settings dialog - implementation. + */ +/* Authors: + * Bob Jamison + * Stéphane Gimenez + * Vinícius dos Santos Oliveira + * Other dudes from The Inkscape Organization + * + * Copyright (C) 2004-2013 Authors + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ +#ifdef HAVE_CONFIG_H +# include +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "pixelartdialog.h" +#include +#include + +#include //for GTK_RESPONSE* types +#include + +#include "ui/widget/spinbutton.h" +#include "ui/widget/frame.h" + +#include "desktop.h" +#include "desktop-tracker.h" +#include "message-stack.h" +#include "selection.h" +#include "preferences.h" + +#include "sp-image.h" +#include "libdepixelize/kopftracer2011.h" +#include +#include "document.h" +#include "xml/repr.h" +#include "xml/document.h" +#include "svg/svg.h" +#include "svg/svg-color.h" +#include "color.h" +#include "svg/css-ostringstream.h" +#include "document-undo.h" + +#ifdef HAVE_OPENMP +#include +#endif // HAVE_OPENMP + +namespace Inkscape { +namespace UI { +namespace Dialog { + +template +T move(T &obj) +{ +#ifdef LIBDEPIXELIZE_ENABLE_CPP11 + return std::move(obj); +#else + T ret; + std::swap(obj, ret); + return ret; +#endif // LIBDEPIXELIZE_ENABLE_CPP11 +} + +/** + * A dialog for adjusting pixel art -> vector tracing parameters + */ +class PixelArtDialogImpl : public PixelArtDialog +{ +public: + PixelArtDialogImpl(); + + ~PixelArtDialogImpl(); + +private: + void setDesktop(SPDesktop *desktop); + void setTargetDesktop(SPDesktop *desktop); + + //############ Events + + void responseCallback(int response_id); + + //############ UI Logic + + Tracer::Kopf2011::Options options(); + + void vectorize(); + void processLibdepixelize(SPImage *img); + void setDefaults(); + void updatePreview(); + + bool ignorePreview; + bool pendingPreview; + + //############ UI + + Gtk::HBox buttonsHBox; + + Gtk::Button *mainOkButton; + Gtk::Button *mainCancelButton; + Gtk::Button *mainResetButton; + + Gtk::VBox heuristicsVBox; + UI::Widget::Frame heuristicsFrame; + + Gtk::HBox curvesMultiplierHBox; + Gtk::Label curvesMultiplierLabel; + Inkscape::UI::Widget::SpinButton curvesMultiplierSpinner; + + Gtk::HBox islandsWeightHBox; + Gtk::Label islandsWeightLabel; + Inkscape::UI::Widget::SpinButton islandsWeightSpinner; + + Gtk::HBox sparsePixelsMultiplierHBox; + Gtk::Label sparsePixelsMultiplierLabel; + Inkscape::UI::Widget::SpinButton sparsePixelsMultiplierSpinner; + + Gtk::HBox sparsePixelsRadiusHBox; + Gtk::Label sparsePixelsRadiusLabel; + Inkscape::UI::Widget::SpinButton sparsePixelsRadiusSpinner; + + Gtk::VBox outputVBox; + UI::Widget::Frame outputFrame; + Gtk::RadioButtonGroup outputGroup; + + Gtk::RadioButton voronoiRadioButton; + Gtk::RadioButton noOptimizeRadioButton; + Gtk::RadioButton optimizeRadioButton; + + SPDesktop *desktop; + DesktopTracker deskTrack; + sigc::connection desktopChangeConn; +}; + +void PixelArtDialogImpl::setDesktop(SPDesktop *desktop) +{ + Panel::setDesktop(desktop); + deskTrack.setBase(desktop); +} + +void PixelArtDialogImpl::setTargetDesktop(SPDesktop *desktop) +{ + this->desktop = desktop; +} + +PixelArtDialogImpl::PixelArtDialogImpl() : + PixelArtDialog(), + ignorePreview(false), + pendingPreview(false) +{ + + Gtk::Box *contents = _getContents(); + + // Heuristics + { + curvesMultiplierLabel.set_label(_("_Curves (multiplier)")); + curvesMultiplierLabel.set_use_underline(true); + curvesMultiplierLabel.set_mnemonic_widget(curvesMultiplierSpinner); + curvesMultiplierLabel.set_tooltip_text(_("Favors connections that are part of a long curve")); + curvesMultiplierSpinner.set_increments(0.125, 0); + curvesMultiplierSpinner.set_digits(3); + curvesMultiplierSpinner.set_range(-10, 10); + curvesMultiplierSpinner.get_adjustment()->signal_value_changed() + .connect(sigc::mem_fun(*this, &PixelArtDialogImpl::updatePreview)); + + curvesMultiplierHBox.pack_start(curvesMultiplierLabel, false, false); + curvesMultiplierHBox.pack_end(curvesMultiplierSpinner, false, false); + heuristicsVBox.pack_start(curvesMultiplierHBox, false, false); + + islandsWeightLabel.set_label(_("_Islands (weight)")); + islandsWeightLabel.set_use_underline(true); + islandsWeightLabel.set_mnemonic_widget(islandsWeightSpinner); + islandsWeightLabel.set_tooltip_text(_("Avoid single disconnected pixels")); + + islandsWeightSpinner.set_tooltip_text(_("A constant vote value")); + islandsWeightSpinner.set_increments(1, 0); + islandsWeightSpinner.set_range(-20, 20); + islandsWeightSpinner.get_adjustment()->signal_value_changed() + .connect(sigc::mem_fun(*this, &PixelArtDialogImpl::updatePreview)); + + islandsWeightHBox.pack_start(islandsWeightLabel, false, false); + islandsWeightHBox.pack_end(islandsWeightSpinner, false, false); + heuristicsVBox.pack_start(islandsWeightHBox, false, false); + + sparsePixelsRadiusLabel.set_label(_("Sparse pixels (window _radius)")); + sparsePixelsRadiusLabel.set_use_underline(true); + sparsePixelsRadiusLabel.set_mnemonic_widget(sparsePixelsRadiusSpinner); + + sparsePixelsRadiusSpinner.set_increments(1, 0); + sparsePixelsRadiusSpinner.set_range(2, 8); + sparsePixelsRadiusSpinner.get_adjustment()->signal_value_changed() + .connect(sigc::mem_fun(*this, &PixelArtDialogImpl::updatePreview)); + + sparsePixelsRadiusSpinner.set_tooltip_text(_("The radius of the window analyzed")); + sparsePixelsMultiplierLabel.set_label(_("Sparse pixels (_multiplier)")); + sparsePixelsMultiplierLabel.set_use_underline(true); + sparsePixelsMultiplierLabel.set_mnemonic_widget(sparsePixelsMultiplierSpinner); + + sparsePixelsMultiplierSpinner.set_increments(0.125, 0); + sparsePixelsMultiplierSpinner.set_digits(3); + sparsePixelsMultiplierSpinner.set_range(-10, 10); + sparsePixelsMultiplierSpinner.get_adjustment()->signal_value_changed() + .connect(sigc::mem_fun(*this, &PixelArtDialogImpl::updatePreview)); + + { + char const *str = _("Favors connections that are part of foreground color"); + sparsePixelsRadiusLabel.set_tooltip_text(str); + sparsePixelsMultiplierLabel.set_tooltip_text(str); + } + + { + char const *str = _("The heuristic computed vote will be multiplied by this value"); + curvesMultiplierSpinner.set_tooltip_text(str); + sparsePixelsMultiplierSpinner.set_tooltip_text(str); + } + + sparsePixelsRadiusHBox.pack_start(sparsePixelsRadiusLabel, false, false); + sparsePixelsRadiusHBox.pack_end(sparsePixelsRadiusSpinner, false, false); + heuristicsVBox.pack_start(sparsePixelsRadiusHBox, false, false); + + sparsePixelsMultiplierHBox.pack_start(sparsePixelsMultiplierLabel, false, false); + sparsePixelsMultiplierHBox.pack_end(sparsePixelsMultiplierSpinner, false, false); + heuristicsVBox.pack_start(sparsePixelsMultiplierHBox, false, false); + + heuristicsFrame.set_label(_("Heuristics")); + heuristicsFrame.add(heuristicsVBox); + contents->pack_start(heuristicsFrame, false, false); + } + + // Output + { + voronoiRadioButton.set_label(_("_Voronoi diagram")); + voronoiRadioButton.set_tooltip_text(_("Output composed of straight lines")); + voronoiRadioButton.set_use_underline(true); + outputGroup = voronoiRadioButton.get_group(); + + outputVBox.pack_start(voronoiRadioButton, false, false); + + noOptimizeRadioButton.set_label(_("Convert to _B-spline curves")); + noOptimizeRadioButton.set_tooltip_text(_("Preserve staircasing artifacts")); + noOptimizeRadioButton.set_use_underline(true); + noOptimizeRadioButton.set_group(outputGroup); + + outputVBox.pack_start(noOptimizeRadioButton, false, false); + + optimizeRadioButton.set_label(_("_Smooth curves")); + optimizeRadioButton.set_tooltip_text(_("The Kopf-Lischinski algorithm")); + optimizeRadioButton.set_use_underline(true); + optimizeRadioButton.set_group(outputGroup); + + outputVBox.pack_start(optimizeRadioButton, false, false); + + outputFrame.set_label(_("Output")); + outputFrame.add(outputVBox); + contents->pack_start(outputFrame, true, false); + } + + // Buttons + { + mainResetButton = addResponseButton(_("Reset"), GTK_RESPONSE_HELP, true); + mainResetButton ->set_tooltip_text(_("Reset all settings to defaults")); + + //## The OK button + mainCancelButton = addResponseButton(Gtk::Stock::STOP, GTK_RESPONSE_CANCEL); + if (mainCancelButton) { + mainCancelButton->set_tooltip_text(_("Abort a trace in progress")); + mainCancelButton->set_sensitive(false); + } + mainOkButton = addResponseButton(Gtk::Stock::OK, GTK_RESPONSE_OK); + mainOkButton->set_tooltip_text(_("Execute the trace")); + + contents->pack_start(buttonsHBox); + } + + setDefaults(); + + show_all_children(); + + desktopChangeConn = deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &PixelArtDialogImpl::setTargetDesktop) ); + deskTrack.connect(GTK_WIDGET(gobj())); + + signalResponse().connect(sigc::mem_fun(*this, &PixelArtDialogImpl::responseCallback)); +} + +void PixelArtDialogImpl::responseCallback(int response_id) +{ + if (response_id == GTK_RESPONSE_OK) { + vectorize(); + } else if (response_id == GTK_RESPONSE_CANCEL) { + // TODO + } else if (response_id == GTK_RESPONSE_HELP) { + setDefaults(); + } else { + hide(); + return; + } +} + +Tracer::Kopf2011::Options PixelArtDialogImpl::options() +{ + Tracer::Kopf2011::Options options; + + options.curvesMultiplier = curvesMultiplierSpinner.get_value(); + options.islandsWeight = islandsWeightSpinner.get_value_as_int(); + options.sparsePixelsMultiplier = sparsePixelsMultiplierSpinner.get_value(); + options.sparsePixelsRadius = sparsePixelsRadiusSpinner.get_value_as_int(); + options.optimize = optimizeRadioButton.get_active(); + + options.nthreads = Inkscape::Preferences::get() + ->getIntLimited("/options/threading/numthreads", +#ifdef HAVE_OPENMP + omp_get_num_procs(), +#else + 1, +#endif // HAVE_OPENMP + 1, 256); + + return options; +} + +void PixelArtDialogImpl::vectorize() +{ + Inkscape::MessageStack *msgStack = desktop->messageStack(); + + if ( !desktop->selection ) { + char *msg = _("Select an image to trace"); + msgStack->flash(Inkscape::ERROR_MESSAGE, msg); + return; + } + + bool found = false; + + for ( GSList const *list = desktop->selection->itemList() ; list + ; list = list->next ) { + if ( !SP_IS_IMAGE(list->data) ) + continue; + + found = true; + + processLibdepixelize(SP_IMAGE(list->data)); + } + + if ( !found ) { + char *msg = _("Select an image to trace"); + msgStack->flash(Inkscape::ERROR_MESSAGE, msg); + return; + } + + DocumentUndo::done(desktop->doc(), SP_VERB_SELECTION_PIXEL_ART, + _("Trace pixel art")); + + // Flush pending updates + desktop->doc()->ensureUpToDate(); +} + +void PixelArtDialogImpl::processLibdepixelize(SPImage *img) +{ + Tracer::Splines out; + + if ( voronoiRadioButton.get_active() ) { + out = Tracer::Kopf2011::to_voronoi(Glib::wrap(img->pixbuf, true), + options()); + } else { + out = Tracer::Kopf2011::to_splines(Glib::wrap(img->pixbuf, true), + options()); + } + + Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); + Inkscape::XML::Node *group = xml_doc->createElement("svg:g"); + + for ( Tracer::Splines::iterator it = out.begin(), end = out.end() + ; it != end ; ++it ) { + Inkscape::XML::Node *repr = xml_doc->createElement("svg:path"); + + { + SPCSSAttr *css = sp_repr_css_attr_new(); + + { + gchar b[64]; + sp_svg_write_color(b, sizeof(b), + SP_RGBA32_U_COMPOSE(unsigned(it->rgba[2]), + unsigned(it->rgba[1]), + unsigned(it->rgba[0]), + unsigned(it->rgba[3]))); + + sp_repr_css_set_property(css, "fill", b); + } + + { + Inkscape::CSSOStringStream osalpha; + osalpha << float(it->rgba[3]) / 255.; + sp_repr_css_set_property(css, "fill-opacity", + osalpha.str().c_str()); + } + + sp_repr_css_set(repr, css, "style"); + sp_repr_css_attr_unref(css); + } + + gchar *str = sp_svg_write_path(move(it->pathVector)); + repr->setAttribute("d", str); + g_free(str); + + group->appendChild(repr); + + Inkscape::GC::release(repr); + } + + { + group->setAttribute("transform", + (std::string("translate(") + + sp_svg_length_write_with_units(img->x) + + ' ' + sp_svg_length_write_with_units(img->y) + + ')').c_str()); + } + + desktop->currentLayer()->appendChildRepr(group); + + Inkscape::GC::release(group); +} + +void PixelArtDialogImpl::setDefaults() +{ + ignorePreview = true; + + curvesMultiplierSpinner.set_value(Tracer::Kopf2011::Options + ::CURVES_MULTIPLIER); + + islandsWeightSpinner.set_value(Tracer::Kopf2011::Options::ISLANDS_WEIGHT); + + sparsePixelsRadiusSpinner.set_value(Tracer::Kopf2011::Options + ::SPARSE_PIXELS_RADIUS); + + sparsePixelsMultiplierSpinner.set_value(Tracer::Kopf2011::Options + ::SPARSE_PIXELS_MULTIPLIER); + + optimizeRadioButton.set_active(); + + ignorePreview = false; + + if ( pendingPreview ) + updatePreview(); +} + +void PixelArtDialogImpl::updatePreview() +{ + if ( ignorePreview ) { + pendingPreview = true; + return; + } + + // TODO: update preview + pendingPreview = false; +} + +/** + * Factory method. Use this to create a new PixelArtDialog + */ +PixelArtDialog &PixelArtDialog::getInstance() +{ + PixelArtDialog *dialog = new PixelArtDialogImpl(); + return *dialog; +} + +PixelArtDialogImpl::~PixelArtDialogImpl() +{ + desktopChangeConn.disconnect(); +} + + +} //namespace Dialog +} //namespace UI +} //namespace Inkscape + +/* + 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:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/dialog/pixelartdialog.h b/src/ui/dialog/pixelartdialog.h new file mode 100644 index 000000000..b2be4b077 --- /dev/null +++ b/src/ui/dialog/pixelartdialog.h @@ -0,0 +1,69 @@ +/** @file + * @brief Bitmap tracing settings dialog + */ +/* Authors: + * Bob Jamison + * Vinícius dos Santos Oliveira + * Other dudes from The Inkscape Organization + * + * Copyright (C) 2004, 2005 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifndef __PIXELARTDIALOG_H__ +#define __PIXELARTDIALOG_H__ + +#include "ui/widget/panel.h" +#include "verbs.h" + +namespace Inkscape { +namespace UI { +namespace Dialog { + + +/** + * A dialog that displays log messages + */ +class PixelArtDialog : public UI::Widget::Panel +{ + +public: + + /** + * Constructor + */ + PixelArtDialog() : + UI::Widget::Panel("", "/dialogs/pixelart", SP_VERB_SELECTION_PIXEL_ART) + {} + + + /** + * Factory method + */ + static PixelArtDialog &getInstance(); + + /** + * Destructor + */ + virtual ~PixelArtDialog() {}; + + +}; + + +} //namespace Dialog +} //namespace UI +} //namespace Inkscape + +#endif /* __PIXELARTDIALOGDIALOG_H__ */ + +/* + 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:fileencoding=utf-8:textwidth=99 : -- cgit v1.2.3 From d956a27f7d3b8fbe82bc5ef3d991d963db79fedf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20dos=20Santos=20Oliveira?= Date: Fri, 13 Sep 2013 03:59:44 -0300 Subject: Removing obvious comments from PixelArtDialog (bzr r12506.1.2) --- src/ui/dialog/pixelartdialog.h | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/pixelartdialog.h b/src/ui/dialog/pixelartdialog.h index b2be4b077..165cb8699 100644 --- a/src/ui/dialog/pixelartdialog.h +++ b/src/ui/dialog/pixelartdialog.h @@ -29,25 +29,14 @@ class PixelArtDialog : public UI::Widget::Panel public: - /** - * Constructor - */ PixelArtDialog() : - UI::Widget::Panel("", "/dialogs/pixelart", SP_VERB_SELECTION_PIXEL_ART) - {} + UI::Widget::Panel("", "/dialogs/pixelart", SP_VERB_SELECTION_PIXEL_ART) + {} - /** - * Factory method - */ static PixelArtDialog &getInstance(); - /** - * Destructor - */ virtual ~PixelArtDialog() {}; - - }; -- cgit v1.2.3 From 5cf6efefbfd06d723973b6517b442f0ee64416b7 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sun, 15 Sep 2013 02:43:49 +0200 Subject: Added runtime check in SP_-cast macros. (bzr r11608.1.123) --- src/ui/tool/node-tool.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/tool/node-tool.h b/src/ui/tool/node-tool.h index 779cf98e6..ce022cec6 100644 --- a/src/ui/tool/node-tool.h +++ b/src/ui/tool/node-tool.h @@ -30,7 +30,7 @@ namespace Inkscape { } } -#define INK_NODE_TOOL(obj) ((InkNodeTool*)obj) +#define INK_NODE_TOOL(obj) (dynamic_cast((SPEventContext*)obj)) #define INK_IS_NODE_TOOL(obj) (dynamic_cast((const SPEventContext*)obj)) class InkNodeTool : public SPEventContext { -- cgit v1.2.3 From 509ef3751bec8b1d4416e9c136eb5d2776d0c63a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20dos=20Santos=20Oliveira?= Date: Thu, 19 Sep 2013 01:52:47 -0300 Subject: Updating libdepixelize integration to use new Inkscape::Pixbuf interface. Fixes build issue introduced in last commit. (bzr r12534) --- src/ui/dialog/pixelartdialog.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/pixelartdialog.cpp b/src/ui/dialog/pixelartdialog.cpp index 6f0845ada..16d3c079d 100644 --- a/src/ui/dialog/pixelartdialog.cpp +++ b/src/ui/dialog/pixelartdialog.cpp @@ -37,6 +37,7 @@ #include "preferences.h" #include "sp-image.h" +#include "display/cairo-utils.h" #include "libdepixelize/kopftracer2011.h" #include #include "document.h" @@ -363,12 +364,13 @@ void PixelArtDialogImpl::processLibdepixelize(SPImage *img) { Tracer::Splines out; + Glib::RefPtr pixbuf + = Glib::wrap(img->pixbuf->getPixbufRaw(), true); + if ( voronoiRadioButton.get_active() ) { - out = Tracer::Kopf2011::to_voronoi(Glib::wrap(img->pixbuf, true), - options()); + out = Tracer::Kopf2011::to_voronoi(pixbuf, options()); } else { - out = Tracer::Kopf2011::to_splines(Glib::wrap(img->pixbuf, true), - options()); + out = Tracer::Kopf2011::to_splines(pixbuf, options()); } Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); -- cgit v1.2.3 From 2454f5dff9f989548b15154707d011b76ac76457 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20dos=20Santos=20Oliveira?= Date: Thu, 19 Sep 2013 01:58:26 -0300 Subject: Fixing colors in libdepixelize integration output. (bzr r12535) --- src/ui/dialog/pixelartdialog.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/pixelartdialog.cpp b/src/ui/dialog/pixelartdialog.cpp index 16d3c079d..ef181b357 100644 --- a/src/ui/dialog/pixelartdialog.cpp +++ b/src/ui/dialog/pixelartdialog.cpp @@ -386,9 +386,9 @@ void PixelArtDialogImpl::processLibdepixelize(SPImage *img) { gchar b[64]; sp_svg_write_color(b, sizeof(b), - SP_RGBA32_U_COMPOSE(unsigned(it->rgba[2]), + SP_RGBA32_U_COMPOSE(unsigned(it->rgba[0]), unsigned(it->rgba[1]), - unsigned(it->rgba[0]), + unsigned(it->rgba[2]), unsigned(it->rgba[3]))); sp_repr_css_set_property(css, "fill", b); -- cgit v1.2.3 From 0fea1d0d5af42e2dadf5dd3e4df779e68b7c6dfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20dos=20Santos=20Oliveira?= Date: Thu, 19 Sep 2013 17:43:38 -0300 Subject: Removing redundant "include config.h" (bzr r12545) --- src/ui/dialog/pixelartdialog.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/pixelartdialog.cpp b/src/ui/dialog/pixelartdialog.cpp index ef181b357..24c1ec37f 100644 --- a/src/ui/dialog/pixelartdialog.cpp +++ b/src/ui/dialog/pixelartdialog.cpp @@ -16,10 +16,6 @@ # include #endif -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - #include "pixelartdialog.h" #include #include -- cgit v1.2.3 From 47f1c1ee40b8185001b047c2a7bc2ca58e40ab0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20dos=20Santos=20Oliveira?= Date: Thu, 19 Sep 2013 18:14:28 -0300 Subject: Show warning when input image of Trace Pixel Art dialog is too large. (bzr r12546) --- src/ui/dialog/pixelartdialog.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/ui') diff --git a/src/ui/dialog/pixelartdialog.cpp b/src/ui/dialog/pixelartdialog.cpp index 24c1ec37f..e07cbccb5 100644 --- a/src/ui/dialog/pixelartdialog.cpp +++ b/src/ui/dialog/pixelartdialog.cpp @@ -19,6 +19,7 @@ #include "pixelartdialog.h" #include #include +#include #include //for GTK_RESPONSE* types #include @@ -363,6 +364,17 @@ void PixelArtDialogImpl::processLibdepixelize(SPImage *img) Glib::RefPtr pixbuf = Glib::wrap(img->pixbuf->getPixbufRaw(), true); + if ( pixbuf->get_width() > 256 || pixbuf->get_height() > 256 ) { + char *msg = _("Image looks too big. Process may take a while and is" + " wise to save your document before continue." + "\n\nContinue the procedure (without saving)?"); + Gtk::MessageDialog dialog(msg, false, Gtk::MESSAGE_WARNING, + Gtk::BUTTONS_OK_CANCEL, true); + + if ( dialog.run() != Gtk::RESPONSE_OK ) + return; + } + if ( voronoiRadioButton.get_active() ) { out = Tracer::Kopf2011::to_voronoi(pixbuf, options()); } else { -- cgit v1.2.3 From 044c350e4c0e27e97cb39dd6dbb25e7655c302d1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 20 Sep 2013 07:38:24 +1000 Subject: updates for cmake (bzr r12547) --- src/ui/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 233e01862..24324c874 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -175,6 +175,7 @@ set(ui_SRC dialog/object-properties.h dialog/ocaldialogs.h dialog/panel-dialog.h + dialog/pixelartdialog.h dialog/print-colors-preview-dialog.h dialog/print.h @@ -183,7 +184,7 @@ set(ui_SRC dialog/swatches.h dialog/symbols.h dialog/template-load-tab.h - dialog/template-widget.h + dialog/template-widget.h dialog/text-edit.h dialog/tile.h dialog/tracedialog.h -- cgit v1.2.3