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 bd77ef25e9161acb007323f851ba77e106036939 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Mon, 1 Jul 2013 23:40:52 -0400 Subject: Ported "ui/widget/page-sizer.cpp" and "document.cpp" to "Util::Unit" class. (bzr r12380.1.4) --- src/ui/widget/page-sizer.cpp | 159 +++++++++++++++++++++---------------------- src/ui/widget/page-sizer.h | 9 +-- 2 files changed, 83 insertions(+), 85 deletions(-) (limited to 'src/ui') diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index fa3f8e3a1..cceb3f600 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -36,7 +36,7 @@ #include "document.h" #include "desktop.h" #include "helper/action.h" -#include "helper/units.h" +#include "util/units.h" #include "inkscape.h" #include "sp-namedview.h" #include "sp-root.h" @@ -46,6 +46,8 @@ #include "xml/node.h" #include "xml/repr.h" +static Inkscape::Util::UnitTable unit_table; + using std::pair; namespace Inkscape { @@ -95,7 +97,7 @@ struct PaperSizeRec { char const * const name; //name double const smaller; //lesser dimension double const larger; //greater dimension - SPUnitId const unit; //units + Inkscape::Util::Unit const unit; //units }; // list of page formats that should be in landscape automatically @@ -113,31 +115,31 @@ fill_landscape_papers() { } static PaperSizeRec const inkscape_papers[] = { - { "A4", 210, 297, SP_UNIT_MM }, - { "US Letter", 8.5, 11, SP_UNIT_IN }, - { "US Legal", 8.5, 14, SP_UNIT_IN }, - { "US Executive", 7.25, 10.5, SP_UNIT_IN }, - { "A0", 841, 1189, SP_UNIT_MM }, - { "A1", 594, 841, SP_UNIT_MM }, - { "A2", 420, 594, SP_UNIT_MM }, - { "A3", 297, 420, SP_UNIT_MM }, - { "A5", 148, 210, SP_UNIT_MM }, - { "A6", 105, 148, SP_UNIT_MM }, - { "A7", 74, 105, SP_UNIT_MM }, - { "A8", 52, 74, SP_UNIT_MM }, - { "A9", 37, 52, SP_UNIT_MM }, - { "A10", 26, 37, SP_UNIT_MM }, - { "B0", 1000, 1414, SP_UNIT_MM }, - { "B1", 707, 1000, SP_UNIT_MM }, - { "B2", 500, 707, SP_UNIT_MM }, - { "B3", 353, 500, SP_UNIT_MM }, - { "B4", 250, 353, SP_UNIT_MM }, - { "B5", 176, 250, SP_UNIT_MM }, - { "B6", 125, 176, SP_UNIT_MM }, - { "B7", 88, 125, SP_UNIT_MM }, - { "B8", 62, 88, SP_UNIT_MM }, - { "B9", 44, 62, SP_UNIT_MM }, - { "B10", 31, 44, SP_UNIT_MM }, + { "A4", 210, 297, unit_table.getUnit("mm") }, + { "US Letter", 8.5, 11, unit_table.getUnit("in") }, + { "US Legal", 8.5, 14, unit_table.getUnit("in") }, + { "US Executive", 7.25, 10.5, unit_table.getUnit("in") }, + { "A0", 841, 1189, unit_table.getUnit("mm") }, + { "A1", 594, 841, unit_table.getUnit("mm") }, + { "A2", 420, 594, unit_table.getUnit("mm") }, + { "A3", 297, 420, unit_table.getUnit("mm") }, + { "A5", 148, 210, unit_table.getUnit("mm") }, + { "A6", 105, 148, unit_table.getUnit("mm") }, + { "A7", 74, 105, unit_table.getUnit("mm") }, + { "A8", 52, 74, unit_table.getUnit("mm") }, + { "A9", 37, 52, unit_table.getUnit("mm") }, + { "A10", 26, 37, unit_table.getUnit("mm") }, + { "B0", 1000, 1414, unit_table.getUnit("mm") }, + { "B1", 707, 1000, unit_table.getUnit("mm") }, + { "B2", 500, 707, unit_table.getUnit("mm") }, + { "B3", 353, 500, unit_table.getUnit("mm") }, + { "B4", 250, 353, unit_table.getUnit("mm") }, + { "B5", 176, 250, unit_table.getUnit("mm") }, + { "B6", 125, 176, unit_table.getUnit("mm") }, + { "B7", 88, 125, unit_table.getUnit("mm") }, + { "B8", 62, 88, unit_table.getUnit("mm") }, + { "B9", 44, 62, unit_table.getUnit("mm") }, + { "B10", 31, 44, unit_table.getUnit("mm") }, @@ -149,63 +151,63 @@ static PaperSizeRec const inkscape_papers[] = { don't know what D and E series are used for. */ - { "C0", 917, 1297, SP_UNIT_MM }, - { "C1", 648, 917, SP_UNIT_MM }, - { "C2", 458, 648, SP_UNIT_MM }, - { "C3", 324, 458, SP_UNIT_MM }, - { "C4", 229, 324, SP_UNIT_MM }, - { "C5", 162, 229, SP_UNIT_MM }, - { "C6", 114, 162, SP_UNIT_MM }, - { "C7", 81, 114, SP_UNIT_MM }, - { "C8", 57, 81, SP_UNIT_MM }, - { "C9", 40, 57, SP_UNIT_MM }, - { "C10", 28, 40, SP_UNIT_MM }, - { "D1", 545, 771, SP_UNIT_MM }, - { "D2", 385, 545, SP_UNIT_MM }, - { "D3", 272, 385, SP_UNIT_MM }, - { "D4", 192, 272, SP_UNIT_MM }, - { "D5", 136, 192, SP_UNIT_MM }, - { "D6", 96, 136, SP_UNIT_MM }, - { "D7", 68, 96, SP_UNIT_MM }, - { "E3", 400, 560, SP_UNIT_MM }, - { "E4", 280, 400, SP_UNIT_MM }, - { "E5", 200, 280, SP_UNIT_MM }, - { "E6", 140, 200, SP_UNIT_MM }, + { "C0", 917, 1297, unit_table.getUnit("mm") }, + { "C1", 648, 917, unit_table.getUnit("mm") }, + { "C2", 458, 648, unit_table.getUnit("mm") }, + { "C3", 324, 458, unit_table.getUnit("mm") }, + { "C4", 229, 324, unit_table.getUnit("mm") }, + { "C5", 162, 229, unit_table.getUnit("mm") }, + { "C6", 114, 162, unit_table.getUnit("mm") }, + { "C7", 81, 114, unit_table.getUnit("mm") }, + { "C8", 57, 81, unit_table.getUnit("mm") }, + { "C9", 40, 57, unit_table.getUnit("mm") }, + { "C10", 28, 40, unit_table.getUnit("mm") }, + { "D1", 545, 771, unit_table.getUnit("mm") }, + { "D2", 385, 545, unit_table.getUnit("mm") }, + { "D3", 272, 385, unit_table.getUnit("mm") }, + { "D4", 192, 272, unit_table.getUnit("mm") }, + { "D5", 136, 192, unit_table.getUnit("mm") }, + { "D6", 96, 136, unit_table.getUnit("mm") }, + { "D7", 68, 96, unit_table.getUnit("mm") }, + { "E3", 400, 560, unit_table.getUnit("mm") }, + { "E4", 280, 400, unit_table.getUnit("mm") }, + { "E5", 200, 280, unit_table.getUnit("mm") }, + { "E6", 140, 200, unit_table.getUnit("mm") }, //#endif - { "CSE", 462, 649, SP_UNIT_PT }, - { "US #10 Envelope", 4.125, 9.5, SP_UNIT_IN }, + { "CSE", 462, 649, unit_table.getUnit("pt") }, + { "US #10 Envelope", 4.125, 9.5, unit_table.getUnit("in") }, /* See http://www.hbp.com/content/PCR_envelopes.cfm for a much larger list of US envelope sizes. */ - { "DL Envelope", 110, 220, SP_UNIT_MM }, - { "Ledger/Tabloid", 11, 17, SP_UNIT_IN }, + { "DL Envelope", 110, 220, unit_table.getUnit("mm") }, + { "Ledger/Tabloid", 11, 17, unit_table.getUnit("in") }, /* Note that `Folio' (used in QPrinter/KPrinter) is deliberately absent from this list, as it means different sizes to different people: different people may expect the width to be either 8, 8.25 or 8.5 inches, and the height to be either 13 or 13.5 inches, even restricting our interpretation to foolscap folio. If you wish to introduce a folio-like page size to the list, then please consider using a name more specific than just `Folio' or `Foolscap Folio'. */ - { "Banner 468x60", 60, 468, SP_UNIT_PX }, - { "Icon 16x16", 16, 16, SP_UNIT_PX }, - { "Icon 32x32", 32, 32, SP_UNIT_PX }, - { "Icon 48x48", 48, 48, SP_UNIT_PX }, + { "Banner 468x60", 60, 468, unit_table.getUnit("px") }, + { "Icon 16x16", 16, 16, unit_table.getUnit("px") }, + { "Icon 32x32", 32, 32, unit_table.getUnit("px") }, + { "Icon 48x48", 48, 48, unit_table.getUnit("px") }, /* business cards */ - { "Business Card (ISO 7810)", 53.98, 85.60, SP_UNIT_MM }, - { "Business Card (US)", 2, 3.5, SP_UNIT_IN }, - { "Business Card (Europe)", 55, 85, SP_UNIT_MM }, - { "Business Card (Aus/NZ)", 55, 90, SP_UNIT_MM }, + { "Business Card (ISO 7810)", 53.98, 85.60, unit_table.getUnit("mm") }, + { "Business Card (US)", 2, 3.5, unit_table.getUnit("in") }, + { "Business Card (Europe)", 55, 85, unit_table.getUnit("mm") }, + { "Business Card (Aus/NZ)", 55, 90, unit_table.getUnit("mm") }, // Start Arch Series List - { "Arch A", 9, 12, SP_UNIT_IN }, // 229 x 305 mm - { "Arch B", 12, 18, SP_UNIT_IN }, // 305 x 457 mm - { "Arch C", 18, 24, SP_UNIT_IN }, // 457 x 610 mm - { "Arch D", 24, 36, SP_UNIT_IN }, // 610 x 914 mm - { "Arch E", 36, 48, SP_UNIT_IN }, // 914 x 1219 mm - { "Arch E1", 30, 42, SP_UNIT_IN }, // 762 x 1067 mm + { "Arch A", 9, 12, unit_table.getUnit("in") }, // 229 x 305 mm + { "Arch B", 12, 18, unit_table.getUnit("in") }, // 305 x 457 mm + { "Arch C", 18, 24, unit_table.getUnit("in") }, // 457 x 610 mm + { "Arch D", 24, 36, unit_table.getUnit("in") }, // 610 x 914 mm + { "Arch E", 36, 48, unit_table.getUnit("in") }, // 914 x 1219 mm + { "Arch E1", 30, 42, unit_table.getUnit("in") }, // 762 x 1067 mm /* * The above list of Arch sizes were taken from the following site: @@ -216,7 +218,7 @@ static PaperSizeRec const inkscape_papers[] = { * September 2009 - DAK */ - { NULL, 0, 0, SP_UNIT_PX }, + { NULL, 0, 0, unit_table.getUnit("px") }, }; @@ -226,7 +228,7 @@ static PaperSizeRec const inkscape_papers[] = { //######################################################################## //The default unit for this widget and its calculations -static const SPUnit _px_unit = sp_unit_get_by_id (SP_UNIT_PX); +static Inkscape::Util::Unit _px_unit = unit_table.getUnit("px"); /** @@ -279,12 +281,7 @@ PageSizer::PageSizer(Registry & _wr) char formatBuf[80]; snprintf(formatBuf, 79, "%0.1f x %0.1f", p->smaller, p->larger); Glib::ustring desc = formatBuf; - if (p->unit == SP_UNIT_IN) - desc.append(" in"); - else if (p->unit == SP_UNIT_MM) - desc.append(" mm"); - else if (p->unit == SP_UNIT_PX) - desc.append(" px"); + desc.append(" " + p->unit.abbr); PaperSize paper(name, p->smaller, p->larger, p->unit); _paperSizeTable[name] = paper; Gtk::TreeModel::Row row = *(_paperSizeListStore->append()); @@ -568,9 +565,9 @@ PageSizer::find_paper_size (double w, double h) const for (iter = _paperSizeTable.begin() ; iter != _paperSizeTable.end() ; ++iter) { PaperSize paper = iter->second; - SPUnit const &i_unit = sp_unit_get_by_id(paper.unit); - double smallX = sp_units_get_pixels(paper.smaller, i_unit); - double largeX = sp_units_get_pixels(paper.larger, i_unit); + Inkscape::Util::Unit const &i_unit = paper.unit; + double smallX = Inkscape::Util::Quantity::convert(paper.smaller, &i_unit, &_px_unit); + double largeX = Inkscape::Util::Quantity::convert(paper.larger, &i_unit, &_px_unit); g_return_val_if_fail(smallX <= largeX, _paperSizeListStore->children().end()); @@ -661,9 +658,9 @@ PageSizer::on_paper_size_list_changed() _landscape = _landscapeButton.get_active(); } - SPUnit const &src_unit = sp_unit_get_by_id (paper.unit); - sp_convert_distance (&w, &src_unit, &_px_unit); - sp_convert_distance (&h, &src_unit, &_px_unit); + Inkscape::Util::Unit const &src_unit = paper.unit; + w = Inkscape::Util::Quantity::convert(w, &src_unit, &_px_unit); + h = Inkscape::Util::Quantity::convert(h, &src_unit, &_px_unit); if (_landscape) setDim (h, w, false); diff --git a/src/ui/widget/page-sizer.h b/src/ui/widget/page-sizer.h index d1fbb56e0..fc8edeeac 100644 --- a/src/ui/widget/page-sizer.h +++ b/src/ui/widget/page-sizer.h @@ -18,7 +18,7 @@ #include "ui/widget/registered-widget.h" #include -#include "helper/units.h" +#include "util/units.h" #include #include @@ -64,7 +64,7 @@ public: PaperSize(const Glib::ustring &nameArg, double smallerArg, double largerArg, - SPUnitId unitArg) + Inkscape::Util::Unit unitArg) { name = nameArg; smaller = smallerArg; @@ -108,7 +108,7 @@ public: /** * The units (px, pt, mm, etc) of this specification */ - SPUnitId unit; + Inkscape::Util::Unit unit; private: @@ -117,7 +117,8 @@ private: name = ""; smaller = 0.0; larger = 0.0; - unit = SP_UNIT_PX; + static Inkscape::Util::UnitTable unit_table; + unit = unit_table.getUnit("px"); } void assign(const PaperSize &other) -- cgit v1.2.3 From fdb68963cec5ddbd3eef111f4c95b7e049aa839c Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Tue, 2 Jul 2013 17:37:42 +0200 Subject: Adding NewFromTemplate to the Inkscape menu (bzr r12379.2.5) --- src/ui/dialog/Makefile_insert | 6 ++ src/ui/dialog/new-from-template.cpp | 42 +++++++++++ src/ui/dialog/new-from-template.h | 31 +++++++++ src/ui/dialog/static-template-load-tab.cpp | 47 +++++++++++++ src/ui/dialog/static-template-load-tab.h | 33 +++++++++ src/ui/dialog/template-load-tab.cpp | 107 +++++++++++++++++++++++++++++ src/ui/dialog/template-load-tab.h | 59 ++++++++++++++++ 7 files changed, 325 insertions(+) create mode 100644 src/ui/dialog/new-from-template.cpp create mode 100644 src/ui/dialog/new-from-template.h create mode 100644 src/ui/dialog/static-template-load-tab.cpp create mode 100644 src/ui/dialog/static-template-load-tab.h create mode 100644 src/ui/dialog/template-load-tab.cpp create mode 100644 src/ui/dialog/template-load-tab.h (limited to 'src/ui') diff --git a/src/ui/dialog/Makefile_insert b/src/ui/dialog/Makefile_insert index 580b47522..4a34cc71c 100644 --- a/src/ui/dialog/Makefile_insert +++ b/src/ui/dialog/Makefile_insert @@ -70,6 +70,8 @@ ink_common_sources += \ ui/dialog/memory.h \ ui/dialog/messages.cpp \ ui/dialog/messages.h \ + ui/dialog/new-from-template.cpp \ + ui/dialog/new-from-template.h \ ui/dialog/ocaldialogs.cpp \ ui/dialog/ocaldialogs.h \ ui/dialog/object-attributes.cpp \ @@ -85,12 +87,16 @@ ink_common_sources += \ ui/dialog/scriptdialog.h \ ui/dialog/spellcheck.cpp \ ui/dialog/spellcheck.h \ + ui/dialog/static-template-load-tab.cpp \ + ui/dialog/static-template-load-tab.h \ ui/dialog/svg-fonts-dialog.cpp \ ui/dialog/svg-fonts-dialog.h \ ui/dialog/swatches.cpp \ ui/dialog/swatches.h \ ui/dialog/symbols.cpp \ ui/dialog/symbols.h \ + ui/dialog/template-load-tab.cpp \ + ui/dialog/template-load-tab.h \ ui/dialog/text-edit.cpp \ ui/dialog/text-edit.h \ ui/dialog/tile.cpp \ diff --git a/src/ui/dialog/new-from-template.cpp b/src/ui/dialog/new-from-template.cpp new file mode 100644 index 000000000..fc590d199 --- /dev/null +++ b/src/ui/dialog/new-from-template.cpp @@ -0,0 +1,42 @@ +#include "new-from-template.h" +#include "gtkmm/alignment.h" + +namespace Inkscape { +namespace UI { + + +NewFromTemplate::NewFromTemplate() + : _create_template_button("Create from template") +{ + set_title("New From Template"); + resize(400, 250); + + get_vbox()->pack_start(_main_widget); + _main_widget.append_page(_tab1, "Static Templates"); + _main_widget.append_page(_tab2, "Procedural Templates"); + + Gtk::Alignment *align; + align = manage(new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER, 0.0, 0.0)); + get_vbox()->pack_end(*align, Gtk::PACK_SHRINK, 5); + align->add(_create_template_button); + + _create_template_button.signal_pressed().connect( + sigc::mem_fun(*this, &NewFromTemplate::_createFromTemplate)); + + show_all(); +} + + +void NewFromTemplate::_createFromTemplate() +{ + if ( _main_widget.get_current_page() == 0 ) { + _tab1.createTemplate(); + } else { + _tab2.createTemplate(); + } + + response(0); +} + +} +} diff --git a/src/ui/dialog/new-from-template.h b/src/ui/dialog/new-from-template.h new file mode 100644 index 000000000..ef3cbce18 --- /dev/null +++ b/src/ui/dialog/new-from-template.h @@ -0,0 +1,31 @@ +#ifndef INKSCAPE_SEEN_UI_DIALOG_NEW_FROM_TEMPLATE_H +#define INKSCAPE_SEEN_UI_DIALOG_NEW_FROM_TEMPLATE_H + +#include +#include +#include + +#include "template-load-tab.h" +#include "static-template-load-tab.h" + +namespace Inkscape { +namespace UI { + + +class NewFromTemplate : public Gtk::Dialog +{ +public: + NewFromTemplate(); + +private: + Gtk::Notebook _main_widget; + Gtk::Button _create_template_button; + StaticTemplateLoadTab _tab1; + TemplateLoadTab _tab2; + + void _createFromTemplate(); +}; + +} +} +#endif diff --git a/src/ui/dialog/static-template-load-tab.cpp b/src/ui/dialog/static-template-load-tab.cpp new file mode 100644 index 000000000..83ff32e52 --- /dev/null +++ b/src/ui/dialog/static-template-load-tab.cpp @@ -0,0 +1,47 @@ +#include +#include +#include +#include + +#include "static-template-load-tab.h" + +namespace Inkscape { +namespace UI { + + +StaticTemplateLoadTab::StaticTemplateLoadTab() + : _more_info_button("More info") + , _preview_image("preview.png") + , _short_description_label("Short description - I like trains. ad asda asd asdweqe gdfg") + , _template_name_label("Template_name") + , _template_author_label("by template_author") +{ + _template_info_column.pack_start(_template_name_label, Gtk::PACK_SHRINK, 4); + _template_info_column.pack_start(_template_author_label, Gtk::PACK_SHRINK, 0); + _template_info_column.pack_start(_preview_image, Gtk::PACK_SHRINK, 15); + _template_info_column.pack_start(_short_description_label, Gtk::PACK_SHRINK, 4); + + _short_description_label.set_line_wrap(true); + _short_description_label.set_size_request(200); + + Gtk::Alignment *align; + align = manage(new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER, 0.0, 0.0)); + _template_info_column.pack_start(*align, Gtk::PACK_SHRINK, 5); + align->add(_more_info_button); +} + + +void StaticTemplateLoadTab::createTemplate() +{ + std::cout << "Static template\n"; +} + + +void StaticTemplateLoadTab::_displayTemplateInfo() +{ + TemplateLoadTab::_displayTemplateInfo(); + _template_name_label.set_text(_current_template); +} + +} +} diff --git a/src/ui/dialog/static-template-load-tab.h b/src/ui/dialog/static-template-load-tab.h new file mode 100644 index 000000000..651f146a0 --- /dev/null +++ b/src/ui/dialog/static-template-load-tab.h @@ -0,0 +1,33 @@ +#ifndef INKSCAPE_SEEN_UI_DIALOG_STATIC_TEMPLATE_LOAD_TAB_H +#define INKSCAPE_SEEN_UI_DIALOG_STATIC_TEMPLATE_LOAD_TAB_H + +#include +#include +#include + +#include "template-load-tab.h" + +namespace Inkscape { +namespace UI { + + +class StaticTemplateLoadTab : public TemplateLoadTab +{ +public: + StaticTemplateLoadTab(); + virtual void createTemplate(); + +protected: + virtual void _displayTemplateInfo(); + + Gtk::Button _more_info_button; + Gtk::Label _short_description_label; + Gtk::Label _template_author_label; + Gtk::Label _template_name_label; + Gtk::Image _preview_image; +}; + +} +} + +#endif diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp new file mode 100644 index 000000000..a7b5e63f3 --- /dev/null +++ b/src/ui/dialog/template-load-tab.cpp @@ -0,0 +1,107 @@ +#include +#include + +#include "template-load-tab.h" + +namespace Inkscape { +namespace UI { + + +TemplateLoadTab::TemplateLoadTab() + : _keywords_combo(true) +{ + set_border_width(10); + + Gtk::Label *title; + title = manage(new Gtk::Label("Search Tags:")); + _templates_column.pack_start(*title, Gtk::PACK_SHRINK, 10); + + _templates_column.pack_start(_keywords_combo, Gtk::PACK_SHRINK, 0); + + title = manage(new Gtk::Label("Templates")); + _templates_column.pack_start(*title, Gtk::PACK_SHRINK, 10); + + title = manage(new Gtk::Label("Selected template")); + _template_info_column.pack_start(*title, Gtk::PACK_SHRINK, 10); + + _initLists(); + + add(_main_box); + _main_box.pack_start(_templates_column, Gtk::PACK_SHRINK, 20); + _main_box.pack_start(_template_info_column, Gtk::PACK_EXPAND_WIDGET, 10); + + _templates_column.pack_start(_templates_view, Gtk::PACK_SHRINK, 5); + + Glib::RefPtr templateSelectionRef = + _templates_view.get_selection(); + + templateSelectionRef->signal_changed().connect( + sigc::mem_fun(*this, &TemplateLoadTab::_displayTemplateInfo)); + + _keywords_combo.signal_changed().connect( + sigc::mem_fun(*this, &TemplateLoadTab::_keywordSelected)); + this->show_all(); +} + + +TemplateLoadTab::~TemplateLoadTab() +{ +} + + +void TemplateLoadTab::createTemplate() +{ + std::cout << "Default Template Tab" << std::endl; +} + + +void TemplateLoadTab::_displayTemplateInfo() +{ + Glib::RefPtr templateSelectionRef = _templates_view.get_selection(); + if (templateSelectionRef->get_selected()) { + _current_template = (*templateSelectionRef->get_selected())[_templates_columns.textValue]; + } +} + + +void TemplateLoadTab::_initKeywordsList() +{ + _keywords_combo.append_text("All"); + + for (int i = 0 ; i < 10 ; ++i) { + _keywords_combo.append_text( "Keyword" + Glib::ustring::format(i)); + } +} + + +void TemplateLoadTab::_initLists() +{ + _templates_ref = Gtk::ListStore::create(_templates_columns); + _templates_view.set_model(_templates_ref); + _templates_view.append_column("", _templates_columns.textValue); + _templates_view.set_headers_visible(false); + + _initKeywordsList(); + _refreshTemplatesList(); +} + + +void TemplateLoadTab::_keywordSelected() +{ + _current_keyword = _keywords_combo.get_active_text(); + _refreshTemplatesList(); +} + + +void TemplateLoadTab::_refreshTemplatesList() +{ + _templates_ref->clear(); + for (int i = 0 ; i < 7 ; ++i) { + Gtk::TreeModel::iterator iter = _templates_ref->append(); + Gtk::TreeModel::Row row = *iter; + row[_templates_columns.textValue] = "Template" + Glib::ustring::format(i); + } +} + +} +} diff --git a/src/ui/dialog/template-load-tab.h b/src/ui/dialog/template-load-tab.h new file mode 100644 index 000000000..a9fa7c313 --- /dev/null +++ b/src/ui/dialog/template-load-tab.h @@ -0,0 +1,59 @@ +#ifndef INKSCAPE_SEEN_UI_DIALOG_TEMPLATE_LOAD_TAB_H +#define INKSCAPE_SEEN_UI_DIALOG_TEMPLATE_LOAD_TAB_H + +#include +#include +#include +#include +#include + +namespace Inkscape { +namespace UI { + + +class TemplateLoadTab : public Gtk::Frame +{ + +public: + TemplateLoadTab(); + virtual ~TemplateLoadTab(); + virtual void createTemplate(); + +protected: + class StringModelColumns : public Gtk::TreeModelColumnRecord + { + public: + StringModelColumns() + { + add(textValue); + } + + Gtk::TreeModelColumn textValue; + }; + + Glib::ustring _current_keyword; + Glib::ustring _current_template; + + virtual void _displayTemplateInfo(); + virtual void _initKeywordsList(); + virtual void _refreshTemplatesList(); + + void _initLists(); + void _keywordSelected(); + + Gtk::HBox _main_box; + Gtk::VBox _templates_column; + Gtk::VBox _template_info_column; + + Gtk::ComboBoxText _keywords_combo; + + Gtk::TreeView _templates_view; + Glib::RefPtr _templates_ref; + StringModelColumns _templates_columns; + +}; + +} +} + +#endif -- cgit v1.2.3 From ec3d3965f0aa7444d42fc8765abbc9c3ed0916ce Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Wed, 3 Jul 2013 13:35:06 +0200 Subject: Templates menu item fixed (bzr r12379.2.6) --- src/ui/dialog/new-from-template.h | 2 +- src/ui/dialog/static-template-load-tab.cpp | 3 ++- src/ui/dialog/static-template-load-tab.h | 3 +-- src/ui/dialog/template-load-tab.cpp | 7 ++++--- 4 files changed, 8 insertions(+), 7 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/new-from-template.h b/src/ui/dialog/new-from-template.h index ef3cbce18..f8c4bbb37 100644 --- a/src/ui/dialog/new-from-template.h +++ b/src/ui/dialog/new-from-template.h @@ -1,8 +1,8 @@ #ifndef INKSCAPE_SEEN_UI_DIALOG_NEW_FROM_TEMPLATE_H #define INKSCAPE_SEEN_UI_DIALOG_NEW_FROM_TEMPLATE_H -#include #include +#include #include #include "template-load-tab.h" diff --git a/src/ui/dialog/static-template-load-tab.cpp b/src/ui/dialog/static-template-load-tab.cpp index 83ff32e52..94298bf1d 100644 --- a/src/ui/dialog/static-template-load-tab.cpp +++ b/src/ui/dialog/static-template-load-tab.cpp @@ -1,9 +1,10 @@ +#include "static-template-load-tab.h" + #include #include #include #include -#include "static-template-load-tab.h" namespace Inkscape { namespace UI { diff --git a/src/ui/dialog/static-template-load-tab.h b/src/ui/dialog/static-template-load-tab.h index 651f146a0..a1a3adf7b 100644 --- a/src/ui/dialog/static-template-load-tab.h +++ b/src/ui/dialog/static-template-load-tab.h @@ -1,12 +1,11 @@ #ifndef INKSCAPE_SEEN_UI_DIALOG_STATIC_TEMPLATE_LOAD_TAB_H #define INKSCAPE_SEEN_UI_DIALOG_STATIC_TEMPLATE_LOAD_TAB_H +#include "template-load-tab.h" #include #include #include -#include "template-load-tab.h" - namespace Inkscape { namespace UI { diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index a7b5e63f3..5d4c3a364 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -1,7 +1,7 @@ +#include "template-load-tab.h" #include #include -#include "template-load-tab.h" namespace Inkscape { namespace UI { @@ -66,10 +66,11 @@ void TemplateLoadTab::_displayTemplateInfo() void TemplateLoadTab::_initKeywordsList() { - _keywords_combo.append_text("All"); + _keywords_combo.append("All"); + // _keywords_combo for (int i = 0 ; i < 10 ; ++i) { - _keywords_combo.append_text( "Keyword" + Glib::ustring::format(i)); + _keywords_combo.append( "Keyword" + Glib::ustring::format(i)); } } -- cgit v1.2.3 From 46211dc227f62c2e71b3edfa1ffb508c9fe8e0ac Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Thu, 4 Jul 2013 16:19:38 +0200 Subject: Added loading templates into NewFromTemplate dialog. (bzr r12379.2.7) --- src/ui/dialog/new-from-template.cpp | 12 ++++++- src/ui/dialog/new-from-template.h | 4 ++- src/ui/dialog/static-template-load-tab.cpp | 20 +++++++++-- src/ui/dialog/static-template-load-tab.h | 2 ++ src/ui/dialog/template-load-tab.cpp | 57 +++++++++++++++++++++++++++--- src/ui/dialog/template-load-tab.h | 25 +++++++++++-- 6 files changed, 108 insertions(+), 12 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/new-from-template.cpp b/src/ui/dialog/new-from-template.cpp index fc590d199..b210545d1 100644 --- a/src/ui/dialog/new-from-template.cpp +++ b/src/ui/dialog/new-from-template.cpp @@ -1,5 +1,9 @@ #include "new-from-template.h" -#include "gtkmm/alignment.h" + +#include + +#include "src/file.h" + namespace Inkscape { namespace UI { @@ -38,5 +42,11 @@ void NewFromTemplate::_createFromTemplate() response(0); } +void NewFromTemplate::load_new_from_template() +{ + NewFromTemplate dl; + dl.run(); +} + } } diff --git a/src/ui/dialog/new-from-template.h b/src/ui/dialog/new-from-template.h index f8c4bbb37..e7976d685 100644 --- a/src/ui/dialog/new-from-template.h +++ b/src/ui/dialog/new-from-template.h @@ -8,6 +8,7 @@ #include "template-load-tab.h" #include "static-template-load-tab.h" + namespace Inkscape { namespace UI { @@ -15,9 +16,10 @@ namespace UI { class NewFromTemplate : public Gtk::Dialog { public: - NewFromTemplate(); + static void load_new_from_template(); private: + NewFromTemplate(); Gtk::Notebook _main_widget; Gtk::Button _create_template_button; StaticTemplateLoadTab _tab1; diff --git a/src/ui/dialog/static-template-load-tab.cpp b/src/ui/dialog/static-template-load-tab.cpp index 94298bf1d..47c7c00b9 100644 --- a/src/ui/dialog/static-template-load-tab.cpp +++ b/src/ui/dialog/static-template-load-tab.cpp @@ -5,18 +5,25 @@ #include #include +#include "src/file.h" + namespace Inkscape { namespace UI { StaticTemplateLoadTab::StaticTemplateLoadTab() - : _more_info_button("More info") + : TemplateLoadTab() + , _more_info_button("More info") , _preview_image("preview.png") , _short_description_label("Short description - I like trains. ad asda asd asdweqe gdfg") , _template_name_label("Template_name") , _template_author_label("by template_author") { + _loading_path = "/static"; + _loadTemplates(); + _initLists(); + _template_info_column.pack_start(_template_name_label, Gtk::PACK_SHRINK, 4); _template_info_column.pack_start(_template_author_label, Gtk::PACK_SHRINK, 0); _template_info_column.pack_start(_preview_image, Gtk::PACK_SHRINK, 15); @@ -34,7 +41,14 @@ StaticTemplateLoadTab::StaticTemplateLoadTab() void StaticTemplateLoadTab::createTemplate() { - std::cout << "Static template\n"; + Glib::ustring path; + if (_templates.find(_current_template) != _templates.end()){ + path = _templates[_current_template].path; + } + else + path = ""; + + sp_file_new(path); } @@ -42,6 +56,8 @@ void StaticTemplateLoadTab::_displayTemplateInfo() { TemplateLoadTab::_displayTemplateInfo(); _template_name_label.set_text(_current_template); + _template_author_label.set_text(_templates[_current_template].author); + _short_description_label.set_text(_templates[_current_template].short_description); } } diff --git a/src/ui/dialog/static-template-load-tab.h b/src/ui/dialog/static-template-load-tab.h index a1a3adf7b..a5411296d 100644 --- a/src/ui/dialog/static-template-load-tab.h +++ b/src/ui/dialog/static-template-load-tab.h @@ -2,10 +2,12 @@ #define INKSCAPE_SEEN_UI_DIALOG_STATIC_TEMPLATE_LOAD_TAB_H #include "template-load-tab.h" + #include #include #include + namespace Inkscape { namespace UI { diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index 5d4c3a364..5e3a16a3f 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -1,7 +1,14 @@ #include "template-load-tab.h" + #include #include +#include "src/interface.h" +#include "src/file.h" +#include "src/path-prefix.h" +#include "src/preferences.h" +#include "src/inkscape.h" + namespace Inkscape { namespace UI { @@ -9,6 +16,7 @@ namespace UI { TemplateLoadTab::TemplateLoadTab() : _keywords_combo(true) + , _current_keyword("") { set_border_width(10); @@ -24,8 +32,6 @@ TemplateLoadTab::TemplateLoadTab() title = manage(new Gtk::Label("Selected template")); _template_info_column.pack_start(*title, Gtk::PACK_SHRINK, 10); - _initLists(); - add(_main_box); _main_box.pack_start(_templates_column, Gtk::PACK_SHRINK, 20); _main_box.pack_start(_template_info_column, Gtk::PACK_EXPAND_WIDGET, 10); @@ -67,7 +73,6 @@ void TemplateLoadTab::_displayTemplateInfo() void TemplateLoadTab::_initKeywordsList() { _keywords_combo.append("All"); - // _keywords_combo for (int i = 0 ; i < 10 ; ++i) { _keywords_combo.append( "Keyword" + Glib::ustring::format(i)); @@ -97,12 +102,54 @@ void TemplateLoadTab::_keywordSelected() void TemplateLoadTab::_refreshTemplatesList() { _templates_ref->clear(); - for (int i = 0 ; i < 7 ; ++i) { + + for (std::map::iterator it = _templates.begin() ; it != _templates.end() ; ++it) { Gtk::TreeModel::iterator iter = _templates_ref->append(); Gtk::TreeModel::Row row = *iter; - row[_templates_columns.textValue] = "Template" + Glib::ustring::format(i); + row[_templates_columns.textValue] = it->first; } } + +void TemplateLoadTab::_loadTemplates() +{ + // user's local dir + _getTemplatesFromDir(profile_path("templates") + _loading_path); + + // system templates dir + _getTemplatesFromDir(INKSCAPE_TEMPLATESDIR + _loading_path); +} + + +TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(Glib::ustring path) +{ + TemplateData result; + result.path = path; + result.display_name = Glib::path_get_basename(path); + result.short_description = "LaLaLaLa"; + result.author = "JAASDASD"; + + return result; +} + + +void TemplateLoadTab::_getTemplatesFromDir(Glib::ustring path) +{ + if ( !Glib::file_test(path, Glib::FILE_TEST_EXISTS) || + !Glib::file_test(path, Glib::FILE_TEST_IS_DIR)) + return; + + Glib::Dir dir(path); + path += "/"; + Glib::ustring file = path + dir.read_name(); + while (file != path){ + if (Glib::str_has_suffix(file, ".svg")){ + TemplateData tmp = _processTemplateFile(file); + _templates[Glib::path_get_basename(file)] = tmp; + } + file = path + dir.read_name(); + } +} + } } diff --git a/src/ui/dialog/template-load-tab.h b/src/ui/dialog/template-load-tab.h index a9fa7c313..3edcf15eb 100644 --- a/src/ui/dialog/template-load-tab.h +++ b/src/ui/dialog/template-load-tab.h @@ -6,6 +6,9 @@ #include #include #include +#include +#include + namespace Inkscape { namespace UI { @@ -20,6 +23,15 @@ public: virtual void createTemplate(); protected: + struct TemplateData + { + Glib::ustring path; + Glib::ustring display_name; + Glib::ustring author; + Glib::ustring short_description; + std::set keywords; + }; + class StringModelColumns : public Gtk::TreeModelColumnRecord { public: @@ -33,14 +45,16 @@ protected: Glib::ustring _current_keyword; Glib::ustring _current_template; + Glib::ustring _loading_path; + std::map _templates; + virtual void _displayTemplateInfo(); virtual void _initKeywordsList(); virtual void _refreshTemplatesList(); - + void _loadTemplates(); void _initLists(); - void _keywordSelected(); - + Gtk::HBox _main_box; Gtk::VBox _templates_column; Gtk::VBox _template_info_column; @@ -50,6 +64,11 @@ protected: Gtk::TreeView _templates_view; Glib::RefPtr _templates_ref; StringModelColumns _templates_columns; + +private: + void _getTemplatesFromDir(Glib::ustring); + void _keywordSelected(); + TemplateData _processTemplateFile(Glib::ustring); }; -- cgit v1.2.3 From d04405f745da587b2a3ccca8d2ca7bf49edf2d4d Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Sat, 6 Jul 2013 11:01:59 -0400 Subject: Switch setWidth and setHeight to use Quantity and switch to forward declaration of Inkscape::Util::Quantity in document.h. (bzr r12380.1.7) --- src/ui/widget/page-sizer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/ui') diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index cceb3f600..884f9ea0a 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -480,8 +480,8 @@ PageSizer::setDim (double w, double h, bool changeList) if (SP_ACTIVE_DESKTOP && !_widgetRegistry->isUpdating()) { SPDocument *doc = sp_desktop_document(SP_ACTIVE_DESKTOP); double const old_height = doc->getHeight(); - doc->setWidth (w, &_px_unit); - doc->setHeight (h, &_px_unit); + doc->setWidth (Inkscape::Util::Quantity(w, &_px_unit)); + doc->setHeight (Inkscape::Util::Quantity(h, &_px_unit)); // The origin for the user is in the lower left corner; this point should remain stationary when // changing the page size. The SVG's origin however is in the upper left corner, so we must compensate for this Geom::Translate const vert_offset(Geom::Point(0, (old_height - h))); -- cgit v1.2.3 From cbdafaae927348aa8ef5396474535571fe989bf8 Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Mon, 8 Jul 2013 18:02:38 +0200 Subject: Coding style improvements and display bug fixes (bzr r12379.2.8) --- src/ui/dialog/new-from-template.cpp | 15 ++++- src/ui/dialog/new-from-template.h | 10 ++++ src/ui/dialog/static-template-load-tab.cpp | 36 +++++++----- src/ui/dialog/static-template-load-tab.h | 10 ++++ src/ui/dialog/template-load-tab.cpp | 91 +++++++++++++++++------------- src/ui/dialog/template-load-tab.h | 26 ++++++--- 6 files changed, 126 insertions(+), 62 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/new-from-template.cpp b/src/ui/dialog/new-from-template.cpp index b210545d1..765ec0bce 100644 --- a/src/ui/dialog/new-from-template.cpp +++ b/src/ui/dialog/new-from-template.cpp @@ -1,8 +1,19 @@ +/** @file + * @brief New From Template main dialog - implementation + */ +/* Authors: + * Jan Darowski , supervised by Krzysztof Kosiński + * + * Copyright (C) 2013 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + + #include "new-from-template.h" #include -#include "src/file.h" +#include "file.h" namespace Inkscape { @@ -13,7 +24,7 @@ NewFromTemplate::NewFromTemplate() : _create_template_button("Create from template") { set_title("New From Template"); - resize(400, 250); + resize(400, 400); get_vbox()->pack_start(_main_widget); _main_widget.append_page(_tab1, "Static Templates"); diff --git a/src/ui/dialog/new-from-template.h b/src/ui/dialog/new-from-template.h index e7976d685..59b61a015 100644 --- a/src/ui/dialog/new-from-template.h +++ b/src/ui/dialog/new-from-template.h @@ -1,3 +1,13 @@ +/** @file + * @brief New From Template main dialog + */ +/* Authors: + * Jan Darowski , supervised by Krzysztof Kosiński + * + * Copyright (C) 2013 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + #ifndef INKSCAPE_SEEN_UI_DIALOG_NEW_FROM_TEMPLATE_H #define INKSCAPE_SEEN_UI_DIALOG_NEW_FROM_TEMPLATE_H diff --git a/src/ui/dialog/static-template-load-tab.cpp b/src/ui/dialog/static-template-load-tab.cpp index 47c7c00b9..26b999aec 100644 --- a/src/ui/dialog/static-template-load-tab.cpp +++ b/src/ui/dialog/static-template-load-tab.cpp @@ -1,3 +1,13 @@ +/** @file + * @brief New From Template static templates tab - implementation + */ +/* Authors: + * Jan Darowski , supervised by Krzysztof Kosiński + * + * Copyright (C) 2013 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + #include "static-template-load-tab.h" #include @@ -5,7 +15,7 @@ #include #include -#include "src/file.h" +#include "file.h" namespace Inkscape { @@ -15,26 +25,26 @@ namespace UI { StaticTemplateLoadTab::StaticTemplateLoadTab() : TemplateLoadTab() , _more_info_button("More info") - , _preview_image("preview.png") , _short_description_label("Short description - I like trains. ad asda asd asdweqe gdfg") - , _template_name_label("Template_name") , _template_author_label("by template_author") + , _template_name_label("Template_name") + , _preview_image("preview.png") { - _loading_path = "/static"; + _loading_path = ""; _loadTemplates(); _initLists(); - _template_info_column.pack_start(_template_name_label, Gtk::PACK_SHRINK, 4); - _template_info_column.pack_start(_template_author_label, Gtk::PACK_SHRINK, 0); - _template_info_column.pack_start(_preview_image, Gtk::PACK_SHRINK, 15); - _template_info_column.pack_start(_short_description_label, Gtk::PACK_SHRINK, 4); + _info_box.pack_start(_template_name_label, Gtk::PACK_SHRINK, 4); + _info_box.pack_start(_template_author_label, Gtk::PACK_SHRINK, 0); + _info_box.pack_start(_preview_image, Gtk::PACK_SHRINK, 15); + _info_box.pack_start(_short_description_label, Gtk::PACK_SHRINK, 4); _short_description_label.set_line_wrap(true); _short_description_label.set_size_request(200); Gtk::Alignment *align; align = manage(new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER, 0.0, 0.0)); - _template_info_column.pack_start(*align, Gtk::PACK_SHRINK, 5); + _info_box.pack_start(*align, Gtk::PACK_SHRINK, 5); align->add(_more_info_button); } @@ -42,8 +52,8 @@ StaticTemplateLoadTab::StaticTemplateLoadTab() void StaticTemplateLoadTab::createTemplate() { Glib::ustring path; - if (_templates.find(_current_template) != _templates.end()){ - path = _templates[_current_template].path; + if (_tdata.find(_current_template) != _tdata.end()){ + path = _tdata[_current_template].path; } else path = ""; @@ -56,8 +66,8 @@ void StaticTemplateLoadTab::_displayTemplateInfo() { TemplateLoadTab::_displayTemplateInfo(); _template_name_label.set_text(_current_template); - _template_author_label.set_text(_templates[_current_template].author); - _short_description_label.set_text(_templates[_current_template].short_description); + _template_author_label.set_text(_tdata[_current_template].author); + _short_description_label.set_text(_tdata[_current_template].short_description); } } diff --git a/src/ui/dialog/static-template-load-tab.h b/src/ui/dialog/static-template-load-tab.h index a5411296d..9b19c495a 100644 --- a/src/ui/dialog/static-template-load-tab.h +++ b/src/ui/dialog/static-template-load-tab.h @@ -1,3 +1,13 @@ +/** @file + * @brief New From Template static templates tab + */ +/* Authors: + * Jan Darowski , supervised by Krzysztof Kosiński + * + * Copyright (C) 2013 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + #ifndef INKSCAPE_SEEN_UI_DIALOG_STATIC_TEMPLATE_LOAD_TAB_H #define INKSCAPE_SEEN_UI_DIALOG_STATIC_TEMPLATE_LOAD_TAB_H diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index 5e3a16a3f..95baccc75 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -1,13 +1,23 @@ +/** @file + * @brief New From Template abstract tab implementation + */ +/* Authors: + * Jan Darowski , supervised by Krzysztof Kosiński + * + * Copyright (C) 2013 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + #include "template-load-tab.h" -#include +#include #include -#include "src/interface.h" -#include "src/file.h" -#include "src/path-prefix.h" -#include "src/preferences.h" -#include "src/inkscape.h" +#include "interface.h" +#include "file.h" +#include "path-prefix.h" +#include "preferences.h" +#include "inkscape.h" namespace Inkscape { @@ -15,34 +25,32 @@ namespace UI { TemplateLoadTab::TemplateLoadTab() - : _keywords_combo(true) - , _current_keyword("") + : _current_keyword("") + , _keywords_combo(true) { set_border_width(10); Gtk::Label *title; - title = manage(new Gtk::Label("Search Tags:")); - _templates_column.pack_start(*title, Gtk::PACK_SHRINK, 10); + title = manage(new Gtk::Label("Search:")); + _tlist_box.pack_start(*title, Gtk::PACK_SHRINK, 10); - _templates_column.pack_start(_keywords_combo, Gtk::PACK_SHRINK, 0); + _tlist_box.pack_start(_keywords_combo, Gtk::PACK_SHRINK, 0); title = manage(new Gtk::Label("Templates")); - _templates_column.pack_start(*title, Gtk::PACK_SHRINK, 10); + _tlist_box.pack_start(*title, Gtk::PACK_SHRINK, 10); title = manage(new Gtk::Label("Selected template")); - _template_info_column.pack_start(*title, Gtk::PACK_SHRINK, 10); + _info_box.pack_start(*title, Gtk::PACK_SHRINK, 10); add(_main_box); - _main_box.pack_start(_templates_column, Gtk::PACK_SHRINK, 20); - _main_box.pack_start(_template_info_column, Gtk::PACK_EXPAND_WIDGET, 10); + _main_box.pack_start(_tlist_box, Gtk::PACK_SHRINK, 20); + _main_box.pack_start(_info_box, Gtk::PACK_EXPAND_WIDGET, 10); - _templates_column.pack_start(_templates_view, Gtk::PACK_SHRINK, 5); - - Glib::RefPtr templateSelectionRef = - _templates_view.get_selection(); - - templateSelectionRef->signal_changed().connect( - sigc::mem_fun(*this, &TemplateLoadTab::_displayTemplateInfo)); + Gtk::ScrolledWindow *scrolled; + scrolled = manage(new Gtk::ScrolledWindow()); + scrolled->set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC); + scrolled->add(_tlist_view); + _tlist_box.pack_start(*scrolled, Gtk::PACK_EXPAND_WIDGET, 5); _keywords_combo.signal_changed().connect( sigc::mem_fun(*this, &TemplateLoadTab::_keywordSelected)); @@ -63,9 +71,9 @@ void TemplateLoadTab::createTemplate() void TemplateLoadTab::_displayTemplateInfo() { - Glib::RefPtr templateSelectionRef = _templates_view.get_selection(); + Glib::RefPtr templateSelectionRef = _tlist_view.get_selection(); if (templateSelectionRef->get_selected()) { - _current_template = (*templateSelectionRef->get_selected())[_templates_columns.textValue]; + _current_template = (*templateSelectionRef->get_selected())[_columns.textValue]; } } @@ -82,13 +90,18 @@ void TemplateLoadTab::_initKeywordsList() void TemplateLoadTab::_initLists() { - _templates_ref = Gtk::ListStore::create(_templates_columns); - _templates_view.set_model(_templates_ref); - _templates_view.append_column("", _templates_columns.textValue); - _templates_view.set_headers_visible(false); + _tlist_store = Gtk::ListStore::create(_columns); + _tlist_view.set_model(_tlist_store); + _tlist_view.append_column("", _columns.textValue); + _tlist_view.set_headers_visible(false); _initKeywordsList(); _refreshTemplatesList(); + + Glib::RefPtr templateSelectionRef = + _tlist_view.get_selection(); + templateSelectionRef->signal_changed().connect( + sigc::mem_fun(*this, &TemplateLoadTab::_displayTemplateInfo)); } @@ -101,12 +114,12 @@ void TemplateLoadTab::_keywordSelected() void TemplateLoadTab::_refreshTemplatesList() { - _templates_ref->clear(); + _tlist_store->clear(); - for (std::map::iterator it = _templates.begin() ; it != _templates.end() ; ++it) { - Gtk::TreeModel::iterator iter = _templates_ref->append(); + for (std::map::iterator it = _tdata.begin() ; it != _tdata.end() ; ++it) { + Gtk::TreeModel::iterator iter = _tlist_store->append(); Gtk::TreeModel::Row row = *iter; - row[_templates_columns.textValue] = it->first; + row[_columns.textValue] = it->first; } } @@ -121,7 +134,7 @@ void TemplateLoadTab::_loadTemplates() } -TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(Glib::ustring path) +TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(const Glib::ustring &path) { TemplateData result; result.path = path; @@ -133,21 +146,21 @@ TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(Glib::ustrin } -void TemplateLoadTab::_getTemplatesFromDir(Glib::ustring path) +void TemplateLoadTab::_getTemplatesFromDir(const Glib::ustring &path) { if ( !Glib::file_test(path, Glib::FILE_TEST_EXISTS) || !Glib::file_test(path, Glib::FILE_TEST_IS_DIR)) return; Glib::Dir dir(path); - path += "/"; - Glib::ustring file = path + dir.read_name(); + + Glib::ustring file = Glib::build_filename(path, dir.read_name()); while (file != path){ - if (Glib::str_has_suffix(file, ".svg")){ + if (Glib::str_has_suffix(file, ".svg") && !Glib::str_has_prefix(Glib::path_get_basename(file), "default")){ TemplateData tmp = _processTemplateFile(file); - _templates[Glib::path_get_basename(file)] = tmp; + _tdata[Glib::path_get_basename(file)] = tmp; } - file = path + dir.read_name(); + file = Glib::build_filename(path, dir.read_name()); } } diff --git a/src/ui/dialog/template-load-tab.h b/src/ui/dialog/template-load-tab.h index 3edcf15eb..7d1e25d6d 100644 --- a/src/ui/dialog/template-load-tab.h +++ b/src/ui/dialog/template-load-tab.h @@ -1,3 +1,13 @@ +/** @file + * @brief New From Template abstract tab class + */ +/* Authors: + * Jan Darowski , supervised by Krzysztof Kosiński + * + * Copyright (C) 2013 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + #ifndef INKSCAPE_SEEN_UI_DIALOG_TEMPLATE_LOAD_TAB_H #define INKSCAPE_SEEN_UI_DIALOG_TEMPLATE_LOAD_TAB_H @@ -46,7 +56,7 @@ protected: Glib::ustring _current_keyword; Glib::ustring _current_template; Glib::ustring _loading_path; - std::map _templates; + std::map _tdata; virtual void _displayTemplateInfo(); @@ -56,19 +66,19 @@ protected: void _initLists(); Gtk::HBox _main_box; - Gtk::VBox _templates_column; - Gtk::VBox _template_info_column; + Gtk::VBox _tlist_box; + Gtk::VBox _info_box; Gtk::ComboBoxText _keywords_combo; - Gtk::TreeView _templates_view; - Glib::RefPtr _templates_ref; - StringModelColumns _templates_columns; + Gtk::TreeView _tlist_view; + Glib::RefPtr _tlist_store; + StringModelColumns _columns; private: - void _getTemplatesFromDir(Glib::ustring); + void _getTemplatesFromDir(const Glib::ustring &); void _keywordSelected(); - TemplateData _processTemplateFile(Glib::ustring); + TemplateData _processTemplateFile(const Glib::ustring &); }; -- cgit v1.2.3 From 9dc7b786c9ef31060012ea4ae13a8188548b4f62 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Tue, 9 Jul 2013 16:42:04 -0400 Subject: Ported sp-namedview.cpp (todo: fix a bunch of things). (bzr r12380.1.8) --- src/ui/dialog/clonetiler.cpp | 2 +- src/ui/dialog/document-properties.cpp | 4 ++-- src/ui/dialog/export.cpp | 4 ++-- src/ui/dialog/guides.cpp | 2 +- src/ui/widget/page-sizer.cpp | 4 ++-- src/ui/widget/selected-style.cpp | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index 753320ab9..00bb6f0e2 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -1093,7 +1093,7 @@ CloneTiler::CloneTiler (void) : // unitmenu GtkWidget *u = sp_unit_selector_new (SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE); - sp_unit_selector_set_unit (SP_UNIT_SELECTOR(u), sp_desktop_namedview(SP_ACTIVE_DESKTOP)->doc_units); + //sp_unit_selector_set_unit (SP_UNIT_SELECTOR(u), sp_desktop_namedview(SP_ACTIVE_DESKTOP)->doc_units); { // Width spinbutton diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index d335fb303..af462a1df 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -1431,8 +1431,8 @@ void DocumentProperties::update() _rcp_bord.setRgba32 (nv->bordercolor); _rcb_shad.setActive (nv->showpageshadow); - if (nv->doc_units) - _rum_deflt.setUnit (nv->doc_units); + //if (nv->doc_units) + // _rum_deflt.setUnit (nv->doc_units); double const doc_w_px = sp_desktop_document(dt)->getWidth(); double const doc_h_px = sp_desktop_document(dt)->getHeight(); diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index a851503fe..25300cfc0 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -200,8 +200,8 @@ Export::Export (void) : earlier than that */ unit_selector = Glib::wrap(sp_unit_selector_new (SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE)); SPDesktop *desktop = SP_ACTIVE_DESKTOP; - if (desktop) - sp_unit_selector_set_unit (SP_UNIT_SELECTOR(unit_selector->gobj()), sp_desktop_namedview(desktop)->doc_units); + //if (desktop) + // sp_unit_selector_set_unit (SP_UNIT_SELECTOR(unit_selector->gobj()), sp_desktop_namedview(desktop)->doc_units); unitbox.pack_end(*unit_selector, false, false, 0); unitbox.pack_end(units_label, false, false, 3); diff --git a/src/ui/dialog/guides.cpp b/src/ui/dialog/guides.cpp index 51bbc7d9a..9a7b19c35 100644 --- a/src/ui/dialog/guides.cpp +++ b/src/ui/dialog/guides.cpp @@ -230,7 +230,7 @@ void GuidelinePropertiesDialog::_setup() { _unit_menu.setUnitType(UNIT_TYPE_LINEAR); _unit_menu.setUnit("px"); if (_desktop->namedview->doc_units) { - _unit_menu.setUnit( sp_unit_get_abbreviation(_desktop->namedview->doc_units) ); + //_unit_menu.setUnit( sp_unit_get_abbreviation(_desktop->namedview->doc_units) ); } _spin_angle.setUnit(_angle_unit_status); diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index 884f9ea0a..14e280f6d 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -316,9 +316,9 @@ PageSizer::PageSizer(Registry & _wr) SPNamedView *nv = sp_desktop_namedview(dt); _wr.setUpdating (true); if (nv->units) { - _dimensionUnits.setUnit(nv->units); + //_dimensionUnits.setUnit(nv->units); } else if (nv->doc_units) { - _dimensionUnits.setUnit(nv->doc_units); + //_dimensionUnits.setUnit(nv->doc_units); } _wr.setUpdating (false); diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index 18dbb984b..d6e2406c9 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -476,7 +476,7 @@ SelectedStyle::setDesktop(SPDesktop *desktop) this ) )); - _sw_unit = const_cast(sp_desktop_namedview(desktop)->doc_units); + //_sw_unit = const_cast(sp_desktop_namedview(desktop)->doc_units); // Set the doc default unit active in the units list gint length = g_slist_length(_unit_mis); -- cgit v1.2.3 From 5977386b97689dfd12335f7444217634c66b5930 Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Sat, 13 Jul 2013 00:24:56 +0200 Subject: Template info loading + searching by keywords added. (bzr r12379.2.9) --- src/ui/dialog/static-template-load-tab.cpp | 6 ++ src/ui/dialog/template-load-tab.cpp | 108 ++++++++++++++++++++++++++--- src/ui/dialog/template-load-tab.h | 5 ++ 3 files changed, 109 insertions(+), 10 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/static-template-load-tab.cpp b/src/ui/dialog/static-template-load-tab.cpp index 26b999aec..35f3430fb 100644 --- a/src/ui/dialog/static-template-load-tab.cpp +++ b/src/ui/dialog/static-template-load-tab.cpp @@ -46,6 +46,9 @@ StaticTemplateLoadTab::StaticTemplateLoadTab() align = manage(new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER, 0.0, 0.0)); _info_box.pack_start(*align, Gtk::PACK_SHRINK, 5); align->add(_more_info_button); + + _more_info_button.signal_pressed().connect( + sigc::mem_fun(*this, &StaticTemplateLoadTab::_displayTemplateDetails)); } @@ -68,6 +71,9 @@ void StaticTemplateLoadTab::_displayTemplateInfo() _template_name_label.set_text(_current_template); _template_author_label.set_text(_tdata[_current_template].author); _short_description_label.set_text(_tdata[_current_template].short_description); + + Glib::ustring imagePath = Glib::build_filename(Glib::path_get_dirname(_tdata[_current_template].path), _tdata[_current_template].preview_name); + _preview_image.set(imagePath); } } diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index 95baccc75..6d9c61078 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -10,6 +10,7 @@ #include "template-load-tab.h" +#include #include #include @@ -18,6 +19,17 @@ #include "path-prefix.h" #include "preferences.h" #include "inkscape.h" +#include "xml/repr.h" +#include "xml/document.h" +#include "xml/node.h" + +// +#include + +#include +#include +#include +// namespace Inkscape { @@ -80,10 +92,10 @@ void TemplateLoadTab::_displayTemplateInfo() void TemplateLoadTab::_initKeywordsList() { - _keywords_combo.append("All"); + _keywords_combo.append(_("All")); - for (int i = 0 ; i < 10 ; ++i) { - _keywords_combo.append( "Keyword" + Glib::ustring::format(i)); + for (std::set::iterator it = _keywords.begin() ; it != _keywords.end() ; ++it){ + _keywords_combo.append(*it); } } @@ -108,6 +120,8 @@ void TemplateLoadTab::_initLists() void TemplateLoadTab::_keywordSelected() { _current_keyword = _keywords_combo.get_active_text(); + if (_current_keyword == "" && _keywords_combo.get_entry_text().size() > 0) + _current_keyword = _keywords_combo.get_entry_text(); _refreshTemplatesList(); } @@ -117,9 +131,11 @@ void TemplateLoadTab::_refreshTemplatesList() _tlist_store->clear(); for (std::map::iterator it = _tdata.begin() ; it != _tdata.end() ; ++it) { - Gtk::TreeModel::iterator iter = _tlist_store->append(); - Gtk::TreeModel::Row row = *iter; - row[_columns.textValue] = it->first; + if (it->second.keywords.count(_current_keyword) > 0 || _current_keyword == _("All") || _current_keyword == ""){ + Gtk::TreeModel::iterator iter = _tlist_store->append(); + Gtk::TreeModel::Row row = *iter; + row[_columns.textValue] = it->first; + } } } @@ -130,7 +146,7 @@ void TemplateLoadTab::_loadTemplates() _getTemplatesFromDir(profile_path("templates") + _loading_path); // system templates dir - _getTemplatesFromDir(INKSCAPE_TEMPLATESDIR + _loading_path); + // _getTemplatesFromDir(INKSCAPE_TEMPLATESDIR + _loading_path); } @@ -138,9 +154,54 @@ TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(const Glib:: { TemplateData result; result.path = path; - result.display_name = Glib::path_get_basename(path); + result.display_name = Glib::path_get_basename(path);/* result.short_description = "LaLaLaLa"; - result.author = "JAASDASD"; + result.author = "JAASDASD";*/ + + Inkscape::XML::Document *rdoc; + rdoc = sp_repr_read_file(path.data(), SP_SVG_NS_URI); + Inkscape::XML::Node *myRoot; + Inkscape::XML::Node *dataNode; + if (rdoc){ + myRoot = rdoc->root(); + if (strcmp(myRoot->name(), "svg:svg") != 0){ // Wrong file format + return result; + } + + myRoot = sp_repr_lookup_name(myRoot, "inkscape:_templateinfo"); + + if (myRoot == NULL) // No template info + return result; + + if ((dataNode = sp_repr_lookup_name(myRoot, "inkscape:_name")) != NULL) + result.display_name = dgettext(NULL, dataNode->firstChild()->content()); + if ((dataNode = sp_repr_lookup_name(myRoot, "inkscape:author")) != NULL) + result.author = dataNode->firstChild()->content(); + if ((dataNode = sp_repr_lookup_name(myRoot, "inkscape:_short")) != NULL) + result.short_description = dgettext(NULL, dataNode->firstChild()->content()); + if ((dataNode = sp_repr_lookup_name(myRoot, "inkscape:_long") )!= NULL) + result.long_description = dgettext(NULL, dataNode->firstChild()->content()); + if ((dataNode = sp_repr_lookup_name(myRoot, "inkscape:preview")) != NULL) + result.preview_name = dataNode->firstChild()->content(); + if ((dataNode = sp_repr_lookup_name(myRoot, "inkscape:date")) != NULL){ + result.creation_date = dataNode->firstChild()->content(); + } + + if ((dataNode = sp_repr_lookup_name(myRoot, "inkscape:_keywords")) != NULL){ + Glib::ustring data = dataNode->firstChild()->content(); + while (!data.empty()){ + int pos = data.find_first_of(" "); + Glib::ustring keyword = dgettext(NULL, data.substr(0, pos).data()); + result.keywords.insert(keyword); + std::cout< 0){ + message += "Keywords: "; + for (std::set::iterator it = tmpl.keywords.begin(); it != tmpl.keywords.end(); ++it) + message += *it + " "; + message += "\n\n"; + } + + if (tmpl.author != "") + message += "By: " + _tdata[_current_template].author + " " + tmpl.creation_date + "\n\n"; + + Gtk::MessageDialog dl(message, false, Gtk::MESSAGE_OTHER); + dl.run(); +} + } } diff --git a/src/ui/dialog/template-load-tab.h b/src/ui/dialog/template-load-tab.h index 7d1e25d6d..55893eed0 100644 --- a/src/ui/dialog/template-load-tab.h +++ b/src/ui/dialog/template-load-tab.h @@ -39,6 +39,9 @@ protected: Glib::ustring display_name; Glib::ustring author; Glib::ustring short_description; + Glib::ustring long_description; + Glib::ustring preview_name; + Glib::ustring creation_date; std::set keywords; }; @@ -57,6 +60,7 @@ protected: Glib::ustring _current_template; Glib::ustring _loading_path; std::map _tdata; + std::set _keywords; virtual void _displayTemplateInfo(); @@ -64,6 +68,7 @@ protected: virtual void _refreshTemplatesList(); void _loadTemplates(); void _initLists(); + void _displayTemplateDetails(); Gtk::HBox _main_box; Gtk::VBox _tlist_box; -- cgit v1.2.3 From 3174f1abec451e06ff36bf8f4d9a1e5992ee0382 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Tue, 16 Jul 2013 20:10:36 -0400 Subject: Added new UnitTracker class. (bzr r12380.1.9) --- src/ui/widget/Makefile_insert | 4 +- src/ui/widget/unit-tracker.cpp | 255 +++++++++++++++++++++++++++++++++++++++++ src/ui/widget/unit-tracker.h | 75 ++++++++++++ 3 files changed, 333 insertions(+), 1 deletion(-) create mode 100644 src/ui/widget/unit-tracker.cpp create mode 100644 src/ui/widget/unit-tracker.h (limited to 'src/ui') diff --git a/src/ui/widget/Makefile_insert b/src/ui/widget/Makefile_insert index 2de954674..710b95c2b 100644 --- a/src/ui/widget/Makefile_insert +++ b/src/ui/widget/Makefile_insert @@ -79,5 +79,7 @@ ink_common_sources += \ ui/widget/tolerance-slider.cpp \ ui/widget/tolerance-slider.h \ ui/widget/unit-menu.cpp \ - ui/widget/unit-menu.h + ui/widget/unit-menu.h \ + ui/widget/unit-tracker.h \ + ui/widget/unit-tracker.cpp diff --git a/src/ui/widget/unit-tracker.cpp b/src/ui/widget/unit-tracker.cpp new file mode 100644 index 000000000..b701c785e --- /dev/null +++ b/src/ui/widget/unit-tracker.cpp @@ -0,0 +1,255 @@ +/* + * Inkscape::UI::Widget::UnitTracker + * Simple mediator to synchronize changes to unit menus + * + * Authors: + * Jon A. Cruz + * Matthew Petroff + * + * Copyright (C) 2007 Jon A. Cruz + * Copyright (C) 2013 Matthew Petroff + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "unit-tracker.h" +#include "ege-select-one-action.h" + +#define COLUMN_STRING 0 + +namespace Inkscape { +namespace UI { +namespace Widget { + +UnitTracker::UnitTracker(UnitType unit_type) : + _active(0), + _isUpdating(false), + _activeUnitInitialized(false), + _store(0), + _unitList(0), + _actionList(0), + _adjList(0), + _priorValues() +{ + _store = gtk_list_store_new(1, G_TYPE_STRING); + static Inkscape::Util::UnitTable unit_table; + + GtkTreeIter iter; + UnitTable::UnitMap m = _unit_table.units(unit_type); + UnitTable::UnitMap::iterator m_iter = m.begin(); + while(m_iter != m.end()) { + Glib::ustring text = (*m_iter).first; + m_iter++; + gtk_list_store_append(_store, &iter); + gtk_list_store_set(_store, &iter, COLUMN_STRING, text.c_str(), -1); + } + gint count = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(_store), 0); + if ((count > 0) && (_active > count)) { + _setActive(--count); + } else { + _setActive(_active); + } +} + +UnitTracker::~UnitTracker() +{ + // Unhook weak references to GtkActions + while (_actionList) { + g_signal_handlers_disconnect_by_func(G_OBJECT(_actionList->data), (gpointer) _unitChangedCB, this); + g_object_weak_unref(G_OBJECT(_actionList->data), _actionFinalizedCB, this); + _actionList = g_slist_delete_link(_actionList, _actionList); + } + + // Unhook weak references to GtkAdjustments + while (_adjList) { + g_object_weak_unref(G_OBJECT(_adjList->data), _adjustmentFinalizedCB, this); + _adjList = g_slist_delete_link(_adjList, _adjList); + } +} + +bool UnitTracker::isUpdating() const +{ + return _isUpdating; +} + +Inkscape::Util::Unit UnitTracker::getActiveUnit() const +{ + return _activeUnit; +} + +void UnitTracker::setActiveUnit(Inkscape::Util::Unit const *unit) +{ + if (unit) { + GtkTreeIter iter; + int index = 0; + gboolean found = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(_store), &iter); + while (found) { + gchar *storedUnit = 0; + gtk_tree_model_get(GTK_TREE_MODEL(_store), &iter, COLUMN_STRING, &storedUnit, -1); + if (storedUnit && (!unit->abbr.compare(storedUnit))) { + _setActive(index); + break; + } + + found = gtk_tree_model_iter_next(GTK_TREE_MODEL(_store), &iter); + index++; + } + } +} + +void UnitTracker::setActiveUnitByAbbr(gchar const *abbr) +{ + Inkscape::Util::Unit u = _unit_table.getUnit(abbr); + setActiveUnit(&u); +} + +void UnitTracker::addAdjustment(GtkAdjustment *adj) +{ + if (!g_slist_find(_adjList, adj)) { + g_object_weak_ref(G_OBJECT(adj), _adjustmentFinalizedCB, this); + _adjList = g_slist_append(_adjList, adj); + } +} + +void UnitTracker::setFullVal(GtkAdjustment *adj, gdouble val) +{ + _priorValues[adj] = val; +} + +GtkAction *UnitTracker::createAction(gchar const *name, gchar const *label, gchar const *tooltip) +{ + EgeSelectOneAction *act1 = ege_select_one_action_new(name, label, tooltip, NULL, GTK_TREE_MODEL(_store)); + ege_select_one_action_set_label_column(act1, COLUMN_STRING); + if (_active) { + ege_select_one_action_set_active(act1, _active); + } + + ege_select_one_action_set_appearance(act1, "minimal"); + g_object_weak_ref(G_OBJECT(act1), _actionFinalizedCB, this); + g_signal_connect(G_OBJECT(act1), "changed", G_CALLBACK(_unitChangedCB), this); + _actionList = g_slist_append(_actionList, act1); + + return GTK_ACTION(act1); +} + +void UnitTracker::_unitChangedCB(GtkAction *action, gpointer data) +{ + if (action && data) { + EgeSelectOneAction *act = EGE_SELECT_ONE_ACTION(action); + gint active = ege_select_one_action_get_active(act); + UnitTracker *self = reinterpret_cast(data); + self->_setActive(active); + } +} + +void UnitTracker::_actionFinalizedCB(gpointer data, GObject *where_the_object_was) +{ + if (data && where_the_object_was) { + UnitTracker *self = reinterpret_cast(data); + self->_actionFinalized(where_the_object_was); + } +} + +void UnitTracker::_adjustmentFinalizedCB(gpointer data, GObject *where_the_object_was) +{ + if (data && where_the_object_was) { + UnitTracker *self = reinterpret_cast(data); + self->_adjustmentFinalized(where_the_object_was); + } +} + +void UnitTracker::_actionFinalized(GObject *where_the_object_was) +{ + GSList *target = g_slist_find(_actionList, where_the_object_was); + if (target) { + _actionList = g_slist_remove(_actionList, where_the_object_was); + } else { + g_warning("Received a finalization callback for unknown object %p", where_the_object_was); + } +} + +void UnitTracker::_adjustmentFinalized(GObject *where_the_object_was) +{ + GSList *target = g_slist_find(_adjList, where_the_object_was); + if (target) { + _adjList = g_slist_remove(_adjList, where_the_object_was); + } else { + g_warning("Received a finalization callback for unknown object %p", where_the_object_was); + } +} + +void UnitTracker::_setActive(gint active) +{ + if ( active != _active || !_activeUnitInitialized ) { + gint oldActive = _active; + + GtkTreeIter iter; + gboolean found = gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(_store), &iter, NULL, oldActive); + if (found) { + gchar *abbr; + gtk_tree_model_get(GTK_TREE_MODEL(_store), &iter, COLUMN_STRING, &abbr, -1); + Inkscape::Util::Unit unit = _unit_table.getUnit(abbr); + + found = gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(_store), &iter, NULL, active); + if (found) { + gchar *newAbbr; + gtk_tree_model_get(GTK_TREE_MODEL(_store), &iter, COLUMN_STRING, &newAbbr, -1); + Inkscape::Util::Unit newUnit = _unit_table.getUnit(newAbbr); + _activeUnit = newUnit; + + if (_adjList) { + _fixupAdjustments(unit, newUnit); + } + + } else { + g_warning("Did not find new unit"); + } + } else { + g_warning("Did not find old unit"); + } + + _active = active; + + for ( GSList *cur = _actionList ; cur ; cur = g_slist_next(cur) ) { + if (IS_EGE_SELECT_ONE_ACTION(cur->data)) { + EgeSelectOneAction *act = EGE_SELECT_ONE_ACTION(cur->data); + ege_select_one_action_set_active(act, active); + } + } + + _activeUnitInitialized = true; + } +} + +void UnitTracker::_fixupAdjustments(Inkscape::Util::Unit const oldUnit, Inkscape::Util::Unit const newUnit) +{ + _isUpdating = true; + Inkscape::Util::Unit px = _unit_table.getUnit("px"); + for ( GSList *cur = _adjList ; cur ; cur = g_slist_next(cur) ) { + GtkAdjustment *adj = GTK_ADJUSTMENT(cur->data); + gdouble oldVal = gtk_adjustment_get_value(adj); + gdouble val = oldVal; + + if ( (oldUnit.type != Inkscape::Util::UNIT_TYPE_DIMENSIONLESS) + && (newUnit.type == Inkscape::Util::UNIT_TYPE_DIMENSIONLESS) ) + { + val = 1.0 / newUnit.factor; + _priorValues[adj] = Inkscape::Util::Quantity::convert(oldVal, &oldUnit, &px); + } else if ( (oldUnit.type == Inkscape::Util::UNIT_TYPE_DIMENSIONLESS) + && (newUnit.type != Inkscape::Util::UNIT_TYPE_DIMENSIONLESS) ) + { + if (_priorValues.find(adj) != _priorValues.end()) { + val = Inkscape::Util::Quantity::convert(_priorValues[adj], &newUnit, &px); + } + } else { + val = Inkscape::Util::Quantity::convert(oldVal, &oldUnit, &newUnit); + } + + gtk_adjustment_set_value(adj, val); + } + _isUpdating = false; +} + +} // namespace Widget +} // namespace UI +} // namespace Inkscape diff --git a/src/ui/widget/unit-tracker.h b/src/ui/widget/unit-tracker.h new file mode 100644 index 000000000..521fe50c8 --- /dev/null +++ b/src/ui/widget/unit-tracker.h @@ -0,0 +1,75 @@ +/* + * Inkscape::UI::Widget::UnitTracker + * Simple mediator to synchronize changes to unit menus + * + * Authors: + * Jon A. Cruz + * Matthew Petroff + * + * Copyright (C) 2007 Jon A. Cruz + * Copyright (C) 2013 Matthew Petroff + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifndef INKSCAPE_UI_WIDGET_UNIT_TRACKER_H +#define INKSCAPE_UI_WIDGET_UNIT_TRACKER_H + +#include +#include + +#include "util/units.h" + +using Inkscape::Util::Unit; +using Inkscape::Util::UnitTable; +using Inkscape::Util::UnitType; + +namespace Inkscape { +namespace UI { +namespace Widget { + +class UnitTracker { +public: + UnitTracker(UnitType unit_type); + virtual ~UnitTracker(); + + bool isUpdating() const; + + void setActiveUnit(Inkscape::Util::Unit const *unit); + void setActiveUnitByAbbr(gchar const *abbr); + Inkscape::Util::Unit getActiveUnit() const; + + void addAdjustment(GtkAdjustment *adj); + void setFullVal(GtkAdjustment *adj, gdouble val); + + GtkAction *createAction(gchar const *name, gchar const *label, gchar const *tooltip); + +protected: + UnitTable _unit_table; + UnitType _type; + +private: + static void _unitChangedCB(GtkAction *action, gpointer data); + static void _actionFinalizedCB(gpointer data, GObject *where_the_object_was); + static void _adjustmentFinalizedCB(gpointer data, GObject *where_the_object_was); + void _setActive(gint index); + void _fixupAdjustments(Inkscape::Util::Unit const oldUnit, Inkscape::Util::Unit const newUnit); + void _actionFinalized(GObject *where_the_object_was); + void _adjustmentFinalized(GObject *where_the_object_was); + + gint _active; + bool _isUpdating; + Inkscape::Util::Unit _activeUnit; + bool _activeUnitInitialized; + GtkListStore *_store; + GSList *_unitList; + GSList *_actionList; + GSList *_adjList; + std::map _priorValues; +}; + +} // namespace Widget +} // namespace UI +} // namespace Inkscape + +#endif // INKSCAPE_UI_WIDGET_UNIT_TRACKER_H -- cgit v1.2.3 From c28e6d2bdeb2983698a4e4789de15570e0f3d161 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Wed, 17 Jul 2013 00:25:40 -0400 Subject: Fixed conversion factors and missed unit include removal. (bzr r12380.1.12) --- src/ui/widget/unit-tracker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/widget/unit-tracker.cpp b/src/ui/widget/unit-tracker.cpp index b701c785e..df78e21dd 100644 --- a/src/ui/widget/unit-tracker.cpp +++ b/src/ui/widget/unit-tracker.cpp @@ -233,7 +233,7 @@ void UnitTracker::_fixupAdjustments(Inkscape::Util::Unit const oldUnit, Inkscape if ( (oldUnit.type != Inkscape::Util::UNIT_TYPE_DIMENSIONLESS) && (newUnit.type == Inkscape::Util::UNIT_TYPE_DIMENSIONLESS) ) { - val = 1.0 / newUnit.factor; + val = newUnit.factor; _priorValues[adj] = Inkscape::Util::Quantity::convert(oldVal, &oldUnit, &px); } else if ( (oldUnit.type == Inkscape::Util::UNIT_TYPE_DIMENSIONLESS) && (newUnit.type != Inkscape::Util::UNIT_TYPE_DIMENSIONLESS) ) -- cgit v1.2.3 From 7af2b98550f3389d08773addca07cd943ec6e2bb Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Wed, 17 Jul 2013 01:00:49 -0400 Subject: Temporary fixes/kludges. (bzr r12380.1.16) --- src/ui/widget/selected-style.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/ui') diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index d6e2406c9..102132158 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -477,6 +477,7 @@ SelectedStyle::setDesktop(SPDesktop *desktop) )); //_sw_unit = const_cast(sp_desktop_namedview(desktop)->doc_units); + _sw_unit = const_cast(&sp_unit_get_by_id(SP_UNIT_PX)); // Set the doc default unit active in the units list gint length = g_slist_length(_unit_mis); -- cgit v1.2.3 From 76ce8f0dae07598af9b0369473db64c38fa309a4 Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Wed, 17 Jul 2013 12:17:23 +0200 Subject: Searching by words in descriptions, titles etc. Translation support improved (bzr r12379.2.10) --- src/ui/dialog/template-load-tab.cpp | 64 +++++++++++++++++++++++++++++-------- src/ui/dialog/template-load-tab.h | 9 ++++++ 2 files changed, 60 insertions(+), 13 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index 6d9c61078..90980dc39 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -39,6 +39,7 @@ namespace UI { TemplateLoadTab::TemplateLoadTab() : _current_keyword("") , _keywords_combo(true) + ,_current_search_type(ALL) { set_border_width(10); @@ -120,8 +121,16 @@ void TemplateLoadTab::_initLists() void TemplateLoadTab::_keywordSelected() { _current_keyword = _keywords_combo.get_active_text(); - if (_current_keyword == "" && _keywords_combo.get_entry_text().size() > 0) + if (_current_keyword == ""){ _current_keyword = _keywords_combo.get_entry_text(); + _current_search_type = USER_SPECIFIED; + } + else + _current_search_type = LIST_KEYWORD; + + if (_current_keyword == "" || _current_keyword == "All") + _current_search_type = ALL; + _refreshTemplatesList(); } @@ -130,12 +139,43 @@ void TemplateLoadTab::_refreshTemplatesList() { _tlist_store->clear(); - for (std::map::iterator it = _tdata.begin() ; it != _tdata.end() ; ++it) { - if (it->second.keywords.count(_current_keyword) > 0 || _current_keyword == _("All") || _current_keyword == ""){ + switch (_current_search_type){ + case ALL :{ + + for (std::map::iterator it = _tdata.begin() ; it != _tdata.end() ; ++it) { Gtk::TreeModel::iterator iter = _tlist_store->append(); Gtk::TreeModel::Row row = *iter; row[_columns.textValue] = it->first; } + break; + } + + case LIST_KEYWORD: { + for (std::map::iterator it = _tdata.begin() ; it != _tdata.end() ; ++it) { + if (it->second.keywords.count(_current_keyword) != 0){ + Gtk::TreeModel::iterator iter = _tlist_store->append(); + Gtk::TreeModel::Row row = *iter; + row[_columns.textValue] = it->first; + } + } + break; + } + + case USER_SPECIFIED : { + for (std::map::iterator it = _tdata.begin() ; it != _tdata.end() ; ++it) { + if (it->second.keywords.count(_current_keyword) != 0 || + it->second.display_name.find(_current_keyword) != Glib::ustring::npos || + it->second.author.find(_current_keyword) != Glib::ustring::npos || + it->second.short_description.find(_current_keyword) != Glib::ustring::npos || + it->second.long_description.find(_current_keyword) != Glib::ustring::npos ) + { + Gtk::TreeModel::iterator iter = _tlist_store->append(); + Gtk::TreeModel::Row row = *iter; + row[_columns.textValue] = it->first; + } + } + break; + } } } @@ -174,13 +214,13 @@ TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(const Glib:: return result; if ((dataNode = sp_repr_lookup_name(myRoot, "inkscape:_name")) != NULL) - result.display_name = dgettext(NULL, dataNode->firstChild()->content()); + result.display_name = dgettext("Document template name", dataNode->firstChild()->content()); if ((dataNode = sp_repr_lookup_name(myRoot, "inkscape:author")) != NULL) result.author = dataNode->firstChild()->content(); if ((dataNode = sp_repr_lookup_name(myRoot, "inkscape:_short")) != NULL) - result.short_description = dgettext(NULL, dataNode->firstChild()->content()); + result.short_description = dgettext("Document template short description", dataNode->firstChild()->content()); if ((dataNode = sp_repr_lookup_name(myRoot, "inkscape:_long") )!= NULL) - result.long_description = dgettext(NULL, dataNode->firstChild()->content()); + result.long_description = dgettext("Document template long description", dataNode->firstChild()->content()); if ((dataNode = sp_repr_lookup_name(myRoot, "inkscape:preview")) != NULL) result.preview_name = dataNode->firstChild()->content(); if ((dataNode = sp_repr_lookup_name(myRoot, "inkscape:date")) != NULL){ @@ -191,10 +231,8 @@ TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(const Glib:: Glib::ustring data = dataNode->firstChild()->content(); while (!data.empty()){ int pos = data.find_first_of(" "); - Glib::ustring keyword = dgettext(NULL, data.substr(0, pos).data()); + Glib::ustring keyword = dgettext("Document template keyword", data.substr(0, pos).data()); result.keywords.insert(keyword); - std::cout< 0){ - message += "Keywords: "; + message += _("Keywords: "); for (std::set::iterator it = tmpl.keywords.begin(); it != tmpl.keywords.end(); ++it) message += *it + " "; message += "\n\n"; } if (tmpl.author != "") - message += "By: " + _tdata[_current_template].author + " " + tmpl.creation_date + "\n\n"; + message += _("By: ") + _tdata[_current_template].author + " " + tmpl.creation_date + "\n\n"; Gtk::MessageDialog dl(message, false, Gtk::MESSAGE_OTHER); dl.run(); diff --git a/src/ui/dialog/template-load-tab.h b/src/ui/dialog/template-load-tab.h index 55893eed0..8290f1b3f 100644 --- a/src/ui/dialog/template-load-tab.h +++ b/src/ui/dialog/template-load-tab.h @@ -81,6 +81,15 @@ protected: StringModelColumns _columns; private: + enum SearchType + { + LIST_KEYWORD, + USER_SPECIFIED, + ALL + }; + + SearchType _current_search_type; + void _getTemplatesFromDir(const Glib::ustring &); void _keywordSelected(); TemplateData _processTemplateFile(const Glib::ustring &); -- cgit v1.2.3 From c60177d361dd435e58caa902a395fa21c9415f51 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Wed, 17 Jul 2013 18:12:31 -0400 Subject: Removed "helper/unit.*" dependency from "ui/widget/registered-widget.*". (bzr r12380.1.21) --- src/ui/widget/registered-widget.cpp | 5 ++--- src/ui/widget/registered-widget.h | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'src/ui') diff --git a/src/ui/widget/registered-widget.cpp b/src/ui/widget/registered-widget.cpp index ea2bac867..ae6a7d1e0 100644 --- a/src/ui/widget/registered-widget.cpp +++ b/src/ui/widget/registered-widget.cpp @@ -27,7 +27,6 @@ #include "ui/widget/random.h" #include "widgets/spinbutton-events.h" -#include "helper/units.h" #include "xml/repr.h" #include "svg/svg-color.h" #include "svg/stringstream.h" @@ -118,9 +117,9 @@ RegisteredUnitMenu::RegisteredUnitMenu (const Glib::ustring& label, const Glib:: } void -RegisteredUnitMenu::setUnit (const SPUnit* unit) +RegisteredUnitMenu::setUnit (Glib::ustring unit) { - getUnitMenu()->setUnit (sp_unit_get_abbreviation (unit)); + getUnitMenu()->setUnit(unit); } void diff --git a/src/ui/widget/registered-widget.h b/src/ui/widget/registered-widget.h index fa35b815e..491ca6050 100644 --- a/src/ui/widget/registered-widget.h +++ b/src/ui/widget/registered-widget.h @@ -166,7 +166,7 @@ public: Inkscape::XML::Node* repr_in = NULL, SPDocument *doc_in = NULL ); - void setUnit (const SPUnit*); + void setUnit (const Glib::ustring); Unit getUnit() const { return static_cast(_widget)->getUnit(); }; UnitMenu* getUnitMenu() const { return static_cast(_widget); }; sigc::connection _changed_connection; -- cgit v1.2.3 From 64e66e01886be870fc9615e65416097e64ad544b Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Wed, 17 Jul 2013 18:13:19 -0400 Subject: Ported "ui/dialog/export.*". (bzr r12380.1.22) --- src/ui/dialog/export.cpp | 74 ++++++++++++++++++------------------------------ src/ui/dialog/export.h | 8 +++++- 2 files changed, 35 insertions(+), 47 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 25300cfc0..61fb6e4ee 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -48,8 +48,8 @@ #include #include -#include "helper/unit-menu.h" -#include "helper/units.h" +#include "ui/widget/unit-menu.h" +#include "util/units.h" #include "unit-constants.h" #include "helper/window.h" #include "inkscape-private.h" @@ -198,10 +198,13 @@ Export::Export (void) : /* Units box */ /* gets added to the vbox later, but the unit selector is needed earlier than that */ - unit_selector = Glib::wrap(sp_unit_selector_new (SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE)); + unit_selector = new Inkscape::UI::Widget::UnitMenu(); + unit_selector->setUnitType(Inkscape::Util::UNIT_TYPE_LINEAR); + unitChangedConn = unit_selector->signal_changed().connect(sigc::mem_fun(*this, &Export::onUnitChanged)); + SPDesktop *desktop = SP_ACTIVE_DESKTOP; - //if (desktop) - // sp_unit_selector_set_unit (SP_UNIT_SELECTOR(unit_selector->gobj()), sp_desktop_namedview(desktop)->doc_units); + if (desktop) + unit_selector->setUnit(sp_desktop_namedview(desktop)->doc_units->abbr); unitbox.pack_end(*unit_selector, false, false, 0); unitbox.pack_end(units_label, false, false, 3); @@ -226,28 +229,28 @@ Export::Export (void) : t->set_col_spacings (4); #endif - x0_adj = createSpinbutton ( "x0", 0.0, -1000000.0, 1000000.0, 0.1, 1.0, unit_selector->gobj(), + x0_adj = createSpinbutton ( "x0", 0.0, -1000000.0, 1000000.0, 0.1, 1.0, ((Gtk::Widget*) unit_selector)->gobj(), t, 0, 0, _("_x0:"), "", EXPORT_COORD_PRECISION, 1, &Export::onAreaX0Change); - x1_adj = createSpinbutton ( "x1", 0.0, -1000000.0, 1000000.0, 0.1, 1.0, unit_selector->gobj(), + x1_adj = createSpinbutton ( "x1", 0.0, -1000000.0, 1000000.0, 0.1, 1.0, ((Gtk::Widget*) unit_selector)->gobj(), t, 0, 1, _("x_1:"), "", EXPORT_COORD_PRECISION, 1, &Export::onAreaX1Change); width_adj = createSpinbutton ( "width", 0.0, 0.0, PNG_UINT_31_MAX, 0.1, 1.0, - unit_selector->gobj(), t, 0, 2, _("Wid_th:"), "", EXPORT_COORD_PRECISION, 1, + ((Gtk::Widget*) unit_selector)->gobj(), t, 0, 2, _("Wid_th:"), "", EXPORT_COORD_PRECISION, 1, &Export::onAreaWidthChange); - y0_adj = createSpinbutton ( "y0", 0.0, -1000000.0, 1000000.0, 0.1, 1.0, unit_selector->gobj(), + y0_adj = createSpinbutton ( "y0", 0.0, -1000000.0, 1000000.0, 0.1, 1.0, ((Gtk::Widget*) unit_selector)->gobj(), t, 2, 0, _("_y0:"), "", EXPORT_COORD_PRECISION, 1, &Export::onAreaY0Change); - y1_adj = createSpinbutton ( "y1", 0.0, -1000000.0, 1000000.0, 0.1, 1.0, unit_selector->gobj(), + y1_adj = createSpinbutton ( "y1", 0.0, -1000000.0, 1000000.0, 0.1, 1.0, ((Gtk::Widget*) unit_selector)->gobj(), t, 2, 1, _("y_1:"), "", EXPORT_COORD_PRECISION, 1, &Export::onAreaY1Change); height_adj = createSpinbutton ( "height", 0.0, 0.0, PNG_UINT_31_MAX, 0.1, 1.0, - unit_selector->gobj(), t, 2, 2, _("Hei_ght:"), "", EXPORT_COORD_PRECISION, 1, + ((Gtk::Widget*) unit_selector)->gobj(), t, 2, 2, _("Hei_ght:"), "", EXPORT_COORD_PRECISION, 1, &Export::onAreaHeightChange); area_box.pack_start(togglebox, false, false, 3); @@ -496,9 +499,6 @@ Gtk::Adjustment * Export::createSpinbutton( gchar const * /*key*/, float val, fl #else Gtk::Adjustment *adj = new Gtk::Adjustment ( val, min, max, step, page, 0 ); #endif - if (us) { - sp_unit_selector_add_adjustment ( SP_UNIT_SELECTOR (us), GTK_ADJUSTMENT (adj->gobj()) ); - } int pos = 0; Gtk::Label *l = NULL; @@ -979,6 +979,12 @@ Glib::ustring Export::absolutize_path_from_document_location (SPDocument *doc, c return path; } +// Called when unit is changed +void Export::onUnitChanged() +{ + onAreaToggled(); +} + void Export::onHideExceptSelected () { prefs->setBool("/dialogs/export/hideexceptselected/value", hide_export.get_active()); @@ -1507,10 +1513,6 @@ void Export::areaXChange (Gtk::Adjustment *adj) return; } - if (sp_unit_selector_update_test(SP_UNIT_SELECTOR(unit_selector->gobj()))) { - return; - } - update = true; x0 = getValuePx(x0_adj); @@ -1554,10 +1556,6 @@ void Export::areaYChange (Gtk::Adjustment *adj) return; } - if (sp_unit_selector_update_test (SP_UNIT_SELECTOR(unit_selector->gobj()))) { - return; - } - update = true; y0 = getValuePx(y0_adj); @@ -1597,10 +1595,6 @@ void Export::onAreaWidthChange() return; } - if (sp_unit_selector_update_test(reinterpret_cast(unit_selector->gobj()))) { - return; - } - update = true; float x0 = getValuePx(x0_adj); @@ -1630,10 +1624,6 @@ void Export::onAreaHeightChange() return; } - if (sp_unit_selector_update_test(reinterpret_cast(unit_selector->gobj()))) { - return; - } - update = true; float y0 = getValuePx(y0_adj); @@ -1709,10 +1699,6 @@ void Export::onBitmapWidthChange () return; } - if (sp_unit_selector_update_test(SP_UNIT_SELECTOR(unit_selector->gobj()))) { - return; - } - update = true; x0 = getValuePx(x0_adj); @@ -1743,10 +1729,6 @@ void Export::onBitmapHeightChange () return; } - if (sp_unit_selector_update_test(SP_UNIT_SELECTOR(unit_selector->gobj()))) { - return; - } - update = true; y0 = getValuePx(y0_adj); @@ -1803,10 +1785,6 @@ void Export::onExportXdpiChange() return; } - if (sp_unit_selector_update_test(SP_UNIT_SELECTOR(unit_selector->gobj()))) { - return; - } - update = true; x0 = getValuePx(x0_adj); @@ -1905,9 +1883,11 @@ void Export::setValuePx(Glib::RefPtr& adj, double val) void Export::setValuePx( Gtk::Adjustment *adj, double val) #endif { - const SPUnit *unit = sp_unit_selector_get_unit(SP_UNIT_SELECTOR(unit_selector->gobj()) ); + const Unit unit = unit_selector->getUnit(); + Inkscape::Util::UnitTable unit_table; + Inkscape::Util::Unit px = unit_table.getUnit("px"); - setValue(adj, sp_pixels_get_units (val, *unit)); + setValue(adj, Inkscape::Util::Quantity::convert(val, &px, &unit)); return; } @@ -1955,9 +1935,11 @@ float Export::getValuePx( Gtk::Adjustment *adj ) #endif { float value = getValue( adj); - const SPUnit *unit = sp_unit_selector_get_unit(SP_UNIT_SELECTOR(unit_selector->gobj())); + const Unit unit = unit_selector->getUnit(); + Inkscape::Util::UnitTable unit_table; + Inkscape::Util::Unit px = unit_table.getUnit("px"); - return sp_units_get_pixels (value, *unit); + return Inkscape::Util::Quantity::convert(value, &unit, &px); } // end of sp_export_value_get_px() /** diff --git a/src/ui/dialog/export.h b/src/ui/dialog/export.h index b10c98fd2..f324f5dc5 100644 --- a/src/ui/dialog/export.h +++ b/src/ui/dialog/export.h @@ -171,6 +171,11 @@ private: void areaYChange ( Gtk::Adjustment *adj); #endif + /** + * Unit changed callback + */ + void onUnitChanged(); + /** * Hide except selected callback */ @@ -330,7 +335,7 @@ private: /* Unit selector widgets */ Gtk::HBox unitbox; - Gtk::Widget* unit_selector; + Inkscape::UI::Widget::UnitMenu *unit_selector; Gtk::Label units_label; /* Filename widgets */ @@ -365,6 +370,7 @@ private: sigc::connection selectChangedConn; sigc::connection subselChangedConn; sigc::connection selectModifiedConn; + sigc::connection unitChangedConn; }; -- cgit v1.2.3 From ce25410db81c6a22a6b841efdb4790f7f19319ec Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Thu, 18 Jul 2013 10:39:48 -0400 Subject: Ported "ui/dialog/clonetiler.*". (bzr r12380.1.23) --- src/ui/dialog/clonetiler.cpp | 86 +++++++++++++++++++++++++++----------------- src/ui/dialog/clonetiler.h | 20 +++++++++-- 2 files changed, 72 insertions(+), 34 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index 00bb6f0e2..d270afc3f 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -34,8 +34,8 @@ #include "document.h" #include "document-undo.h" #include "filter-chemistry.h" -#include "helper/unit-menu.h" -#include "helper/units.h" +#include "ui/widget/unit-menu.h" +#include "util/units.h" #include "helper/window.h" #include "inkscape.h" #include "interface.h" @@ -1092,35 +1092,38 @@ CloneTiler::CloneTiler (void) : g_object_set_data (G_OBJECT(dlg), "widthheight", (gpointer) hb); // unitmenu - GtkWidget *u = sp_unit_selector_new (SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE); - //sp_unit_selector_set_unit (SP_UNIT_SELECTOR(u), sp_desktop_namedview(SP_ACTIVE_DESKTOP)->doc_units); + unit_menu = new Inkscape::UI::Widget::UnitMenu(); + unit_menu->setUnitType(Inkscape::Util::UNIT_TYPE_LINEAR); + unit_menu->setUnit(sp_desktop_namedview(SP_ACTIVE_DESKTOP)->doc_units->abbr); + unitChangedConn = unit_menu->signal_changed().connect(sigc::mem_fun(*this, &CloneTiler::clonetiler_unit_changed)); { // Width spinbutton #if WITH_GTKMM_3_0 - Glib::RefPtr a = Gtk::Adjustment::create(0.0, -1e6, 1e6, 1.0, 10.0, 0); + fill_width = Gtk::Adjustment::create(0.0, -1e6, 1e6, 1.0, 10.0, 0); #else - Gtk::Adjustment *a = new Gtk::Adjustment (0.0, -1e6, 1e6, 1.0, 10.0, 0); + fill_width = new Gtk::Adjustment (0.0, -1e6, 1e6, 1.0, 10.0, 0); #endif - sp_unit_selector_add_adjustment (SP_UNIT_SELECTOR (u), GTK_ADJUSTMENT (a->gobj())); double value = prefs->getDouble(prefs_path + "fillwidth", 50.0); - SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(u)); - gdouble const units = sp_pixels_get_units (value, unit); - a->set_value (units); + Inkscape::Util::Unit const unit = unit_menu->getUnit(); + Inkscape::Util::UnitTable unit_table; + Inkscape::Util::Unit const px = unit_table.getUnit("px"); + gdouble const units = Inkscape::Util::Quantity::convert(value, &px, &unit); + fill_width->set_value (units); #if WITH_GTKMM_3_0 - Inkscape::UI::Widget::SpinButton *e = new Inkscape::UI::Widget::SpinButton(a, 1.0, 2); + Inkscape::UI::Widget::SpinButton *e = new Inkscape::UI::Widget::SpinButton(fill_width, 1.0, 2); #else - Inkscape::UI::Widget::SpinButton *e = new Inkscape::UI::Widget::SpinButton (*a, 1.0, 2); + Inkscape::UI::Widget::SpinButton *e = new Inkscape::UI::Widget::SpinButton (*fill_width, 1.0, 2); #endif e->set_tooltip_text (_("Width of the rectangle to be filled")); e->set_width_chars (7); e->set_digits (4); gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(e->gobj()), TRUE, TRUE, 0); // TODO: C++ification - g_signal_connect(G_OBJECT(a->gobj()), "value_changed", - G_CALLBACK(clonetiler_fill_width_changed), u); + g_signal_connect(G_OBJECT(fill_width->gobj()), "value_changed", + G_CALLBACK(clonetiler_fill_width_changed), unit_menu); } { GtkWidget *l = gtk_label_new (""); @@ -1132,32 +1135,33 @@ CloneTiler::CloneTiler (void) : { // Height spinbutton #if WITH_GTKMM_3_0 - Glib::RefPtr a = Gtk::Adjustment::create(0.0, -1e6, 1e6, 1.0, 10.0, 0); + fill_height = Gtk::Adjustment::create(0.0, -1e6, 1e6, 1.0, 10.0, 0); #else - Gtk::Adjustment *a = new Gtk::Adjustment (0.0, -1e6, 1e6, 1.0, 10.0, 0); + fill_height = new Gtk::Adjustment (0.0, -1e6, 1e6, 1.0, 10.0, 0); #endif - sp_unit_selector_add_adjustment (SP_UNIT_SELECTOR (u), GTK_ADJUSTMENT (a->gobj())); double value = prefs->getDouble(prefs_path + "fillheight", 50.0); - SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(u)); - gdouble const units = sp_pixels_get_units (value, unit); - a->set_value (units); + Inkscape::Util::Unit const unit = unit_menu->getUnit(); + Inkscape::Util::UnitTable unit_table; + Inkscape::Util::Unit const px = unit_table.getUnit("px"); + gdouble const units = Inkscape::Util::Quantity::convert(value, &px, &unit); + fill_height->set_value (units); #if WITH_GTKMM_3_0 - Inkscape::UI::Widget::SpinButton *e = new Inkscape::UI::Widget::SpinButton(a, 1.0, 2); + Inkscape::UI::Widget::SpinButton *e = new Inkscape::UI::Widget::SpinButton(fill_height, 1.0, 2); #else - Inkscape::UI::Widget::SpinButton *e = new Inkscape::UI::Widget::SpinButton (*a, 1.0, 2); + Inkscape::UI::Widget::SpinButton *e = new Inkscape::UI::Widget::SpinButton (*fill_height, 1.0, 2); #endif e->set_tooltip_text (_("Height of the rectangle to be filled")); e->set_width_chars (7); e->set_digits (4); gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(e->gobj()), TRUE, TRUE, 0); // TODO: C++ification - g_signal_connect(G_OBJECT(a->gobj()), "value_changed", - G_CALLBACK(clonetiler_fill_height_changed), u); + g_signal_connect(G_OBJECT(fill_height->gobj()), "value_changed", + G_CALLBACK(clonetiler_fill_height_changed), unit_menu); } - gtk_box_pack_start (GTK_BOX (hb), u, TRUE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (hb), (GtkWidget*) unit_menu->gobj(), TRUE, TRUE, 0); clonetiler_table_attach (table, hb, 0.0, 2, 2); } @@ -2944,26 +2948,45 @@ void CloneTiler::clonetiler_switch_to_fill(GtkToggleButton * /*tb*/, GtkWidget * -void CloneTiler::clonetiler_fill_width_changed(GtkAdjustment *adj, GtkWidget *u) +void CloneTiler::clonetiler_fill_width_changed(GtkAdjustment *adj, Inkscape::UI::Widget::UnitMenu *u) { gdouble const raw_dist = gtk_adjustment_get_value (adj); - SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(u)); - gdouble const pixels = sp_units_get_pixels (raw_dist, unit); + Inkscape::Util::Unit const unit = u->getUnit(); + Inkscape::Util::UnitTable unit_table; + Inkscape::Util::Unit const px = unit_table.getUnit("px"); + gdouble const pixels = Inkscape::Util::Quantity::convert(raw_dist, &unit, &px); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setDouble(prefs_path + "fillwidth", pixels); } -void CloneTiler::clonetiler_fill_height_changed(GtkAdjustment *adj, GtkWidget *u) +void CloneTiler::clonetiler_fill_height_changed(GtkAdjustment *adj, Inkscape::UI::Widget::UnitMenu *u) { gdouble const raw_dist = gtk_adjustment_get_value (adj); - SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(u)); - gdouble const pixels = sp_units_get_pixels (raw_dist, unit); + Inkscape::Util::Unit const unit = u->getUnit(); + Inkscape::Util::UnitTable unit_table; + Inkscape::Util::Unit const px = unit_table.getUnit("px"); + gdouble const pixels = Inkscape::Util::Quantity::convert(raw_dist, &unit, &px); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setDouble(prefs_path + "fillheight", pixels); } +void CloneTiler::clonetiler_unit_changed() +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + gdouble width_pixels = prefs->getDouble(prefs_path + "fillwidth"); + gdouble height_pixels = prefs->getDouble(prefs_path + "fillheight"); + + Inkscape::Util::Unit unit = unit_menu->getUnit(); + Inkscape::Util::UnitTable unit_table; + Inkscape::Util::Unit px = unit_table.getUnit("px"); + + gdouble width_value = Inkscape::Util::Quantity::convert(width_pixels, &px, &unit); + gdouble height_value = Inkscape::Util::Quantity::convert(height_pixels, &px, &unit); + gtk_adjustment_set_value(fill_width->gobj(), width_value); + gtk_adjustment_set_value(fill_height->gobj(), height_value); +} void CloneTiler::clonetiler_do_pick_toggled(GtkToggleButton *tb, GtkWidget *dlg) { @@ -2977,7 +3000,6 @@ void CloneTiler::clonetiler_do_pick_toggled(GtkToggleButton *tb, GtkWidget *dlg) } } - } } } diff --git a/src/ui/dialog/clonetiler.h b/src/ui/dialog/clonetiler.h index 7ec30cfaa..e2a0240ee 100644 --- a/src/ui/dialog/clonetiler.h +++ b/src/ui/dialog/clonetiler.h @@ -19,6 +19,11 @@ namespace Inkscape { namespace UI { + +namespace Widget { + class UnitMenu; +} + namespace Dialog { class CloneTiler : public Widget::Panel { @@ -45,8 +50,9 @@ protected: static void clonetiler_do_pick_toggled(GtkToggleButton *tb, GtkWidget *dlg); static void clonetiler_pick_to(GtkToggleButton *tb, gpointer data); static void clonetiler_xy_changed(GtkAdjustment *adj, gpointer data); - static void clonetiler_fill_width_changed(GtkAdjustment *adj, GtkWidget *u); - static void clonetiler_fill_height_changed(GtkAdjustment *adj, GtkWidget *u); + static void clonetiler_fill_width_changed(GtkAdjustment *adj, Inkscape::UI::Widget::UnitMenu *u); + static void clonetiler_fill_height_changed(GtkAdjustment *adj, Inkscape::UI::Widget::UnitMenu *u); + void clonetiler_unit_changed(); static void clonetiler_switch_to_create(GtkToggleButton */*tb*/, GtkWidget *dlg); static void clonetiler_switch_to_fill(GtkToggleButton */*tb*/, GtkWidget *dlg); static void clonetiler_keep_bbox_toggled(GtkToggleButton *tb, gpointer /*data*/); @@ -112,12 +118,22 @@ private: DesktopTracker deskTrack; Inkscape::UI::Widget::ColorPicker *color_picker; GtkSizeGroup* table_row_labels; + Inkscape::UI::Widget::UnitMenu *unit_menu; + +#if WITH_GTKMM_3_0 + Glib::RefPtr fill_width; + Glib::RefPtr fill_height; +#else + Gtk::Adjustment *fill_width; + Gtk::Adjustment *fill_height; +#endif sigc::connection desktopChangeConn; sigc::connection selectChangedConn; sigc::connection subselChangedConn; sigc::connection selectModifiedConn; sigc::connection color_changed_connection; + sigc::connection unitChangedConn; /** * Can be invoked for setting the desktop. Currently not used. -- cgit v1.2.3 From 3772fc428950b2b946a1bd7c7c97e06219c3165f Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Thu, 18 Jul 2013 17:21:24 -0400 Subject: Switch unit functions from using pointer arguements to reference arguements. (bzr r12380.1.28) --- src/ui/dialog/clonetiler.cpp | 17 ++++++----------- src/ui/dialog/export.cpp | 6 ++---- src/ui/widget/page-sizer.cpp | 17 ++++++----------- src/ui/widget/unit-tracker.cpp | 7 +++---- 4 files changed, 17 insertions(+), 30 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index d270afc3f..abb2512f7 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -1108,8 +1108,7 @@ CloneTiler::CloneTiler (void) : double value = prefs->getDouble(prefs_path + "fillwidth", 50.0); Inkscape::Util::Unit const unit = unit_menu->getUnit(); Inkscape::Util::UnitTable unit_table; - Inkscape::Util::Unit const px = unit_table.getUnit("px"); - gdouble const units = Inkscape::Util::Quantity::convert(value, &px, &unit); + gdouble const units = Inkscape::Util::Quantity::convert(value, "px", unit); fill_width->set_value (units); #if WITH_GTKMM_3_0 @@ -1143,8 +1142,7 @@ CloneTiler::CloneTiler (void) : double value = prefs->getDouble(prefs_path + "fillheight", 50.0); Inkscape::Util::Unit const unit = unit_menu->getUnit(); Inkscape::Util::UnitTable unit_table; - Inkscape::Util::Unit const px = unit_table.getUnit("px"); - gdouble const units = Inkscape::Util::Quantity::convert(value, &px, &unit); + gdouble const units = Inkscape::Util::Quantity::convert(value, "px", unit); fill_height->set_value (units); #if WITH_GTKMM_3_0 @@ -2953,8 +2951,7 @@ void CloneTiler::clonetiler_fill_width_changed(GtkAdjustment *adj, Inkscape::UI: gdouble const raw_dist = gtk_adjustment_get_value (adj); Inkscape::Util::Unit const unit = u->getUnit(); Inkscape::Util::UnitTable unit_table; - Inkscape::Util::Unit const px = unit_table.getUnit("px"); - gdouble const pixels = Inkscape::Util::Quantity::convert(raw_dist, &unit, &px); + gdouble const pixels = Inkscape::Util::Quantity::convert(raw_dist, unit, "px"); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setDouble(prefs_path + "fillwidth", pixels); @@ -2965,8 +2962,7 @@ void CloneTiler::clonetiler_fill_height_changed(GtkAdjustment *adj, Inkscape::UI gdouble const raw_dist = gtk_adjustment_get_value (adj); Inkscape::Util::Unit const unit = u->getUnit(); Inkscape::Util::UnitTable unit_table; - Inkscape::Util::Unit const px = unit_table.getUnit("px"); - gdouble const pixels = Inkscape::Util::Quantity::convert(raw_dist, &unit, &px); + gdouble const pixels = Inkscape::Util::Quantity::convert(raw_dist, unit, "px"); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setDouble(prefs_path + "fillheight", pixels); @@ -2980,10 +2976,9 @@ void CloneTiler::clonetiler_unit_changed() Inkscape::Util::Unit unit = unit_menu->getUnit(); Inkscape::Util::UnitTable unit_table; - Inkscape::Util::Unit px = unit_table.getUnit("px"); - gdouble width_value = Inkscape::Util::Quantity::convert(width_pixels, &px, &unit); - gdouble height_value = Inkscape::Util::Quantity::convert(height_pixels, &px, &unit); + gdouble width_value = Inkscape::Util::Quantity::convert(width_pixels, "px", unit); + gdouble height_value = Inkscape::Util::Quantity::convert(height_pixels, "px", unit); gtk_adjustment_set_value(fill_width->gobj(), width_value); gtk_adjustment_set_value(fill_height->gobj(), height_value); } diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 61fb6e4ee..5cb9357c3 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -1885,9 +1885,8 @@ void Export::setValuePx( Gtk::Adjustment *adj, double val) { const Unit unit = unit_selector->getUnit(); Inkscape::Util::UnitTable unit_table; - Inkscape::Util::Unit px = unit_table.getUnit("px"); - setValue(adj, Inkscape::Util::Quantity::convert(val, &px, &unit)); + setValue(adj, Inkscape::Util::Quantity::convert(val, "px", unit)); return; } @@ -1937,9 +1936,8 @@ float Export::getValuePx( Gtk::Adjustment *adj ) float value = getValue( adj); const Unit unit = unit_selector->getUnit(); Inkscape::Util::UnitTable unit_table; - Inkscape::Util::Unit px = unit_table.getUnit("px"); - return Inkscape::Util::Quantity::convert(value, &unit, &px); + return Inkscape::Util::Quantity::convert(value, unit, "px"); } // end of sp_export_value_get_px() /** diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index 73b75090b..f6392cfd8 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -228,10 +228,6 @@ static PaperSizeRec const inkscape_papers[] = { //# P A G E S I Z E R //######################################################################## -//The default unit for this widget and its calculations -static Inkscape::Util::Unit _px_unit = unit_table.getUnit("px"); - - /** * Constructor */ @@ -481,8 +477,8 @@ PageSizer::setDim (double w, double h, bool changeList) if (SP_ACTIVE_DESKTOP && !_widgetRegistry->isUpdating()) { SPDocument *doc = sp_desktop_document(SP_ACTIVE_DESKTOP); double const old_height = doc->getHeight(); - doc->setWidth (Inkscape::Util::Quantity(w, &_px_unit)); - doc->setHeight (Inkscape::Util::Quantity(h, &_px_unit)); + doc->setWidth (Inkscape::Util::Quantity(w, "px")); + doc->setHeight (Inkscape::Util::Quantity(h, "px")); // The origin for the user is in the lower left corner; this point should remain stationary when // changing the page size. The SVG's origin however is in the upper left corner, so we must compensate for this Geom::Translate const vert_offset(Geom::Point(0, (old_height - h))); @@ -567,8 +563,8 @@ PageSizer::find_paper_size (double w, double h) const iter != _paperSizeTable.end() ; ++iter) { PaperSize paper = iter->second; Inkscape::Util::Unit const &i_unit = paper.unit; - double smallX = Inkscape::Util::Quantity::convert(paper.smaller, &i_unit, &_px_unit); - double largeX = Inkscape::Util::Quantity::convert(paper.larger, &i_unit, &_px_unit); + double smallX = Inkscape::Util::Quantity::convert(paper.smaller, i_unit, "px"); + double largeX = Inkscape::Util::Quantity::convert(paper.larger, i_unit, "px"); g_return_val_if_fail(smallX <= largeX, _paperSizeListStore->children().end()); @@ -659,9 +655,8 @@ PageSizer::on_paper_size_list_changed() _landscape = _landscapeButton.get_active(); } - Inkscape::Util::Unit const &src_unit = paper.unit; - w = Inkscape::Util::Quantity::convert(w, &src_unit, &_px_unit); - h = Inkscape::Util::Quantity::convert(h, &src_unit, &_px_unit); + w = Inkscape::Util::Quantity::convert(w, paper.unit, "px"); + h = Inkscape::Util::Quantity::convert(h, paper.unit, "px"); if (_landscape) setDim (h, w, false); diff --git a/src/ui/widget/unit-tracker.cpp b/src/ui/widget/unit-tracker.cpp index df78e21dd..372419c3b 100644 --- a/src/ui/widget/unit-tracker.cpp +++ b/src/ui/widget/unit-tracker.cpp @@ -224,7 +224,6 @@ void UnitTracker::_setActive(gint active) void UnitTracker::_fixupAdjustments(Inkscape::Util::Unit const oldUnit, Inkscape::Util::Unit const newUnit) { _isUpdating = true; - Inkscape::Util::Unit px = _unit_table.getUnit("px"); for ( GSList *cur = _adjList ; cur ; cur = g_slist_next(cur) ) { GtkAdjustment *adj = GTK_ADJUSTMENT(cur->data); gdouble oldVal = gtk_adjustment_get_value(adj); @@ -234,15 +233,15 @@ void UnitTracker::_fixupAdjustments(Inkscape::Util::Unit const oldUnit, Inkscape && (newUnit.type == Inkscape::Util::UNIT_TYPE_DIMENSIONLESS) ) { val = newUnit.factor; - _priorValues[adj] = Inkscape::Util::Quantity::convert(oldVal, &oldUnit, &px); + _priorValues[adj] = Inkscape::Util::Quantity::convert(oldVal, oldUnit, "px"); } else if ( (oldUnit.type == Inkscape::Util::UNIT_TYPE_DIMENSIONLESS) && (newUnit.type != Inkscape::Util::UNIT_TYPE_DIMENSIONLESS) ) { if (_priorValues.find(adj) != _priorValues.end()) { - val = Inkscape::Util::Quantity::convert(_priorValues[adj], &newUnit, &px); + val = Inkscape::Util::Quantity::convert(_priorValues[adj], newUnit, "px"); } } else { - val = Inkscape::Util::Quantity::convert(oldVal, &oldUnit, &newUnit); + val = Inkscape::Util::Quantity::convert(oldVal, oldUnit, newUnit); } gtk_adjustment_set_value(adj, val); -- cgit v1.2.3 From 231a793d4d28f83b55fe9104a6593d72bca75219 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Fri, 19 Jul 2013 14:32:09 -0400 Subject: Removed "helper/units.h" from "ui/dialog/document-properties.cpp". (bzr r12380.1.33) --- src/ui/dialog/document-properties.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index af462a1df..77fb182e5 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -28,7 +28,6 @@ #include "document.h" #include "desktop-handles.h" #include "desktop.h" -#include "helper/units.h" #include "inkscape.h" #include "io/sys.h" #include "preferences.h" @@ -1431,8 +1430,8 @@ void DocumentProperties::update() _rcp_bord.setRgba32 (nv->bordercolor); _rcb_shad.setActive (nv->showpageshadow); - //if (nv->doc_units) - // _rum_deflt.setUnit (nv->doc_units); + if (nv->doc_units) + _rum_deflt.setUnit (nv->doc_units->abbr); double const doc_w_px = sp_desktop_document(dt)->getWidth(); double const doc_h_px = sp_desktop_document(dt)->getHeight(); -- cgit v1.2.3 From 0fb0f1dd09f4c03a420dd8abf2089b81cd6d30d7 Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Fri, 19 Jul 2013 20:35:26 +0200 Subject: New From Template ui rearrangement (bzr r12379.2.11) --- src/ui/dialog/Makefile_insert | 4 +- src/ui/dialog/new-from-template.cpp | 10 +-- src/ui/dialog/new-from-template.h | 6 +- src/ui/dialog/static-template-load-tab.cpp | 80 --------------------- src/ui/dialog/static-template-load-tab.h | 44 ------------ src/ui/dialog/template-load-tab.cpp | 48 +++++-------- src/ui/dialog/template-load-tab.h | 20 +++--- src/ui/dialog/template-widget.cpp | 110 +++++++++++++++++++++++++++++ src/ui/dialog/template-widget.h | 48 +++++++++++++ 9 files changed, 193 insertions(+), 177 deletions(-) delete mode 100644 src/ui/dialog/static-template-load-tab.cpp delete mode 100644 src/ui/dialog/static-template-load-tab.h create mode 100644 src/ui/dialog/template-widget.cpp create mode 100644 src/ui/dialog/template-widget.h (limited to 'src/ui') diff --git a/src/ui/dialog/Makefile_insert b/src/ui/dialog/Makefile_insert index 4a34cc71c..41e3ecbf8 100644 --- a/src/ui/dialog/Makefile_insert +++ b/src/ui/dialog/Makefile_insert @@ -87,8 +87,6 @@ ink_common_sources += \ ui/dialog/scriptdialog.h \ ui/dialog/spellcheck.cpp \ ui/dialog/spellcheck.h \ - ui/dialog/static-template-load-tab.cpp \ - ui/dialog/static-template-load-tab.h \ ui/dialog/svg-fonts-dialog.cpp \ ui/dialog/svg-fonts-dialog.h \ ui/dialog/swatches.cpp \ @@ -97,6 +95,8 @@ ink_common_sources += \ ui/dialog/symbols.h \ ui/dialog/template-load-tab.cpp \ ui/dialog/template-load-tab.h \ + ui/dialog/template-widget.cpp \ + ui/dialog/template-widget.h \ ui/dialog/text-edit.cpp \ ui/dialog/text-edit.h \ ui/dialog/tile.cpp \ diff --git a/src/ui/dialog/new-from-template.cpp b/src/ui/dialog/new-from-template.cpp index 765ec0bce..241da3f43 100644 --- a/src/ui/dialog/new-from-template.cpp +++ b/src/ui/dialog/new-from-template.cpp @@ -27,9 +27,7 @@ NewFromTemplate::NewFromTemplate() resize(400, 400); get_vbox()->pack_start(_main_widget); - _main_widget.append_page(_tab1, "Static Templates"); - _main_widget.append_page(_tab2, "Procedural Templates"); - + Gtk::Alignment *align; align = manage(new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER, 0.0, 0.0)); get_vbox()->pack_end(*align, Gtk::PACK_SHRINK, 5); @@ -44,11 +42,7 @@ NewFromTemplate::NewFromTemplate() void NewFromTemplate::_createFromTemplate() { - if ( _main_widget.get_current_page() == 0 ) { - _tab1.createTemplate(); - } else { - _tab2.createTemplate(); - } + _main_widget.createTemplate(); response(0); } diff --git a/src/ui/dialog/new-from-template.h b/src/ui/dialog/new-from-template.h index 59b61a015..05af98a50 100644 --- a/src/ui/dialog/new-from-template.h +++ b/src/ui/dialog/new-from-template.h @@ -16,7 +16,6 @@ #include #include "template-load-tab.h" -#include "static-template-load-tab.h" namespace Inkscape { @@ -30,10 +29,9 @@ public: private: NewFromTemplate(); - Gtk::Notebook _main_widget; Gtk::Button _create_template_button; - StaticTemplateLoadTab _tab1; - TemplateLoadTab _tab2; + //StaticTemplateLoadTab _tab1; + TemplateLoadTab _main_widget; void _createFromTemplate(); }; diff --git a/src/ui/dialog/static-template-load-tab.cpp b/src/ui/dialog/static-template-load-tab.cpp deleted file mode 100644 index 35f3430fb..000000000 --- a/src/ui/dialog/static-template-load-tab.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/** @file - * @brief New From Template static templates tab - implementation - */ -/* Authors: - * Jan Darowski , supervised by Krzysztof Kosiński - * - * Copyright (C) 2013 Authors - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include "static-template-load-tab.h" - -#include -#include -#include -#include - -#include "file.h" - - -namespace Inkscape { -namespace UI { - - -StaticTemplateLoadTab::StaticTemplateLoadTab() - : TemplateLoadTab() - , _more_info_button("More info") - , _short_description_label("Short description - I like trains. ad asda asd asdweqe gdfg") - , _template_author_label("by template_author") - , _template_name_label("Template_name") - , _preview_image("preview.png") -{ - _loading_path = ""; - _loadTemplates(); - _initLists(); - - _info_box.pack_start(_template_name_label, Gtk::PACK_SHRINK, 4); - _info_box.pack_start(_template_author_label, Gtk::PACK_SHRINK, 0); - _info_box.pack_start(_preview_image, Gtk::PACK_SHRINK, 15); - _info_box.pack_start(_short_description_label, Gtk::PACK_SHRINK, 4); - - _short_description_label.set_line_wrap(true); - _short_description_label.set_size_request(200); - - Gtk::Alignment *align; - align = manage(new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER, 0.0, 0.0)); - _info_box.pack_start(*align, Gtk::PACK_SHRINK, 5); - align->add(_more_info_button); - - _more_info_button.signal_pressed().connect( - sigc::mem_fun(*this, &StaticTemplateLoadTab::_displayTemplateDetails)); -} - - -void StaticTemplateLoadTab::createTemplate() -{ - Glib::ustring path; - if (_tdata.find(_current_template) != _tdata.end()){ - path = _tdata[_current_template].path; - } - else - path = ""; - - sp_file_new(path); -} - - -void StaticTemplateLoadTab::_displayTemplateInfo() -{ - TemplateLoadTab::_displayTemplateInfo(); - _template_name_label.set_text(_current_template); - _template_author_label.set_text(_tdata[_current_template].author); - _short_description_label.set_text(_tdata[_current_template].short_description); - - Glib::ustring imagePath = Glib::build_filename(Glib::path_get_dirname(_tdata[_current_template].path), _tdata[_current_template].preview_name); - _preview_image.set(imagePath); -} - -} -} diff --git a/src/ui/dialog/static-template-load-tab.h b/src/ui/dialog/static-template-load-tab.h deleted file mode 100644 index 9b19c495a..000000000 --- a/src/ui/dialog/static-template-load-tab.h +++ /dev/null @@ -1,44 +0,0 @@ -/** @file - * @brief New From Template static templates tab - */ -/* Authors: - * Jan Darowski , supervised by Krzysztof Kosiński - * - * Copyright (C) 2013 Authors - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#ifndef INKSCAPE_SEEN_UI_DIALOG_STATIC_TEMPLATE_LOAD_TAB_H -#define INKSCAPE_SEEN_UI_DIALOG_STATIC_TEMPLATE_LOAD_TAB_H - -#include "template-load-tab.h" - -#include -#include -#include - - -namespace Inkscape { -namespace UI { - - -class StaticTemplateLoadTab : public TemplateLoadTab -{ -public: - StaticTemplateLoadTab(); - virtual void createTemplate(); - -protected: - virtual void _displayTemplateInfo(); - - Gtk::Button _more_info_button; - Gtk::Label _short_description_label; - Gtk::Label _template_author_label; - Gtk::Label _template_name_label; - Gtk::Image _preview_image; -}; - -} -} - -#endif diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index 90980dc39..70dadfc52 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -23,6 +23,8 @@ #include "xml/document.h" #include "xml/node.h" +#include "template-widget.h" + // #include @@ -39,10 +41,11 @@ namespace UI { TemplateLoadTab::TemplateLoadTab() : _current_keyword("") , _keywords_combo(true) - ,_current_search_type(ALL) + , _current_search_type(ALL) { set_border_width(10); + _info_widget = manage(new TemplateWidget()); Gtk::Label *title; title = manage(new Gtk::Label("Search:")); _tlist_box.pack_start(*title, Gtk::PACK_SHRINK, 10); @@ -53,11 +56,11 @@ TemplateLoadTab::TemplateLoadTab() _tlist_box.pack_start(*title, Gtk::PACK_SHRINK, 10); title = manage(new Gtk::Label("Selected template")); - _info_box.pack_start(*title, Gtk::PACK_SHRINK, 10); + _info_widget->pack_start(*title, Gtk::PACK_SHRINK, 10); add(_main_box); _main_box.pack_start(_tlist_box, Gtk::PACK_SHRINK, 20); - _main_box.pack_start(_info_box, Gtk::PACK_EXPAND_WIDGET, 10); + _main_box.pack_start(*_info_widget, Gtk::PACK_EXPAND_WIDGET, 10); Gtk::ScrolledWindow *scrolled; scrolled = manage(new Gtk::ScrolledWindow()); @@ -68,6 +71,11 @@ TemplateLoadTab::TemplateLoadTab() _keywords_combo.signal_changed().connect( sigc::mem_fun(*this, &TemplateLoadTab::_keywordSelected)); this->show_all(); + + + _loading_path = ""; + _loadTemplates(); + _initLists(); } @@ -78,7 +86,7 @@ TemplateLoadTab::~TemplateLoadTab() void TemplateLoadTab::createTemplate() { - std::cout << "Default Template Tab" << std::endl; + _info_widget->create(); } @@ -87,7 +95,10 @@ void TemplateLoadTab::_displayTemplateInfo() Glib::RefPtr templateSelectionRef = _tlist_view.get_selection(); if (templateSelectionRef->get_selected()) { _current_template = (*templateSelectionRef->get_selected())[_columns.textValue]; + + _info_widget->display(_tdata[_current_template]); } + } @@ -194,7 +205,8 @@ TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(const Glib:: { TemplateData result; result.path = path; - result.display_name = Glib::path_get_basename(path);/* + result.display_name = Glib::path_get_basename(path); + result.is_procedural = false;/* result.short_description = "LaLaLaLa"; result.author = "JAASDASD";*/ @@ -264,31 +276,5 @@ void TemplateLoadTab::_getTemplatesFromDir(const Glib::ustring &path) } } -void TemplateLoadTab::_displayTemplateDetails() -{ - if (_current_template == "") - return; - - TemplateData &tmpl = _tdata[_current_template]; - - Glib::ustring message = tmpl.display_name + "\n\n" + - _("Path: ") + tmpl.path + "\n\n"; - - if (tmpl.long_description != "") - message += _("Description: ") + _tdata[_current_template].long_description + "\n\n"; - if (tmpl.keywords.size() > 0){ - message += _("Keywords: "); - for (std::set::iterator it = tmpl.keywords.begin(); it != tmpl.keywords.end(); ++it) - message += *it + " "; - message += "\n\n"; - } - - if (tmpl.author != "") - message += _("By: ") + _tdata[_current_template].author + " " + tmpl.creation_date + "\n\n"; - - Gtk::MessageDialog dl(message, false, Gtk::MESSAGE_OTHER); - dl.run(); -} - } } diff --git a/src/ui/dialog/template-load-tab.h b/src/ui/dialog/template-load-tab.h index 8290f1b3f..48ad23ae9 100644 --- a/src/ui/dialog/template-load-tab.h +++ b/src/ui/dialog/template-load-tab.h @@ -22,19 +22,16 @@ namespace Inkscape { namespace UI { - + +class TemplateWidget; class TemplateLoadTab : public Gtk::Frame { public: - TemplateLoadTab(); - virtual ~TemplateLoadTab(); - virtual void createTemplate(); - -protected: struct TemplateData { + bool is_procedural; Glib::ustring path; Glib::ustring display_name; Glib::ustring author; @@ -45,6 +42,12 @@ protected: std::set keywords; }; + TemplateLoadTab(); + virtual ~TemplateLoadTab(); + virtual void createTemplate(); + +protected: + class StringModelColumns : public Gtk::TreeModelColumnRecord { public: @@ -68,11 +71,10 @@ protected: virtual void _refreshTemplatesList(); void _loadTemplates(); void _initLists(); - void _displayTemplateDetails(); Gtk::HBox _main_box; Gtk::VBox _tlist_box; - Gtk::VBox _info_box; + TemplateWidget *_info_widget; Gtk::ComboBoxText _keywords_combo; @@ -80,6 +82,8 @@ protected: Glib::RefPtr _tlist_store; StringModelColumns _columns; + + private: enum SearchType { diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp new file mode 100644 index 000000000..dd066c90b --- /dev/null +++ b/src/ui/dialog/template-widget.cpp @@ -0,0 +1,110 @@ + + +/** @file + * @brief New From Template - templates widget - implementation + */ +/* Authors: + * Jan Darowski , supervised by Krzysztof Kosiński + * + * Copyright (C) 2013 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "template-widget.h" +#include "template-load-tab.h" + +#include +#include +#include +#include +#include + +#include "file.h" + +#include +#include +#include + + +namespace Inkscape { +namespace UI { + + +TemplateWidget::TemplateWidget() + : _more_info_button("More info") + , _short_description_label("Short description - I like trains. ad asda asd asdweqe gdfg") + , _template_author_label("by template_author") + , _template_name_label("Template_name") + , _preview_image("preview.png") +{ + pack_start(_template_name_label, Gtk::PACK_SHRINK, 4); + pack_start(_template_author_label, Gtk::PACK_SHRINK, 0); + pack_start(_preview_image, Gtk::PACK_SHRINK, 15); + pack_start(_short_description_label, Gtk::PACK_SHRINK, 4); + + _short_description_label.set_line_wrap(true); + _short_description_label.set_size_request(200); + + Gtk::Alignment *align; + align = manage(new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER, 0.0, 0.0)); + pack_start(*align, Gtk::PACK_SHRINK, 5); + align->add(_more_info_button); + + _more_info_button.signal_pressed().connect( + sigc::mem_fun(*this, &TemplateWidget::_displayTemplateDetails)); +} + + +void TemplateWidget::create() +{ + if (_current_template.path == "") + return; + if (_current_template.is_procedural){ + + } + else { + sp_file_new(_current_template.path); + } +} + + +void TemplateWidget::display(TemplateLoadTab::TemplateData data) +{ + _current_template = data; + if (data.is_procedural){} + else{ + _template_name_label.set_text(_current_template.display_name); + _template_author_label.set_text(_current_template.author); + _short_description_label.set_text(_current_template.short_description); + + Glib::ustring imagePath = Glib::build_filename(Glib::path_get_dirname(_current_template.path), _current_template.preview_name); + _preview_image.set(imagePath); + } +} + +void TemplateWidget::_displayTemplateDetails() +{ + if (_current_template.path == "") + return; + + Glib::ustring message = _current_template.display_name + "\n\n" + + _("Path: ") + _current_template.path + "\n\n"; + + if (_current_template.long_description != "") + message += _("Description: ") + _current_template.long_description + "\n\n"; + if (_current_template.keywords.size() > 0){ + message += _("Keywords: "); + for (std::set::iterator it = _current_template.keywords.begin(); it != _current_template.keywords.end(); ++it) + message += *it + " "; + message += "\n\n"; + } + + if (_current_template.author != "") + message += _("By: ") + _current_template.author + " " + _current_template.creation_date + "\n\n"; + + Gtk::MessageDialog dl(message, false, Gtk::MESSAGE_OTHER); + dl.run(); +} + +} +} diff --git a/src/ui/dialog/template-widget.h b/src/ui/dialog/template-widget.h new file mode 100644 index 000000000..83024e0d8 --- /dev/null +++ b/src/ui/dialog/template-widget.h @@ -0,0 +1,48 @@ +/** @file + * @brief New From Template - template widget + */ +/* Authors: + * Jan Darowski , supervised by Krzysztof Kosiński + * + * Copyright (C) 2013 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifndef INKSCAPE_SEEN_UI_DIALOG_TEMPLATE_WIDGET_H +#define INKSCAPE_SEEN_UI_DIALOG_TEMPLATE_WIDGET_H + +#include "template-load-tab.h" +#include + + + +namespace Inkscape { +namespace UI { + +class TemplateLoadTab; + + +class TemplateWidget : public Gtk::VBox +{ +public: + TemplateWidget (); + void create(); + void display(TemplateLoadTab::TemplateData); + +private: + TemplateLoadTab::TemplateData _current_template; + + Gtk::Button _more_info_button; + Gtk::Label _short_description_label; + Gtk::Label _template_author_label; + Gtk::Label _template_name_label; + Gtk::Image _preview_image; + + void _displayTemplateDetails(); + +}; + +} +} + +#endif -- cgit v1.2.3 From bd2265c6e8a1496f40692752f9d710f36a24fada Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Fri, 19 Jul 2013 20:57:07 +0200 Subject: Minor code fixes (bzr r12379.2.12) --- src/ui/dialog/new-from-template.cpp | 9 +++++---- src/ui/dialog/new-from-template.h | 2 -- src/ui/dialog/template-load-tab.cpp | 26 ++++++-------------------- src/ui/dialog/template-load-tab.h | 8 ++------ src/ui/dialog/template-widget.cpp | 23 ++++++++++------------- src/ui/dialog/template-widget.h | 4 ---- 6 files changed, 23 insertions(+), 49 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/new-from-template.cpp b/src/ui/dialog/new-from-template.cpp index 241da3f43..6598aecdf 100644 --- a/src/ui/dialog/new-from-template.cpp +++ b/src/ui/dialog/new-from-template.cpp @@ -10,10 +10,10 @@ #include "new-from-template.h" +#include "file.h" #include - -#include "file.h" +#include namespace Inkscape { @@ -21,9 +21,9 @@ namespace UI { NewFromTemplate::NewFromTemplate() - : _create_template_button("Create from template") + : _create_template_button(_("Create from template")) { - set_title("New From Template"); + set_title(_("New From Template")); resize(400, 400); get_vbox()->pack_start(_main_widget); @@ -47,6 +47,7 @@ void NewFromTemplate::_createFromTemplate() response(0); } + void NewFromTemplate::load_new_from_template() { NewFromTemplate dl; diff --git a/src/ui/dialog/new-from-template.h b/src/ui/dialog/new-from-template.h index 05af98a50..8ebcb2863 100644 --- a/src/ui/dialog/new-from-template.h +++ b/src/ui/dialog/new-from-template.h @@ -13,7 +13,6 @@ #include #include -#include #include "template-load-tab.h" @@ -30,7 +29,6 @@ public: private: NewFromTemplate(); Gtk::Button _create_template_button; - //StaticTemplateLoadTab _tab1; TemplateLoadTab _main_widget; void _createFromTemplate(); diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index 70dadfc52..ded4fc6fd 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -9,9 +9,11 @@ */ #include "template-load-tab.h" +#include "template-widget.h" #include #include +#include #include #include "interface.h" @@ -23,16 +25,6 @@ #include "xml/document.h" #include "xml/node.h" -#include "template-widget.h" - -// -#include - -#include -#include -#include -// - namespace Inkscape { namespace UI { @@ -47,17 +39,14 @@ TemplateLoadTab::TemplateLoadTab() _info_widget = manage(new TemplateWidget()); Gtk::Label *title; - title = manage(new Gtk::Label("Search:")); + title = manage(new Gtk::Label(_("Search:"))); _tlist_box.pack_start(*title, Gtk::PACK_SHRINK, 10); _tlist_box.pack_start(_keywords_combo, Gtk::PACK_SHRINK, 0); - title = manage(new Gtk::Label("Templates")); + title = manage(new Gtk::Label(_("Templates"))); _tlist_box.pack_start(*title, Gtk::PACK_SHRINK, 10); - title = manage(new Gtk::Label("Selected template")); - _info_widget->pack_start(*title, Gtk::PACK_SHRINK, 10); - add(_main_box); _main_box.pack_start(_tlist_box, Gtk::PACK_SHRINK, 20); _main_box.pack_start(*_info_widget, Gtk::PACK_EXPAND_WIDGET, 10); @@ -72,7 +61,6 @@ TemplateLoadTab::TemplateLoadTab() sigc::mem_fun(*this, &TemplateLoadTab::_keywordSelected)); this->show_all(); - _loading_path = ""; _loadTemplates(); _initLists(); @@ -139,7 +127,7 @@ void TemplateLoadTab::_keywordSelected() else _current_search_type = LIST_KEYWORD; - if (_current_keyword == "" || _current_keyword == "All") + if (_current_keyword == "" || _current_keyword == _("All")) _current_search_type = ALL; _refreshTemplatesList(); @@ -206,9 +194,7 @@ TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(const Glib:: TemplateData result; result.path = path; result.display_name = Glib::path_get_basename(path); - result.is_procedural = false;/* - result.short_description = "LaLaLaLa"; - result.author = "JAASDASD";*/ + result.is_procedural = false; Inkscape::XML::Document *rdoc; rdoc = sp_repr_read_file(path.data(), SP_SVG_NS_URI); diff --git a/src/ui/dialog/template-load-tab.h b/src/ui/dialog/template-load-tab.h index 48ad23ae9..cc5229c95 100644 --- a/src/ui/dialog/template-load-tab.h +++ b/src/ui/dialog/template-load-tab.h @@ -46,8 +46,7 @@ public: virtual ~TemplateLoadTab(); virtual void createTemplate(); -protected: - +protected: class StringModelColumns : public Gtk::TreeModelColumnRecord { public: @@ -80,9 +79,7 @@ protected: Gtk::TreeView _tlist_view; Glib::RefPtr _tlist_store; - StringModelColumns _columns; - - + StringModelColumns _columns; private: enum SearchType @@ -97,7 +94,6 @@ private: void _getTemplatesFromDir(const Glib::ustring &); void _keywordSelected(); TemplateData _processTemplateFile(const Glib::ustring &); - }; } diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index dd066c90b..bb2c4a683 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -12,18 +12,13 @@ #include "template-widget.h" #include "template-load-tab.h" +#include "file.h" #include #include #include #include -#include - -#include "file.h" - -#include #include -#include namespace Inkscape { @@ -31,12 +26,14 @@ namespace UI { TemplateWidget::TemplateWidget() - : _more_info_button("More info") - , _short_description_label("Short description - I like trains. ad asda asd asdweqe gdfg") - , _template_author_label("by template_author") - , _template_name_label("Template_name") + : _more_info_button(_("More info")) + , _short_description_label(_("Short description")) + , _template_author_label(_("by template_author")) + , _template_name_label(_("Template_name")) , _preview_image("preview.png") { + Gtk::Label *title = manage(new Gtk::Label(_("Selected template"))); + pack_start(*title, Gtk::PACK_SHRINK, 10); pack_start(_template_name_label, Gtk::PACK_SHRINK, 4); pack_start(_template_author_label, Gtk::PACK_SHRINK, 0); pack_start(_preview_image, Gtk::PACK_SHRINK, 15); @@ -59,9 +56,8 @@ void TemplateWidget::create() { if (_current_template.path == "") return; - if (_current_template.is_procedural){ - - } + + if (_current_template.is_procedural) {} else { sp_file_new(_current_template.path); } @@ -82,6 +78,7 @@ void TemplateWidget::display(TemplateLoadTab::TemplateData data) } } + void TemplateWidget::_displayTemplateDetails() { if (_current_template.path == "") diff --git a/src/ui/dialog/template-widget.h b/src/ui/dialog/template-widget.h index 83024e0d8..743fb524d 100644 --- a/src/ui/dialog/template-widget.h +++ b/src/ui/dialog/template-widget.h @@ -15,13 +15,10 @@ #include - namespace Inkscape { namespace UI { -class TemplateLoadTab; - class TemplateWidget : public Gtk::VBox { public: @@ -39,7 +36,6 @@ private: Gtk::Image _preview_image; void _displayTemplateDetails(); - }; } -- cgit v1.2.3 From 4f6415189dc97ccb8b8dfaa5ad515b56dd72de0f Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Fri, 19 Jul 2013 15:48:48 -0400 Subject: Ported "ui/widget/selected-style.*". (bzr r12380.1.39) --- src/ui/widget/selected-style.cpp | 29 ++++++++++++++++------------- src/ui/widget/selected-style.h | 11 +++++++---- 2 files changed, 23 insertions(+), 17 deletions(-) (limited to 'src/ui') diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index 102132158..edf53d25c 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -50,6 +50,7 @@ #include "pixmaps/cursor-adj-a.xpm" #include "sp-cursor.h" #include "gradient-chemistry.h" +#include "util/units.h" static gdouble const _sw_presets[] = { 32 , 16 , 10 , 8 , 6 , 4 , 3 , 2 , 1.5 , 1 , 0.75 , 0.5 , 0.25 , 0.1 }; static gchar const *const _sw_presets_str[] = {"32", "16", "10", "8", "6", "4", "3", "2", "1.5", "1", "0.75", "0.5", "0.25", "0.1"}; @@ -306,15 +307,18 @@ SelectedStyle::SelectedStyle(bool /*layout*/) { int row = 0; - // List of units should match with Fill/Stroke dialog stroke style width list - for (GSList *l = sp_unit_get_list(SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE); l != NULL; l = l->next) { - SPUnit const *u = static_cast(l->data); + Inkscape::Util::UnitTable unit_table; + Inkscape::Util::UnitTable::UnitMap m = unit_table.units(Inkscape::Util::UNIT_TYPE_LINEAR); + Inkscape::Util::UnitTable::UnitMap::iterator iter = m.begin(); + while(iter != m.end()) { Gtk::RadioMenuItem *mi = Gtk::manage(new Gtk::RadioMenuItem(_sw_group)); - mi->add(*(new Gtk::Label(u->abbr, 0.0, 0.5))); + mi->add(*(new Gtk::Label((*iter).first, 0.0, 0.5))); _unit_mis = g_slist_append(_unit_mis, mi); - mi->signal_activate().connect(sigc::bind(sigc::mem_fun(*this, &SelectedStyle::on_popup_units), u->unit_id)); + Inkscape::Util::Unit const *u = new Inkscape::Util::Unit(unit_table.getUnit(iter->first)); + mi->signal_activate().connect(sigc::bind(sigc::mem_fun(*this, &SelectedStyle::on_popup_units), *u)); _popup_sw.attach(*mi, 0,1, row, row+1); row++; + ++iter; } _popup_sw.attach(*(new Gtk::SeparatorMenuItem()), 0,1, row, row+1); @@ -476,14 +480,13 @@ SelectedStyle::setDesktop(SPDesktop *desktop) this ) )); - //_sw_unit = const_cast(sp_desktop_namedview(desktop)->doc_units); - _sw_unit = const_cast(&sp_unit_get_by_id(SP_UNIT_PX)); + _sw_unit = const_cast(sp_desktop_namedview(desktop)->doc_units); // Set the doc default unit active in the units list gint length = g_slist_length(_unit_mis); for (int i = 0; i < length; i++) { Gtk::RadioMenuItem *mi = (Gtk::RadioMenuItem *) g_slist_nth_data(_unit_mis, i); - if (mi && mi->get_label() == Glib::ustring(_sw_unit->abbr)) { + if (mi && mi->get_label() == _sw_unit->abbr) { mi->set_active(); break; } @@ -927,8 +930,8 @@ SelectedStyle::on_opacity_click(GdkEventButton *event) return false; } -void SelectedStyle::on_popup_units(SPUnitId id) { - _sw_unit = (SPUnit *) &(sp_unit_get_by_id(id)); +void SelectedStyle::on_popup_units(Inkscape::Util::Unit &unit) { + _sw_unit = new Inkscape::Util::Unit(unit); update(); } @@ -936,7 +939,7 @@ void SelectedStyle::on_popup_preset(int i) { SPCSSAttr *css = sp_repr_css_attr_new (); gdouble w; if (_sw_unit) { - w = sp_units_get_pixels (_sw_presets[i], *_sw_unit); + w = Inkscape::Util::Quantity::convert(_sw_presets[i], *_sw_unit, "px"); } else { w = _sw_presets[i]; } @@ -1115,7 +1118,7 @@ SelectedStyle::update() { double w; if (_sw_unit) { - w = sp_pixels_get_units(query->stroke_width.computed, *_sw_unit); + w = Inkscape::Util::Quantity::convert(query->stroke_width.computed, "px", *_sw_unit); } else { w = query->stroke_width.computed; } @@ -1129,7 +1132,7 @@ SelectedStyle::update() { gchar *str = g_strdup_printf(_("Stroke width: %.5g%s%s"), w, - _sw_unit? sp_unit_get_abbreviation(_sw_unit) : "px", + _sw_unit? _sw_unit->abbr.c_str() : "px", (result_sw == QUERY_STYLE_MULTIPLE_AVERAGED)? _(" (averaged)") : ""); _stroke_width_place.set_tooltip_text(str); diff --git a/src/ui/widget/selected-style.h b/src/ui/widget/selected-style.h index e5bc4f883..0a907f1fd 100644 --- a/src/ui/widget/selected-style.h +++ b/src/ui/widget/selected-style.h @@ -41,12 +41,15 @@ #include #include "rotateable.h" -#include "helper/units.h" class SPDesktop; -struct SPUnit; namespace Inkscape { + +namespace Util { + class Unit; +} + namespace UI { namespace Widget { @@ -273,11 +276,11 @@ protected: Gtk::Menu _popup_sw; Gtk::RadioButtonGroup _sw_group; GSList *_unit_mis; - void on_popup_units(SPUnitId id); + void on_popup_units(Inkscape::Util::Unit &u); void on_popup_preset(int i); Gtk::MenuItem _popup_sw_remove; - SPUnit *_sw_unit; + Inkscape::Util::Unit *_sw_unit; void *_drop[2]; bool _dropEnabled[2]; -- cgit v1.2.3 From 4d00e731811f7c795b80b49b408eb76a9852b9f0 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Fri, 19 Jul 2013 15:56:24 -0400 Subject: Ported "ui/widget/style-swatch.*". (bzr r12380.1.40) --- src/ui/widget/style-swatch.cpp | 6 +++--- src/ui/widget/style-swatch.h | 8 ++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'src/ui') diff --git a/src/ui/widget/style-swatch.cpp b/src/ui/widget/style-swatch.cpp index aedab3fa5..682457bed 100644 --- a/src/ui/widget/style-swatch.cpp +++ b/src/ui/widget/style-swatch.cpp @@ -26,7 +26,7 @@ #include "xml/repr.h" #include "xml/sp-css-attr.h" #include "widgets/widget-sizes.h" -#include "helper/units.h" +#include "util/units.h" #include "helper/action.h" #include "helper/action-context.h" #include "preferences.h" @@ -333,7 +333,7 @@ void StyleSwatch::setStyle(SPStyle *query) if (has_stroke) { double w; if (_sw_unit) { - w = sp_pixels_get_units(query->stroke_width.computed, *_sw_unit); + w = Inkscape::Util::Quantity::convert(query->stroke_width.computed, "px", *_sw_unit); } else { w = query->stroke_width.computed; } @@ -346,7 +346,7 @@ void StyleSwatch::setStyle(SPStyle *query) { gchar *str = g_strdup_printf(_("Stroke width: %.5g%s"), w, - _sw_unit? sp_unit_get_abbreviation(_sw_unit) : "px"); + _sw_unit? _sw_unit->abbr.c_str() : "px"); _stroke_width_place.set_tooltip_text(str); g_free (str); } diff --git a/src/ui/widget/style-swatch.h b/src/ui/widget/style-swatch.h index 6bdb5e248..6da58a2dd 100644 --- a/src/ui/widget/style-swatch.h +++ b/src/ui/widget/style-swatch.h @@ -30,7 +30,6 @@ #include "button.h" #include "preferences.h" -struct SPUnit; struct SPStyle; class SPCSSAttr; @@ -43,6 +42,11 @@ class Table; } namespace Inkscape { + +namespace Util { + class Unit; +} + namespace UI { namespace Widget { @@ -93,7 +97,7 @@ private: Gtk::EventBox _stroke_width_place; Gtk::Label _stroke_width; - SPUnit *_sw_unit; + Inkscape::Util::Unit *_sw_unit; friend class ToolObserver; }; -- cgit v1.2.3 From 567fbf4a2759ff93533a22a8688b4dcc01f19138 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Sat, 20 Jul 2013 14:00:42 -0400 Subject: Removed last traces of "SPUnit" and removed "helper/unit*". (bzr r12380.1.45) --- src/ui/widget/registered-widget.h | 1 - 1 file changed, 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/widget/registered-widget.h b/src/ui/widget/registered-widget.h index 491ca6050..53d53345a 100644 --- a/src/ui/widget/registered-widget.h +++ b/src/ui/widget/registered-widget.h @@ -32,7 +32,6 @@ #include -struct SPUnit; class SPDocument; namespace Gtk { -- cgit v1.2.3 From fdf69629c66f6c1a69d88a00bb6c1311c97b631b Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Sat, 20 Jul 2013 15:08:31 -0400 Subject: Ported away from and removed "sp-metrics.*". (bzr r12380.1.47) --- src/ui/tool/node.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/ui') diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index dc6e0fbae..82eb697bd 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -22,7 +22,6 @@ #include "preferences.h" #include "snap.h" #include "snap-preferences.h" -#include "sp-metrics.h" #include "sp-namedview.h" #include "ui/control-manager.h" #include "ui/tool/control-point-selection.h" @@ -490,9 +489,13 @@ Glib::ustring Handle::_getDragTip(GdkEventMotion */*event*/) const double angle = Geom::angle_between(Geom::Point(-1,0), position() - _parent->position()); angle += M_PI; // angle is (-M_PI...M_PI] - offset by +pi and scale to 0...360 angle *= 360.0 / (2 * M_PI); - GString *x = SP_PX_TO_METRIC_STRING(dist[Geom::X], _desktop->namedview->getDefaultMetric()); - GString *y = SP_PX_TO_METRIC_STRING(dist[Geom::Y], _desktop->namedview->getDefaultMetric()); - GString *len = SP_PX_TO_METRIC_STRING(length(), _desktop->namedview->getDefaultMetric()); + + Inkscape::Util::Quantity x_q = Inkscape::Util::Quantity(dist[Geom::X], "px"); + Inkscape::Util::Quantity y_q = Inkscape::Util::Quantity(dist[Geom::Y], "px"); + Inkscape::Util::Quantity len_q = Inkscape::Util::Quantity(length(), "px"); + GString *x = g_string_new(x_q.string(*_desktop->namedview->doc_units).c_str()); + GString *y = g_string_new(y_q.string(*_desktop->namedview->doc_units).c_str()); + GString *len = g_string_new(len_q.string(*_desktop->namedview->doc_units).c_str()); Glib::ustring ret = format_tip(C_("Path handle tip", "Move handle by %s, %s; angle %.2f°, length %s"), x->str, y->str, angle, len->str); g_string_free(x, TRUE); @@ -1294,8 +1297,11 @@ Glib::ustring Node::_getTip(unsigned state) const Glib::ustring Node::_getDragTip(GdkEventMotion */*event*/) const { Geom::Point dist = position() - _last_drag_origin(); - GString *x = SP_PX_TO_METRIC_STRING(dist[Geom::X], _desktop->namedview->getDefaultMetric()); - GString *y = SP_PX_TO_METRIC_STRING(dist[Geom::Y], _desktop->namedview->getDefaultMetric()); + + Inkscape::Util::Quantity x_q = Inkscape::Util::Quantity(dist[Geom::X], "px"); + Inkscape::Util::Quantity y_q = Inkscape::Util::Quantity(dist[Geom::Y], "px"); + GString *x = g_string_new(x_q.string(*_desktop->namedview->doc_units).c_str()); + GString *y = g_string_new(y_q.string(*_desktop->namedview->doc_units).c_str()); Glib::ustring ret = format_tip(C_("Path node tip", "Move node by %s, %s"), x->str, y->str); g_string_free(x, TRUE); -- cgit v1.2.3 From eb7b26af09df66f30ba50058e9e4a583028cd81a Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Tue, 23 Jul 2013 12:54:01 +0200 Subject: Remove the disabled script dialog and the nonfunctional Java binding (bzr r12428) --- src/ui/CMakeLists.txt | 2 - src/ui/dialog/Makefile_insert | 2 - src/ui/dialog/dialog-manager.cpp | 3 - src/ui/dialog/scriptdialog.cpp | 255 --------------------------------------- src/ui/dialog/scriptdialog.h | 64 ---------- 5 files changed, 326 deletions(-) delete mode 100644 src/ui/dialog/scriptdialog.cpp delete mode 100644 src/ui/dialog/scriptdialog.h (limited to 'src/ui') diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index f3c3b8473..e831bcf69 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -59,7 +59,6 @@ set(ui_SRC dialog/ocaldialogs.cpp dialog/print-colors-preview-dialog.cpp dialog/print.cpp - dialog/scriptdialog.cpp dialog/symbols.cpp dialog/xml-tree.cpp # dialog/session-player.cpp @@ -172,7 +171,6 @@ set(ui_SRC dialog/panel-dialog.h dialog/print-colors-preview-dialog.h dialog/print.h - dialog/scriptdialog.h dialog/spellcheck.h dialog/svg-fonts-dialog.h dialog/swatches.h diff --git a/src/ui/dialog/Makefile_insert b/src/ui/dialog/Makefile_insert index 580b47522..bbede9df1 100644 --- a/src/ui/dialog/Makefile_insert +++ b/src/ui/dialog/Makefile_insert @@ -81,8 +81,6 @@ ink_common_sources += \ ui/dialog/print.h \ ui/dialog/print-colors-preview-dialog.cpp \ ui/dialog/print-colors-preview-dialog.h \ - ui/dialog/scriptdialog.cpp \ - ui/dialog/scriptdialog.h \ ui/dialog/spellcheck.cpp \ ui/dialog/spellcheck.h \ ui/dialog/svg-fonts-dialog.cpp \ diff --git a/src/ui/dialog/dialog-manager.cpp b/src/ui/dialog/dialog-manager.cpp index 993f48d8f..0ce74f54e 100644 --- a/src/ui/dialog/dialog-manager.cpp +++ b/src/ui/dialog/dialog-manager.cpp @@ -32,7 +32,6 @@ #include "ui/dialog/livepatheffect-editor.h" #include "ui/dialog/memory.h" #include "ui/dialog/messages.h" -#include "ui/dialog/scriptdialog.h" #include "ui/dialog/symbols.h" #include "ui/dialog/tile.h" #include "ui/dialog/tracedialog.h" @@ -114,7 +113,6 @@ DialogManager::DialogManager() { registerFactory("ObjectAttributes", &create); registerFactory("ObjectProperties", &create); // registerFactory("PrintColorsPreviewDialog", &create); - registerFactory("Script", &create); registerFactory("SvgFontsDialog", &create); registerFactory("Swatches", &create); registerFactory("Symbols", &create); @@ -148,7 +146,6 @@ DialogManager::DialogManager() { registerFactory("ObjectAttributes", &create); registerFactory("ObjectProperties", &create); // registerFactory("PrintColorsPreviewDialog", &create); - registerFactory("Script", &create); registerFactory("SvgFontsDialog", &create); registerFactory("Swatches", &create); registerFactory("Symbols", &create); diff --git a/src/ui/dialog/scriptdialog.cpp b/src/ui/dialog/scriptdialog.cpp deleted file mode 100644 index 87794a3ce..000000000 --- a/src/ui/dialog/scriptdialog.cpp +++ /dev/null @@ -1,255 +0,0 @@ -/** - * @file - * Dialog for executing and monitoring script execution. - */ -/* Author: - * Bob Jamison - * - * Copyright (C) 2004-2008 Authors - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "scriptdialog.h" -#include -#include -#include -#include -#include - -#include - - - -namespace Inkscape -{ -namespace UI -{ -namespace Dialog -{ - - - -//######################################################################### -//## I M P L E M E N T A T I O N -//######################################################################### - -/** - * A script editor/executor - */ -class ScriptDialogImpl : public ScriptDialog -{ - - public: - ScriptDialogImpl(); - ~ScriptDialogImpl() - {} - - - /** - * Remove all text from the dialog. - */ - void clear(); - - /** - * Execute a script in the dialog. - * - * @param lang language in which the script is programmed - */ - void execute(Inkscape::Extension::Script::InkscapeScript::ScriptLanguage lang); - - /** - * Execute a Javascript script - */ - void executeJavascript(); - - /** - * Execute a Python script - */ - void executePython(); - - /** - * Execute a Ruby script - */ - void executeRuby(); - - - - private: - Gtk::MenuBar menuBar; - Gtk::Menu fileMenu; - - //## Script text - Gtk::Frame scriptTextFrame; - Gtk::ScrolledWindow scriptTextScroll; - Gtk::TextView scriptText; - - //## Output text - Gtk::Frame outputTextFrame; - Gtk::ScrolledWindow outputTextScroll; - Gtk::TextView outputText; - - //## Error text - Gtk::Frame errorTextFrame; - Gtk::ScrolledWindow errorTextScroll; - Gtk::TextView errorText; - - - -}; - -static const char *defaultCodeStr = - "/**\n" - " * This is some example Javascript.\n" - " * Try 'Execute Javascript'\n" - " */\n" - "importPackage(javax.swing);\n" - "function sayHello() {\n" - " JOptionPane.showMessageDialog(null, 'Hello, world!',\n" - " 'Welcome to Inkscape', JOptionPane.WARNING_MESSAGE);\n" - "}\n" - "\n" - "sayHello();\n" - "\n"; - - - - -//######################################################################### -//## E V E N T S -//######################################################################### - -static void textViewClear(Gtk::TextView &view) -{ - Glib::RefPtr buffer = view.get_buffer(); - buffer->erase(buffer->begin(), buffer->end()); -} - -void ScriptDialogImpl::clear() -{ - textViewClear(scriptText); - textViewClear(outputText); - textViewClear(errorText); -} - -void ScriptDialogImpl::execute(Inkscape::Extension::Script::InkscapeScript::ScriptLanguage lang) -{ - Glib::ustring script = scriptText.get_buffer()->get_text(true); - Glib::ustring output; - Glib::ustring error; - Inkscape::Extension::Script::InkscapeScript engine; - bool ok = engine.interpretScript(script, output, error, lang); - outputText.get_buffer()->set_text(output); - errorText.get_buffer()->set_text(error); - if (!ok) - { - //do we want something here? - } -} - -void ScriptDialogImpl::executeJavascript() -{ - execute(Inkscape::Extension::Script::InkscapeScript::JAVASCRIPT); -} - -void ScriptDialogImpl::executePython() -{ - execute(Inkscape::Extension::Script::InkscapeScript::PYTHON); -} - -void ScriptDialogImpl::executeRuby() -{ - execute(Inkscape::Extension::Script::InkscapeScript::RUBY); -} - - -//######################################################################### -//## C O N S T R U C T O R / D E S T R U C T O R -//######################################################################### -ScriptDialogImpl::ScriptDialogImpl() : - ScriptDialog() -{ - Gtk::Box *contents = _getContents(); - - //## Add a menu for clear() - Gtk::MenuItem* item = Gtk::manage(new Gtk::MenuItem(_("File"), true)); - item->set_submenu(fileMenu); - menuBar.append(*item); - - item = Gtk::manage(new Gtk::MenuItem(_("_Clear"), true)); - item->signal_activate().connect(sigc::mem_fun(*this, &ScriptDialogImpl::clear)); - fileMenu.append(*item); - - item = Gtk::manage(new Gtk::MenuItem(_("_Execute Javascript"), true)); - item->signal_activate().connect(sigc::mem_fun(*this, &ScriptDialogImpl::executeJavascript)); - fileMenu.append(*item); - - item = Gtk::manage(new Gtk::MenuItem(_("_Execute Python"), true)); - item->signal_activate().connect(sigc::mem_fun(*this, &ScriptDialogImpl::executePython)); - fileMenu.append(*item); - - item = Gtk::manage(new Gtk::MenuItem(_("_Execute Ruby"), true)); - item->signal_activate().connect(sigc::mem_fun(*this, &ScriptDialogImpl::executeRuby)); - fileMenu.append(*item); - - contents->pack_start(menuBar, Gtk::PACK_SHRINK); - - //### Set up the script field - scriptText.set_editable(true); - scriptText.get_buffer()->set_text(defaultCodeStr); - scriptTextScroll.add(scriptText); - scriptTextScroll.set_policy(Gtk::POLICY_ALWAYS, Gtk::POLICY_ALWAYS); - scriptTextFrame.set_label(_("Script")); - scriptTextFrame.set_shadow_type(Gtk::SHADOW_NONE); - scriptTextFrame.add(scriptTextScroll); - contents->pack_start(scriptTextFrame); - - //### Set up the output field - outputText.set_editable(true); - outputText.get_buffer()->set_text(""); - outputTextScroll.add(outputText); - outputTextScroll.set_policy(Gtk::POLICY_ALWAYS, Gtk::POLICY_ALWAYS); - outputTextFrame.set_label(_("Output")); - outputTextFrame.set_shadow_type(Gtk::SHADOW_NONE); - outputTextFrame.add(outputTextScroll); - contents->pack_start(outputTextFrame); - - //### Set up the error field - errorText.set_editable(true); - errorText.get_buffer()->set_text(""); - errorTextScroll.add(errorText); - errorTextScroll.set_policy(Gtk::POLICY_ALWAYS, Gtk::POLICY_ALWAYS); - errorTextFrame.set_label(_("Errors")); - errorTextFrame.set_shadow_type(Gtk::SHADOW_NONE); - errorTextFrame.add(errorTextScroll); - contents->pack_start(errorTextFrame); - - // sick of this thing shrinking too much - set_size_request(350, 400); - show_all_children(); - -} - -ScriptDialog &ScriptDialog::getInstance() -{ - ScriptDialog *dialog = new ScriptDialogImpl(); - return *dialog; -} - -} //namespace Dialogs -} //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/scriptdialog.h b/src/ui/dialog/scriptdialog.h deleted file mode 100644 index d1962bf6f..000000000 --- a/src/ui/dialog/scriptdialog.h +++ /dev/null @@ -1,64 +0,0 @@ -/** @file - * @brief Script dialog - * - * This dialog is for launching scripts whose main purpose is - * the scripting of Inkscape itself. - */ -/* Authors: - * Bob Jamison - * Other dudes from The Inkscape Organization - * - * Copyright (C) 2004, 2005 Authors - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#ifndef __SCRIPTDIALOG_H__ -#define __SCRIPTDIALOG_H__ - -#include "ui/widget/panel.h" -#include "verbs.h" - -namespace Inkscape { -namespace UI { -namespace Dialog { - - -/** - * A script editor, loader, and executor - */ -class ScriptDialog : public UI::Widget::Panel -{ - - public: - ScriptDialog() : - UI::Widget::Panel("", "/dialogs/script", SP_VERB_DIALOG_SCRIPT) - {} - - /** - * Helper function which returns a new instance of the dialog. - * getInstance is needed by the dialog manager (Inkscape::UI::Dialog::DialogManager). - */ - static ScriptDialog &getInstance(); - - virtual ~ScriptDialog() {}; - -}; // class ScriptDialog - - -} //namespace Dialog -} //namespace UI -} //namespace Inkscape - -#endif /* __DEBUGDIALOG_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 6b78e29d0a6b0a5df82b1d8779689ec41718b258 Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Wed, 24 Jul 2013 09:25:52 +0200 Subject: Old templates support removed (bzr r12379.2.13) --- src/ui/dialog/template-load-tab.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index ded4fc6fd..58219f8f2 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -185,7 +185,7 @@ void TemplateLoadTab::_loadTemplates() _getTemplatesFromDir(profile_path("templates") + _loading_path); // system templates dir - // _getTemplatesFromDir(INKSCAPE_TEMPLATESDIR + _loading_path); + _getTemplatesFromDir(INKSCAPE_TEMPLATESDIR + _loading_path); } -- cgit v1.2.3 From badc78fc17340975af12905bc7a0e0c4d7ab62b4 Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Wed, 24 Jul 2013 10:22:37 +0200 Subject: Templates gui fixes (bzr r12379.2.14) --- src/ui/dialog/new-from-template.cpp | 3 ++- src/ui/dialog/template-load-tab.cpp | 14 ++++++-------- src/ui/dialog/template-load-tab.h | 5 +++-- src/ui/dialog/template-widget.cpp | 17 ++++++++--------- 4 files changed, 19 insertions(+), 20 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/new-from-template.cpp b/src/ui/dialog/new-from-template.cpp index 6598aecdf..2595e2cf5 100644 --- a/src/ui/dialog/new-from-template.cpp +++ b/src/ui/dialog/new-from-template.cpp @@ -30,7 +30,8 @@ NewFromTemplate::NewFromTemplate() Gtk::Alignment *align; align = manage(new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER, 0.0, 0.0)); - get_vbox()->pack_end(*align, Gtk::PACK_SHRINK, 5); + get_vbox()->pack_end(*align, Gtk::PACK_SHRINK); + align->set_padding(0, 0, 0, 15); align->add(_create_template_button); _create_template_button.signal_pressed().connect( diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index 58219f8f2..65d5e6447 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -38,18 +38,16 @@ TemplateLoadTab::TemplateLoadTab() set_border_width(10); _info_widget = manage(new TemplateWidget()); + Gtk::Label *title; title = manage(new Gtk::Label(_("Search:"))); - _tlist_box.pack_start(*title, Gtk::PACK_SHRINK, 10); - - _tlist_box.pack_start(_keywords_combo, Gtk::PACK_SHRINK, 0); + _search_box.pack_start(*title, Gtk::PACK_SHRINK); + _search_box.pack_start(_keywords_combo, Gtk::PACK_SHRINK, 5); - title = manage(new Gtk::Label(_("Templates"))); - _tlist_box.pack_start(*title, Gtk::PACK_SHRINK, 10); + _tlist_box.pack_start(_search_box, Gtk::PACK_SHRINK, 10); - add(_main_box); - _main_box.pack_start(_tlist_box, Gtk::PACK_SHRINK, 20); - _main_box.pack_start(*_info_widget, Gtk::PACK_EXPAND_WIDGET, 10); + pack_start(_tlist_box, Gtk::PACK_SHRINK); + pack_start(*_info_widget, Gtk::PACK_EXPAND_WIDGET, 5); Gtk::ScrolledWindow *scrolled; scrolled = manage(new Gtk::ScrolledWindow()); diff --git a/src/ui/dialog/template-load-tab.h b/src/ui/dialog/template-load-tab.h index cc5229c95..c3c512374 100644 --- a/src/ui/dialog/template-load-tab.h +++ b/src/ui/dialog/template-load-tab.h @@ -25,7 +25,7 @@ namespace UI { class TemplateWidget; -class TemplateLoadTab : public Gtk::Frame +class TemplateLoadTab : public Gtk::HBox { public: @@ -71,8 +71,9 @@ protected: void _loadTemplates(); void _initLists(); - Gtk::HBox _main_box; + // Gtk::HBox _main_box; Gtk::VBox _tlist_box; + Gtk::HBox _search_box; TemplateWidget *_info_widget; Gtk::ComboBoxText _keywords_combo; diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index bb2c4a683..56346403e 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -27,26 +27,25 @@ namespace UI { TemplateWidget::TemplateWidget() : _more_info_button(_("More info")) - , _short_description_label(_("Short description")) - , _template_author_label(_("by template_author")) - , _template_name_label(_("Template_name")) - , _preview_image("preview.png") + , _short_description_label(_(" ")) + , _template_author_label(_(" ")) + , _template_name_label(_("no template selected")) + , _preview_image(" ") { - Gtk::Label *title = manage(new Gtk::Label(_("Selected template"))); - pack_start(*title, Gtk::PACK_SHRINK, 10); - pack_start(_template_name_label, Gtk::PACK_SHRINK, 4); + pack_start(_template_name_label, Gtk::PACK_SHRINK, 10); pack_start(_template_author_label, Gtk::PACK_SHRINK, 0); pack_start(_preview_image, Gtk::PACK_SHRINK, 15); - pack_start(_short_description_label, Gtk::PACK_SHRINK, 4); _short_description_label.set_line_wrap(true); _short_description_label.set_size_request(200); Gtk::Alignment *align; align = manage(new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER, 0.0, 0.0)); - pack_start(*align, Gtk::PACK_SHRINK, 5); + pack_end(*align, Gtk::PACK_SHRINK); align->add(_more_info_button); + pack_end(_short_description_label, Gtk::PACK_SHRINK, 5); + _more_info_button.signal_pressed().connect( sigc::mem_fun(*this, &TemplateWidget::_displayTemplateDetails)); } -- cgit v1.2.3 From 6967bad3f32f3cf9e660f6009be63adf62f94058 Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Sat, 27 Jul 2013 22:14:29 +0200 Subject: Templates related bug fixes (bzr r12379.2.15) --- src/ui/dialog/template-load-tab.cpp | 10 +++++++++- src/ui/dialog/template-widget.cpp | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index 65d5e6447..d993e0233 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -191,9 +191,17 @@ TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(const Glib:: { TemplateData result; result.path = path; - result.display_name = Glib::path_get_basename(path); result.is_procedural = false; + // convert path into valid template name + result.display_name = Glib::path_get_basename(path); + gsize n = 0; + while ((n = result.display_name.find_first_of("_", 0)) < Glib::ustring::npos){ + result.display_name.replace(n, 1, 1, ' '); + } + n = result.display_name.rfind(".svg"); + result.display_name.replace(n, 4, 1, ' '); + Inkscape::XML::Document *rdoc; rdoc = sp_repr_read_file(path.data(), SP_SVG_NS_URI); Inkscape::XML::Node *myRoot; diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index 56346403e..1efa790ab 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -58,7 +58,7 @@ void TemplateWidget::create() if (_current_template.is_procedural) {} else { - sp_file_new(_current_template.path); + sp_file_open(_current_template.path, NULL); } } -- cgit v1.2.3 From d11c156518710f49dc3fc8ec3408388a1a2b1ddb Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Sat, 27 Jul 2013 22:39:28 +0200 Subject: New preview rendering option in New From Template (bzr r12379.2.16) --- src/ui/dialog/template-load-tab.cpp | 1 + src/ui/dialog/template-widget.cpp | 13 ++++++++++++- src/ui/dialog/template-widget.h | 2 ++ 3 files changed, 15 insertions(+), 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index d993e0233..ade595eaa 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -192,6 +192,7 @@ TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(const Glib:: TemplateData result; result.path = path; result.is_procedural = false; + result.preview_name = ""; // convert path into valid template name result.display_name = Glib::path_get_basename(path); diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index 1efa790ab..c15d234ab 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -31,10 +31,12 @@ TemplateWidget::TemplateWidget() , _template_author_label(_(" ")) , _template_name_label(_("no template selected")) , _preview_image(" ") + , _preview_render() { pack_start(_template_name_label, Gtk::PACK_SHRINK, 10); pack_start(_template_author_label, Gtk::PACK_SHRINK, 0); pack_start(_preview_image, Gtk::PACK_SHRINK, 15); + pack_start(_preview_render, Gtk::PACK_SHRINK, 10); _short_description_label.set_line_wrap(true); _short_description_label.set_size_request(200); @@ -73,7 +75,16 @@ void TemplateWidget::display(TemplateLoadTab::TemplateData data) _short_description_label.set_text(_current_template.short_description); Glib::ustring imagePath = Glib::build_filename(Glib::path_get_dirname(_current_template.path), _current_template.preview_name); - _preview_image.set(imagePath); + if (data.preview_name != ""){ + _preview_image.set(imagePath); + _preview_image.show(); + _preview_render.hide(); + } + else{ + _preview_render.showImage(data.path); + _preview_render.show(); + _preview_image.hide(); + } } } diff --git a/src/ui/dialog/template-widget.h b/src/ui/dialog/template-widget.h index 743fb524d..b9d03415c 100644 --- a/src/ui/dialog/template-widget.h +++ b/src/ui/dialog/template-widget.h @@ -12,6 +12,7 @@ #define INKSCAPE_SEEN_UI_DIALOG_TEMPLATE_WIDGET_H #include "template-load-tab.h" +#include "filedialogimpl-gtkmm.h" #include @@ -34,6 +35,7 @@ private: Gtk::Label _template_author_label; Gtk::Label _template_name_label; Gtk::Image _preview_image; + Dialog::SVGPreview _preview_render; void _displayTemplateDetails(); }; -- cgit v1.2.3 From 2b49305a582432378732c9f26456e1ada464edbd Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Sat, 27 Jul 2013 22:51:06 +0200 Subject: Template preview size fixed (bzr r12379.2.17) --- src/ui/dialog/template-widget.cpp | 6 ++++-- src/ui/dialog/template-widget.h | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index c15d234ab..4b64c1c73 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -35,8 +35,10 @@ TemplateWidget::TemplateWidget() { pack_start(_template_name_label, Gtk::PACK_SHRINK, 10); pack_start(_template_author_label, Gtk::PACK_SHRINK, 0); - pack_start(_preview_image, Gtk::PACK_SHRINK, 15); - pack_start(_preview_render, Gtk::PACK_SHRINK, 10); + pack_start(_preview_box, Gtk::PACK_SHRINK, 0); + + _preview_box.pack_start(_preview_image, Gtk::PACK_EXPAND_PADDING, 15); + _preview_box.pack_start(_preview_render, Gtk::PACK_EXPAND_PADDING, 10); _short_description_label.set_line_wrap(true); _short_description_label.set_size_request(200); diff --git a/src/ui/dialog/template-widget.h b/src/ui/dialog/template-widget.h index b9d03415c..3c95208de 100644 --- a/src/ui/dialog/template-widget.h +++ b/src/ui/dialog/template-widget.h @@ -34,6 +34,7 @@ private: Gtk::Label _short_description_label; Gtk::Label _template_author_label; Gtk::Label _template_name_label; + Gtk::HBox _preview_box; Gtk::Image _preview_image; Dialog::SVGPreview _preview_render; -- cgit v1.2.3 From 7aab446af9e2eb34ce50c8ef0ec58710fac49396 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Mon, 29 Jul 2013 22:51:28 -0400 Subject: Cleanup. (bzr r12380.1.52) --- src/ui/CMakeLists.txt | 2 ++ src/ui/dialog/guides.cpp | 2 +- src/ui/widget/page-sizer.cpp | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) (limited to 'src/ui') diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index e831bcf69..b592d2527 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -112,6 +112,7 @@ set(ui_SRC widget/text.cpp widget/tolerance-slider.cpp widget/unit-menu.cpp + widget/unit-tracker.cpp view/view.cpp view/view-widget.cpp @@ -240,6 +241,7 @@ set(ui_SRC widget/text.h widget/tolerance-slider.h widget/unit-menu.h + widget/unit-tracker.h view/edit-widget-interface.h view/view-widget.h diff --git a/src/ui/dialog/guides.cpp b/src/ui/dialog/guides.cpp index 9a7b19c35..2de387364 100644 --- a/src/ui/dialog/guides.cpp +++ b/src/ui/dialog/guides.cpp @@ -230,7 +230,7 @@ void GuidelinePropertiesDialog::_setup() { _unit_menu.setUnitType(UNIT_TYPE_LINEAR); _unit_menu.setUnit("px"); if (_desktop->namedview->doc_units) { - //_unit_menu.setUnit( sp_unit_get_abbreviation(_desktop->namedview->doc_units) ); + _unit_menu.setUnit( _desktop->namedview->doc_units->abbr ); } _spin_angle.setUnit(_angle_unit_status); diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index f6392cfd8..b15ab2823 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -313,9 +313,9 @@ PageSizer::PageSizer(Registry & _wr) SPNamedView *nv = sp_desktop_namedview(dt); _wr.setUpdating (true); if (nv->units) { - //_dimensionUnits.setUnit(nv->units); + _dimensionUnits.setUnit(nv->units->abbr); } else if (nv->doc_units) { - //_dimensionUnits.setUnit(nv->doc_units); + _dimensionUnits.setUnit(nv->doc_units->abbr); } _wr.setUpdating (false); -- 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 c135cb8c39a4004e9eb8adb227ba4c54848a8c45 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Wed, 31 Jul 2013 16:45:07 -0400 Subject: Added percent support back to select toolbar. (bzr r12380.1.53) --- src/ui/widget/unit-tracker.cpp | 9 ++++++++- src/ui/widget/unit-tracker.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/widget/unit-tracker.cpp b/src/ui/widget/unit-tracker.cpp index 372419c3b..c0d3eec9b 100644 --- a/src/ui/widget/unit-tracker.cpp +++ b/src/ui/widget/unit-tracker.cpp @@ -111,6 +111,13 @@ void UnitTracker::addAdjustment(GtkAdjustment *adj) } } +void UnitTracker::addUnit(Inkscape::Util::Unit const &u) +{ + GtkTreeIter iter; + gtk_list_store_append(_store, &iter); + gtk_list_store_set(_store, &iter, COLUMN_STRING, u.abbr.c_str(), -1); +} + void UnitTracker::setFullVal(GtkAdjustment *adj, gdouble val) { _priorValues[adj] = val; @@ -232,7 +239,7 @@ void UnitTracker::_fixupAdjustments(Inkscape::Util::Unit const oldUnit, Inkscape if ( (oldUnit.type != Inkscape::Util::UNIT_TYPE_DIMENSIONLESS) && (newUnit.type == Inkscape::Util::UNIT_TYPE_DIMENSIONLESS) ) { - val = newUnit.factor; + val = newUnit.factor * 100; _priorValues[adj] = Inkscape::Util::Quantity::convert(oldVal, oldUnit, "px"); } else if ( (oldUnit.type == Inkscape::Util::UNIT_TYPE_DIMENSIONLESS) && (newUnit.type != Inkscape::Util::UNIT_TYPE_DIMENSIONLESS) ) diff --git a/src/ui/widget/unit-tracker.h b/src/ui/widget/unit-tracker.h index 521fe50c8..cdcb07c57 100644 --- a/src/ui/widget/unit-tracker.h +++ b/src/ui/widget/unit-tracker.h @@ -39,6 +39,7 @@ public: void setActiveUnitByAbbr(gchar const *abbr); Inkscape::Util::Unit getActiveUnit() const; + void addUnit(Inkscape::Util::Unit const &u); void addAdjustment(GtkAdjustment *adj); void setFullVal(GtkAdjustment *adj, gdouble val); -- 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 f1cdb3b3f47c7187d9325e8ddd8e630268dc8e8b Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Wed, 31 Jul 2013 18:33:03 -0400 Subject: Eliminate "unit-constants.h". (bzr r12380.1.54) --- src/ui/clipboard.cpp | 8 ++++---- src/ui/dialog/export.cpp | 7 +++---- src/ui/dialog/inkscape-preferences.cpp | 8 ++++---- src/ui/dialog/print.cpp | 12 ++++++------ src/ui/dialog/text-edit.cpp | 4 ++-- src/ui/widget/rendering-options.cpp | 6 +++--- 6 files changed, 22 insertions(+), 23 deletions(-) (limited to 'src/ui') diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 72ddd90a9..629960613 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -79,7 +79,7 @@ #include "text-editing.h" #include "tools-switch.h" #include "path-chemistry.h" -#include "unit-constants.h" +#include "util/units.h" #include "helper/png-write.h" #include "svg/svg-color.h" #include "sp-namedview.h" @@ -1078,14 +1078,14 @@ void ClipboardManagerImpl::_onGet(Gtk::SelectionData &sel, guint /*info*/) try { if (out == outlist.end() && target == "image/png") { - gdouble dpi = PX_PER_IN; + gdouble dpi = Inkscape::Util::Quantity::convert(1, "in", "px"); guint32 bgcolor = 0x00000000; Geom::Point origin (_clipboardSPDoc->getRoot()->x.computed, _clipboardSPDoc->getRoot()->y.computed); Geom::Rect area = Geom::Rect(origin, origin + _clipboardSPDoc->getDimensions()); - unsigned long int width = (unsigned long int) (area.width() * dpi / PX_PER_IN + 0.5); - unsigned long int height = (unsigned long int) (area.height() * dpi / PX_PER_IN + 0.5); + unsigned long int width = (unsigned long int) (area.width() * dpi / Inkscape::Util::Quantity::convert(1, "in", "px") + 0.5); + unsigned long int height = (unsigned long int) (area.height() * dpi / Inkscape::Util::Quantity::convert(1, "in", "px") + 0.5); // read from namedview Inkscape::XML::Node *nv = sp_repr_lookup_name (_clipboardSPDoc->rroot, "sodipodi:namedview"); diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 5cb9357c3..063902aa7 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -50,7 +50,6 @@ #include "ui/widget/unit-menu.h" #include "util/units.h" -#include "unit-constants.h" #include "helper/window.h" #include "inkscape-private.h" #include "document.h" @@ -98,7 +97,7 @@ #define SP_EXPORT_MIN_SIZE 1.0 -#define DPI_BASE PX_PER_IN +#define DPI_BASE Inkscape::Util::Quantity::convert(1, "in", "px") #define EXPORT_COORD_PRECISION 3 @@ -1048,8 +1047,8 @@ void Export::onExport () Geom::OptRect area = item->desktopVisualBounds(); if (area) { - gint width = (gint) (area->width() * dpi / PX_PER_IN + 0.5); - gint height = (gint) (area->height() * dpi / PX_PER_IN + 0.5); + gint width = (gint) (area->width() * dpi / DPI_BASE + 0.5); + gint height = (gint) (area->height() * dpi / DPI_BASE + 0.5); if (width > 1 && height > 1) { // Do export diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index bc648002d..7890b0b4c 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -28,7 +28,7 @@ #include "preferences.h" #include "verbs.h" #include "selcue.h" -#include "unit-constants.h" +#include "util/units.h" #include #include "enums.h" #include "desktop-handles.h" @@ -1428,10 +1428,10 @@ void InkscapePreferences::initPageBitmaps() _("Automatically reload linked images when file is changed on disk")); _misc_bitmap_editor.init("/options/bitmapeditor/value", true); _page_bitmaps.add_line( false, _("_Bitmap editor:"), _misc_bitmap_editor, "", "", true); - _importexport_export_res.init("/dialogs/export/defaultxdpi/value", 0.0, 6000.0, 1.0, 1.0, PX_PER_IN, true, false); + _importexport_export_res.init("/dialogs/export/defaultxdpi/value", 0.0, 6000.0, 1.0, 1.0, Inkscape::Util::Quantity::convert(1, "in", "px"), true, false); _page_bitmaps.add_line( false, _("Default export _resolution:"), _importexport_export_res, _("dpi"), _("Default bitmap resolution (in dots per inch) in the Export dialog"), false); - _bitmap_copy_res.init("/options/createbitmap/resolution", 1.0, 6000.0, 1.0, 1.0, PX_PER_IN, true, false); + _bitmap_copy_res.init("/options/createbitmap/resolution", 1.0, 6000.0, 1.0, 1.0, Inkscape::Util::Quantity::convert(1, "in", "px"), true, false); _page_bitmaps.add_line( false, _("Resolution for Create Bitmap _Copy:"), _bitmap_copy_res, _("dpi"), _("Resolution used by the Create Bitmap Copy command"), false); { @@ -1443,7 +1443,7 @@ void InkscapePreferences::initPageBitmaps() _bitmap_import_quality.init("/dialogs/import/quality", 1, 100, 1, 1, 100, true, false); _page_bitmaps.add_line( false, _("Bitmap import quality:"), _bitmap_import_quality, "%", "Bitmap import quality (jpeg only). 100 is best quality", false); } - _importexport_import_res.init("/dialogs/import/defaultxdpi/value", 0.0, 6000.0, 1.0, 1.0, PX_PER_IN, true, false); + _importexport_import_res.init("/dialogs/import/defaultxdpi/value", 0.0, 6000.0, 1.0, 1.0, Inkscape::Util::Quantity::convert(1, "in", "px"), true, false); _page_bitmaps.add_line( false, _("Default _import resolution:"), _importexport_import_res, _("dpi"), _("Default bitmap resolution (in dots per inch) for bitmap import"), false); _importexport_import_res_override.init(_("Override file resolution"), "/dialogs/import/forcexdpi", false); diff --git a/src/ui/dialog/print.cpp b/src/ui/dialog/print.cpp index 2ab8cf121..4c8c77f96 100644 --- a/src/ui/dialog/print.cpp +++ b/src/ui/dialog/print.cpp @@ -26,7 +26,7 @@ #include "ui/widget/rendering-options.h" #include "document.h" -#include "unit-constants.h" +#include "util/units.h" #include "helper/png-write.h" #include "svg/svg-color.h" #include "io/sys.h" @@ -72,8 +72,8 @@ static void draw_page( sp_export_png_file(junk->_doc, tmp_png.c_str(), 0.0, 0.0, width, height, - (unsigned long)(width * dpi / PX_PER_IN), - (unsigned long)(height * dpi / PX_PER_IN), + (unsigned long)(width * dpi / Inkscape::Util::Quantity::convert(1, "in", "px")), + (unsigned long)(height * dpi / Inkscape::Util::Quantity::convert(1, "in", "px")), dpi, dpi, bgcolor, NULL, NULL, true, NULL); // This doesn't seem to work: @@ -90,7 +90,7 @@ static void draw_page( cairo_t *cr = gtk_print_context_get_cairo_context (context); cairo_matrix_t m; cairo_get_matrix(cr, &m); - cairo_scale(cr, PT_PER_IN / dpi, PT_PER_IN / dpi); + cairo_scale(cr, Inkscape::Util::Quantity::convert(1, "in", "pt") / dpi, Inkscape::Util::Quantity::convert(1, "in", "pt") / dpi); // FIXME: why is the origin offset?? cairo_set_source_surface(cr, png->cobj(), -16.0, -16.0); cairo_paint(cr); @@ -195,8 +195,8 @@ Print::Print(SPDocument *doc, SPItem *base) : // set up paper size to match the document size gtk_print_operation_set_unit (_printop, GTK_UNIT_POINTS); GtkPageSetup *page_setup = gtk_page_setup_new(); - gdouble doc_width = _doc->getWidth() * PT_PER_PX; - gdouble doc_height = _doc->getHeight() * PT_PER_PX; + gdouble doc_width = _doc->getWidth() * Inkscape::Util::Quantity::convert(1, "px", "pt"); + gdouble doc_height = _doc->getHeight() * Inkscape::Util::Quantity::convert(1, "px", "pt"); GtkPaperSize *paper_size; if (doc_width > doc_height) { gtk_page_setup_set_orientation (page_setup, GTK_PAGE_ORIENTATION_LANDSCAPE); diff --git a/src/ui/dialog/text-edit.cpp b/src/ui/dialog/text-edit.cpp index a662495a0..4a25f723b 100644 --- a/src/ui/dialog/text-edit.cpp +++ b/src/ui/dialog/text-edit.cpp @@ -58,7 +58,7 @@ extern "C" { #include "widgets/font-selector.h" #include #include -#include "unit-constants.h" +#include "util/units.h" #include "sp-textpath.h" namespace Inkscape { @@ -401,7 +401,7 @@ void TextEdit::setPreviewText (Glib::ustring font_spec, Glib::ustring phrase) Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int unit = prefs->getInt("/options/font/unitType", SP_CSS_UNIT_PT); - double pt_size = sp_style_css_size_units_to_px(sp_font_selector_get_size(fsel), unit) * PT_PER_PX; + double pt_size = sp_style_css_size_units_to_px(sp_font_selector_get_size(fsel), unit) * Inkscape::Util::Quantity::convert(1, "px", "pt"); // Pango font size is in 1024ths of a point // C++11: Glib::ustring size = std::to_string( pt_size * PANGO_SCALE ); diff --git a/src/ui/widget/rendering-options.cpp b/src/ui/widget/rendering-options.cpp index f26e71553..d6248df69 100644 --- a/src/ui/widget/rendering-options.cpp +++ b/src/ui/widget/rendering-options.cpp @@ -13,7 +13,7 @@ #endif #include "rendering-options.h" -#include "unit-constants.h" +#include "util/units.h" #include namespace Inkscape { @@ -59,8 +59,8 @@ RenderingOptions::RenderingOptions () : _radio_bitmap.signal_toggled().connect(sigc::mem_fun(*this, &RenderingOptions::_toggled)); // configure default DPI - _dpi.setRange(PT_PER_IN,2400.0); - _dpi.setValue(PT_PER_IN); + _dpi.setRange(Inkscape::Util::Quantity::convert(1, "in", "pt"),2400.0); + _dpi.setValue(Inkscape::Util::Quantity::convert(1, "in", "pt")); _dpi.setIncrements(1.0,10.0); _dpi.setDigits(0); _dpi.update(); -- cgit v1.2.3 From f69ba9fbb46f827a2cb76f2d1f87acbf53edc416 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Thu, 1 Aug 2013 19:42:12 -0400 Subject: Fix UnitTracker percentage bug. (bzr r12380.1.59) --- src/ui/widget/unit-tracker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/widget/unit-tracker.cpp b/src/ui/widget/unit-tracker.cpp index c0d3eec9b..99074be40 100644 --- a/src/ui/widget/unit-tracker.cpp +++ b/src/ui/widget/unit-tracker.cpp @@ -245,7 +245,7 @@ void UnitTracker::_fixupAdjustments(Inkscape::Util::Unit const oldUnit, Inkscape && (newUnit.type != Inkscape::Util::UNIT_TYPE_DIMENSIONLESS) ) { if (_priorValues.find(adj) != _priorValues.end()) { - val = Inkscape::Util::Quantity::convert(_priorValues[adj], newUnit, "px"); + val = Inkscape::Util::Quantity::convert(_priorValues[adj], "px", newUnit); } } else { val = Inkscape::Util::Quantity::convert(oldVal, oldUnit, newUnit); -- cgit v1.2.3 From 84ef605959069b0d7bebc61b5c08e2b34ef55945 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 3 Aug 2013 22:45:01 +0200 Subject: fix initialization (bzr r12460) --- src/ui/widget/registered-widget.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/ui') diff --git a/src/ui/widget/registered-widget.h b/src/ui/widget/registered-widget.h index fa35b815e..18a84ea05 100644 --- a/src/ui/widget/registered-widget.h +++ b/src/ui/widget/registered-widget.h @@ -128,6 +128,7 @@ private: repr = NULL; doc = NULL; write_undo = false; + event_type = -1; } }; -- cgit v1.2.3 From 04eec6c234200e1978bd779613cc463929e50d19 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 3 Aug 2013 23:09:02 +0200 Subject: rename variable for clarity (bzr r12462) --- src/ui/dialog/livepatheffect-editor.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp index e6bb9b43d..6c6f3a582 100644 --- a/src/ui/dialog/livepatheffect-editor.cpp +++ b/src/ui/dialog/livepatheffect-editor.cpp @@ -448,9 +448,9 @@ LivePathEffectEditor::onAdd() // run sp_selection_clone_original_path_lpe sp_selection_clone_original_path_lpe(current_desktop); - item = sel->singleItem(); - item->getRepr()->setAttribute("id", id); - item->getRepr()->setAttribute("transform", transform); + SPItem *new_item = sel->singleItem(); + new_item->getRepr()->setAttribute("id", id); + new_item->getRepr()->setAttribute("transform", transform); g_free(id); g_free(transform); -- cgit v1.2.3 From 3d59db609dcae34444b45348c57ac203886576b6 Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Sun, 4 Aug 2013 14:37:48 +0200 Subject: Removing template data from XML tree added (bzr r12379.2.18) --- src/ui/dialog/template-widget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index 4b64c1c73..66121a73a 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -62,7 +62,7 @@ void TemplateWidget::create() if (_current_template.is_procedural) {} else { - sp_file_open(_current_template.path, NULL); + sp_file_open(_current_template.path, NULL, REPLACE_EMPTY | ADD_TO_RECENT | IS_FROM_TEMPLATE); } } -- cgit v1.2.3 From 6ae6c0bea96eef09907091279e0678aa5f83102d Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Sun, 4 Aug 2013 18:01:18 -0400 Subject: Switched to global UnitTable. (bzr r12380.1.62) --- src/ui/dialog/clonetiler.cpp | 6 +----- src/ui/dialog/export.cpp | 4 ++-- src/ui/widget/page-sizer.cpp | 3 +-- src/ui/widget/page-sizer.h | 1 - src/ui/widget/scalar-unit.cpp | 7 ++++--- src/ui/widget/selected-style.cpp | 3 ++- src/ui/widget/unit-menu.cpp | 16 +++++++++------- src/ui/widget/unit-menu.h | 3 --- src/ui/widget/unit-tracker.cpp | 12 +++++++----- src/ui/widget/unit-tracker.h | 2 -- 10 files changed, 26 insertions(+), 31 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index abb2512f7..b3675440b 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -58,6 +58,7 @@ #include "sp-root.h" using Inkscape::DocumentUndo; +using Inkscape::Util::unit_table; namespace Inkscape { namespace UI { @@ -1107,7 +1108,6 @@ CloneTiler::CloneTiler (void) : double value = prefs->getDouble(prefs_path + "fillwidth", 50.0); Inkscape::Util::Unit const unit = unit_menu->getUnit(); - Inkscape::Util::UnitTable unit_table; gdouble const units = Inkscape::Util::Quantity::convert(value, "px", unit); fill_width->set_value (units); @@ -1141,7 +1141,6 @@ CloneTiler::CloneTiler (void) : double value = prefs->getDouble(prefs_path + "fillheight", 50.0); Inkscape::Util::Unit const unit = unit_menu->getUnit(); - Inkscape::Util::UnitTable unit_table; gdouble const units = Inkscape::Util::Quantity::convert(value, "px", unit); fill_height->set_value (units); @@ -2950,7 +2949,6 @@ void CloneTiler::clonetiler_fill_width_changed(GtkAdjustment *adj, Inkscape::UI: { gdouble const raw_dist = gtk_adjustment_get_value (adj); Inkscape::Util::Unit const unit = u->getUnit(); - Inkscape::Util::UnitTable unit_table; gdouble const pixels = Inkscape::Util::Quantity::convert(raw_dist, unit, "px"); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -2961,7 +2959,6 @@ void CloneTiler::clonetiler_fill_height_changed(GtkAdjustment *adj, Inkscape::UI { gdouble const raw_dist = gtk_adjustment_get_value (adj); Inkscape::Util::Unit const unit = u->getUnit(); - Inkscape::Util::UnitTable unit_table; gdouble const pixels = Inkscape::Util::Quantity::convert(raw_dist, unit, "px"); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -2975,7 +2972,6 @@ void CloneTiler::clonetiler_unit_changed() gdouble height_pixels = prefs->getDouble(prefs_path + "fillheight"); Inkscape::Util::Unit unit = unit_menu->getUnit(); - Inkscape::Util::UnitTable unit_table; gdouble width_value = Inkscape::Util::Quantity::convert(width_pixels, "px", unit); gdouble height_value = Inkscape::Util::Quantity::convert(height_pixels, "px", unit); diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 063902aa7..2c92608d7 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -107,6 +107,8 @@ #include "verbs.h" #include "export.h" +using Inkscape::Util::unit_table; + namespace { class MessageCleaner @@ -1883,7 +1885,6 @@ void Export::setValuePx( Gtk::Adjustment *adj, double val) #endif { const Unit unit = unit_selector->getUnit(); - Inkscape::Util::UnitTable unit_table; setValue(adj, Inkscape::Util::Quantity::convert(val, "px", unit)); @@ -1934,7 +1935,6 @@ float Export::getValuePx( Gtk::Adjustment *adj ) { float value = getValue( adj); const Unit unit = unit_selector->getUnit(); - Inkscape::Util::UnitTable unit_table; return Inkscape::Util::Quantity::convert(value, unit, "px"); } // end of sp_export_value_get_px() diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index b15ab2823..d912fd9d3 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -47,9 +47,8 @@ #include "xml/node.h" #include "xml/repr.h" -static Inkscape::Util::UnitTable unit_table; - using std::pair; +using Inkscape::Util::unit_table; namespace Inkscape { namespace UI { diff --git a/src/ui/widget/page-sizer.h b/src/ui/widget/page-sizer.h index fc8edeeac..34ed7592d 100644 --- a/src/ui/widget/page-sizer.h +++ b/src/ui/widget/page-sizer.h @@ -117,7 +117,6 @@ private: name = ""; smaller = 0.0; larger = 0.0; - static Inkscape::Util::UnitTable unit_table; unit = unit_table.getUnit("px"); } diff --git a/src/ui/widget/scalar-unit.cpp b/src/ui/widget/scalar-unit.cpp index 99ff70846..2f4c1f341 100644 --- a/src/ui/widget/scalar-unit.cpp +++ b/src/ui/widget/scalar-unit.cpp @@ -16,6 +16,8 @@ #include "scalar-unit.h" #include "spinbutton.h" +using Inkscape::Util::unit_table; + namespace Inkscape { namespace UI { namespace Widget { @@ -226,9 +228,8 @@ void ScalarUnit::on_unit_changed() Glib::ustring abbr = _unit_menu->getUnitAbbr(); _suffix->set_label(abbr); - Inkscape::Util::UnitTable &table = _unit_menu->getUnitTable(); - Inkscape::Util::Unit new_unit = (table.getUnit(abbr)); - Inkscape::Util::Unit old_unit = (table.getUnit(lastUnits)); + Inkscape::Util::Unit new_unit = (unit_table.getUnit(abbr)); + Inkscape::Util::Unit old_unit = (unit_table.getUnit(lastUnits)); double convertedVal = 0; if (old_unit.type == UNIT_TYPE_DIMENSIONLESS && new_unit.type == UNIT_TYPE_LINEAR) { diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index edf53d25c..388a0bcea 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -52,6 +52,8 @@ #include "gradient-chemistry.h" #include "util/units.h" +using Inkscape::Util::unit_table; + static gdouble const _sw_presets[] = { 32 , 16 , 10 , 8 , 6 , 4 , 3 , 2 , 1.5 , 1 , 0.75 , 0.5 , 0.25 , 0.1 }; static gchar const *const _sw_presets_str[] = {"32", "16", "10", "8", "6", "4", "3", "2", "1.5", "1", "0.75", "0.5", "0.25", "0.1"}; @@ -307,7 +309,6 @@ SelectedStyle::SelectedStyle(bool /*layout*/) { int row = 0; - Inkscape::Util::UnitTable unit_table; Inkscape::Util::UnitTable::UnitMap m = unit_table.units(Inkscape::Util::UNIT_TYPE_LINEAR); Inkscape::Util::UnitTable::UnitMap::iterator iter = m.begin(); while(iter != m.end()) { diff --git a/src/ui/widget/unit-menu.cpp b/src/ui/widget/unit-menu.cpp index 18b7bcab9..111226774 100644 --- a/src/ui/widget/unit-menu.cpp +++ b/src/ui/widget/unit-menu.cpp @@ -15,6 +15,8 @@ #include "unit-menu.h" +using Inkscape::Util::unit_table; + namespace Inkscape { namespace UI { namespace Widget { @@ -30,7 +32,7 @@ UnitMenu::~UnitMenu() { bool UnitMenu::setUnitType(UnitType unit_type) { // Expand the unit widget with unit entries from the unit table - UnitTable::UnitMap m = _unit_table.units(unit_type); + UnitTable::UnitMap m = unit_table.units(unit_type); UnitTable::UnitMap::iterator iter = m.begin(); while(iter != m.end()) { Glib::ustring text = (*iter).first; @@ -38,7 +40,7 @@ bool UnitMenu::setUnitType(UnitType unit_type) ++iter; } _type = unit_type; - set_active_text(_unit_table.primary(unit_type)); + set_active_text(unit_table.primary(unit_type)); return true; } @@ -52,7 +54,7 @@ bool UnitMenu::resetUnitType(UnitType unit_type) void UnitMenu::addUnit(Unit const& u) { - _unit_table.addUnit(u, false); + unit_table.addUnit(u, false); append(u.abbr); } @@ -60,9 +62,9 @@ Unit UnitMenu::getUnit() const { if (get_active_text() == "") { g_assert(_type != UNIT_TYPE_NONE); - return _unit_table.getUnit(_unit_table.primary(_type)); + return unit_table.getUnit(unit_table.primary(_type)); } - return _unit_table.getUnit(get_active_text()); + return unit_table.getUnit(get_active_text()); } bool UnitMenu::setUnit(Glib::ustring const & unit) @@ -112,8 +114,8 @@ double UnitMenu::getConversion(Glib::ustring const &new_unit_abbr, Glib::ustring { double old_factor = getUnit().factor; if (old_unit_abbr != "no_unit") - old_factor = _unit_table.getUnit(old_unit_abbr).factor; - Unit new_unit = _unit_table.getUnit(new_unit_abbr); + old_factor = unit_table.getUnit(old_unit_abbr).factor; + Unit new_unit = unit_table.getUnit(new_unit_abbr); // Catch the case of zero or negative unit factors (error!) if (old_factor < 0.0000001 || diff --git a/src/ui/widget/unit-menu.h b/src/ui/widget/unit-menu.h index 3104d5aef..3f4df6bf9 100644 --- a/src/ui/widget/unit-menu.h +++ b/src/ui/widget/unit-menu.h @@ -127,10 +127,7 @@ public: */ bool isRadial() const; - UnitTable &getUnitTable() {return _unit_table;} - protected: - UnitTable _unit_table; UnitType _type; }; diff --git a/src/ui/widget/unit-tracker.cpp b/src/ui/widget/unit-tracker.cpp index 99074be40..5b2dc031b 100644 --- a/src/ui/widget/unit-tracker.cpp +++ b/src/ui/widget/unit-tracker.cpp @@ -17,6 +17,9 @@ #define COLUMN_STRING 0 +using Inkscape::Util::UnitTable; +using Inkscape::Util::unit_table; + namespace Inkscape { namespace UI { namespace Widget { @@ -32,10 +35,9 @@ UnitTracker::UnitTracker(UnitType unit_type) : _priorValues() { _store = gtk_list_store_new(1, G_TYPE_STRING); - static Inkscape::Util::UnitTable unit_table; GtkTreeIter iter; - UnitTable::UnitMap m = _unit_table.units(unit_type); + UnitTable::UnitMap m = unit_table.units(unit_type); UnitTable::UnitMap::iterator m_iter = m.begin(); while(m_iter != m.end()) { Glib::ustring text = (*m_iter).first; @@ -99,7 +101,7 @@ void UnitTracker::setActiveUnit(Inkscape::Util::Unit const *unit) void UnitTracker::setActiveUnitByAbbr(gchar const *abbr) { - Inkscape::Util::Unit u = _unit_table.getUnit(abbr); + Inkscape::Util::Unit u = unit_table.getUnit(abbr); setActiveUnit(&u); } @@ -195,13 +197,13 @@ void UnitTracker::_setActive(gint active) if (found) { gchar *abbr; gtk_tree_model_get(GTK_TREE_MODEL(_store), &iter, COLUMN_STRING, &abbr, -1); - Inkscape::Util::Unit unit = _unit_table.getUnit(abbr); + Inkscape::Util::Unit unit = unit_table.getUnit(abbr); found = gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(_store), &iter, NULL, active); if (found) { gchar *newAbbr; gtk_tree_model_get(GTK_TREE_MODEL(_store), &iter, COLUMN_STRING, &newAbbr, -1); - Inkscape::Util::Unit newUnit = _unit_table.getUnit(newAbbr); + Inkscape::Util::Unit newUnit = unit_table.getUnit(newAbbr); _activeUnit = newUnit; if (_adjList) { diff --git a/src/ui/widget/unit-tracker.h b/src/ui/widget/unit-tracker.h index cdcb07c57..19559ae1c 100644 --- a/src/ui/widget/unit-tracker.h +++ b/src/ui/widget/unit-tracker.h @@ -21,7 +21,6 @@ #include "util/units.h" using Inkscape::Util::Unit; -using Inkscape::Util::UnitTable; using Inkscape::Util::UnitType; namespace Inkscape { @@ -46,7 +45,6 @@ public: GtkAction *createAction(gchar const *name, gchar const *label, gchar const *tooltip); protected: - UnitTable _unit_table; UnitType _type; private: -- cgit v1.2.3 From 0ec2d349388ad6a4e0c35039b2f5c09cccadc6b0 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Tue, 6 Aug 2013 14:44:23 -0400 Subject: Fixed bug in page sizer. (bzr r12380.1.63) --- src/ui/widget/page-sizer.cpp | 138 +++++++++++++++++++++---------------------- 1 file changed, 69 insertions(+), 69 deletions(-) (limited to 'src/ui') diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index d912fd9d3..8287452d7 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -97,7 +97,7 @@ struct PaperSizeRec { char const * const name; //name double const smaller; //lesser dimension double const larger; //greater dimension - Inkscape::Util::Unit const unit; //units + Glib::ustring const unit; //units }; // list of page formats that should be in landscape automatically @@ -115,31 +115,31 @@ fill_landscape_papers() { } static PaperSizeRec const inkscape_papers[] = { - { "A4", 210, 297, unit_table.getUnit("mm") }, - { "US Letter", 8.5, 11, unit_table.getUnit("in") }, - { "US Legal", 8.5, 14, unit_table.getUnit("in") }, - { "US Executive", 7.25, 10.5, unit_table.getUnit("in") }, - { "A0", 841, 1189, unit_table.getUnit("mm") }, - { "A1", 594, 841, unit_table.getUnit("mm") }, - { "A2", 420, 594, unit_table.getUnit("mm") }, - { "A3", 297, 420, unit_table.getUnit("mm") }, - { "A5", 148, 210, unit_table.getUnit("mm") }, - { "A6", 105, 148, unit_table.getUnit("mm") }, - { "A7", 74, 105, unit_table.getUnit("mm") }, - { "A8", 52, 74, unit_table.getUnit("mm") }, - { "A9", 37, 52, unit_table.getUnit("mm") }, - { "A10", 26, 37, unit_table.getUnit("mm") }, - { "B0", 1000, 1414, unit_table.getUnit("mm") }, - { "B1", 707, 1000, unit_table.getUnit("mm") }, - { "B2", 500, 707, unit_table.getUnit("mm") }, - { "B3", 353, 500, unit_table.getUnit("mm") }, - { "B4", 250, 353, unit_table.getUnit("mm") }, - { "B5", 176, 250, unit_table.getUnit("mm") }, - { "B6", 125, 176, unit_table.getUnit("mm") }, - { "B7", 88, 125, unit_table.getUnit("mm") }, - { "B8", 62, 88, unit_table.getUnit("mm") }, - { "B9", 44, 62, unit_table.getUnit("mm") }, - { "B10", 31, 44, unit_table.getUnit("mm") }, + { "A4", 210, 297, "mm" }, + { "US Letter", 8.5, 11, "in" }, + { "US Legal", 8.5, 14, "in" }, + { "US Executive", 7.25, 10.5, "in" }, + { "A0", 841, 1189, "mm" }, + { "A1", 594, 841, "mm" }, + { "A2", 420, 594, "mm" }, + { "A3", 297, 420, "mm" }, + { "A5", 148, 210, "mm" }, + { "A6", 105, 148, "mm" }, + { "A7", 74, 105, "mm" }, + { "A8", 52, 74, "mm" }, + { "A9", 37, 52, "mm" }, + { "A10", 26, 37, "mm" }, + { "B0", 1000, 1414, "mm" }, + { "B1", 707, 1000, "mm" }, + { "B2", 500, 707, "mm" }, + { "B3", 353, 500, "mm" }, + { "B4", 250, 353, "mm" }, + { "B5", 176, 250, "mm" }, + { "B6", 125, 176, "mm" }, + { "B7", 88, 125, "mm" }, + { "B8", 62, 88, "mm" }, + { "B9", 44, 62, "mm" }, + { "B10", 31, 44, "mm" }, @@ -151,63 +151,63 @@ static PaperSizeRec const inkscape_papers[] = { don't know what D and E series are used for. */ - { "C0", 917, 1297, unit_table.getUnit("mm") }, - { "C1", 648, 917, unit_table.getUnit("mm") }, - { "C2", 458, 648, unit_table.getUnit("mm") }, - { "C3", 324, 458, unit_table.getUnit("mm") }, - { "C4", 229, 324, unit_table.getUnit("mm") }, - { "C5", 162, 229, unit_table.getUnit("mm") }, - { "C6", 114, 162, unit_table.getUnit("mm") }, - { "C7", 81, 114, unit_table.getUnit("mm") }, - { "C8", 57, 81, unit_table.getUnit("mm") }, - { "C9", 40, 57, unit_table.getUnit("mm") }, - { "C10", 28, 40, unit_table.getUnit("mm") }, - { "D1", 545, 771, unit_table.getUnit("mm") }, - { "D2", 385, 545, unit_table.getUnit("mm") }, - { "D3", 272, 385, unit_table.getUnit("mm") }, - { "D4", 192, 272, unit_table.getUnit("mm") }, - { "D5", 136, 192, unit_table.getUnit("mm") }, - { "D6", 96, 136, unit_table.getUnit("mm") }, - { "D7", 68, 96, unit_table.getUnit("mm") }, - { "E3", 400, 560, unit_table.getUnit("mm") }, - { "E4", 280, 400, unit_table.getUnit("mm") }, - { "E5", 200, 280, unit_table.getUnit("mm") }, - { "E6", 140, 200, unit_table.getUnit("mm") }, + { "C0", 917, 1297, "mm" }, + { "C1", 648, 917, "mm" }, + { "C2", 458, 648, "mm" }, + { "C3", 324, 458, "mm" }, + { "C4", 229, 324, "mm" }, + { "C5", 162, 229, "mm" }, + { "C6", 114, 162, "mm" }, + { "C7", 81, 114, "mm" }, + { "C8", 57, 81, "mm" }, + { "C9", 40, 57, "mm" }, + { "C10", 28, 40, "mm" }, + { "D1", 545, 771, "mm" }, + { "D2", 385, 545, "mm" }, + { "D3", 272, 385, "mm" }, + { "D4", 192, 272, "mm" }, + { "D5", 136, 192, "mm" }, + { "D6", 96, 136, "mm" }, + { "D7", 68, 96, "mm" }, + { "E3", 400, 560, "mm" }, + { "E4", 280, 400, "mm" }, + { "E5", 200, 280, "mm" }, + { "E6", 140, 200, "mm" }, //#endif - { "CSE", 462, 649, unit_table.getUnit("pt") }, - { "US #10 Envelope", 4.125, 9.5, unit_table.getUnit("in") }, + { "CSE", 462, 649, "pt" }, + { "US #10 Envelope", 4.125, 9.5, "in" }, /* See http://www.hbp.com/content/PCR_envelopes.cfm for a much larger list of US envelope sizes. */ - { "DL Envelope", 110, 220, unit_table.getUnit("mm") }, - { "Ledger/Tabloid", 11, 17, unit_table.getUnit("in") }, + { "DL Envelope", 110, 220, "mm" }, + { "Ledger/Tabloid", 11, 17, "in" }, /* Note that `Folio' (used in QPrinter/KPrinter) is deliberately absent from this list, as it means different sizes to different people: different people may expect the width to be either 8, 8.25 or 8.5 inches, and the height to be either 13 or 13.5 inches, even restricting our interpretation to foolscap folio. If you wish to introduce a folio-like page size to the list, then please consider using a name more specific than just `Folio' or `Foolscap Folio'. */ - { "Banner 468x60", 60, 468, unit_table.getUnit("px") }, - { "Icon 16x16", 16, 16, unit_table.getUnit("px") }, - { "Icon 32x32", 32, 32, unit_table.getUnit("px") }, - { "Icon 48x48", 48, 48, unit_table.getUnit("px") }, + { "Banner 468x60", 60, 468, "px" }, + { "Icon 16x16", 16, 16, "px" }, + { "Icon 32x32", 32, 32, "px" }, + { "Icon 48x48", 48, 48, "px" }, /* business cards */ - { "Business Card (ISO 7810)", 53.98, 85.60, unit_table.getUnit("mm") }, - { "Business Card (US)", 2, 3.5, unit_table.getUnit("in") }, - { "Business Card (Europe)", 55, 85, unit_table.getUnit("mm") }, - { "Business Card (Aus/NZ)", 55, 90, unit_table.getUnit("mm") }, + { "Business Card (ISO 7810)", 53.98, 85.60, "mm" }, + { "Business Card (US)", 2, 3.5, "in" }, + { "Business Card (Europe)", 55, 85, "mm" }, + { "Business Card (Aus/NZ)", 55, 90, "mm" }, // Start Arch Series List - { "Arch A", 9, 12, unit_table.getUnit("in") }, // 229 x 305 mm - { "Arch B", 12, 18, unit_table.getUnit("in") }, // 305 x 457 mm - { "Arch C", 18, 24, unit_table.getUnit("in") }, // 457 x 610 mm - { "Arch D", 24, 36, unit_table.getUnit("in") }, // 610 x 914 mm - { "Arch E", 36, 48, unit_table.getUnit("in") }, // 914 x 1219 mm - { "Arch E1", 30, 42, unit_table.getUnit("in") }, // 762 x 1067 mm + { "Arch A", 9, 12, "in" }, // 229 x 305 mm + { "Arch B", 12, 18, "in" }, // 305 x 457 mm + { "Arch C", 18, 24, "in" }, // 457 x 610 mm + { "Arch D", 24, 36, "in" }, // 610 x 914 mm + { "Arch E", 36, 48, "in" }, // 914 x 1219 mm + { "Arch E1", 30, 42, "in" }, // 762 x 1067 mm /* * The above list of Arch sizes were taken from the following site: @@ -218,7 +218,7 @@ static PaperSizeRec const inkscape_papers[] = { * September 2009 - DAK */ - { NULL, 0, 0, unit_table.getUnit("px") }, + { NULL, 0, 0, "px" }, }; @@ -277,8 +277,8 @@ PageSizer::PageSizer(Registry & _wr) char formatBuf[80]; snprintf(formatBuf, 79, "%0.1f x %0.1f", p->smaller, p->larger); Glib::ustring desc = formatBuf; - desc.append(" " + p->unit.abbr); - PaperSize paper(name, p->smaller, p->larger, p->unit); + desc.append(" " + p->unit); + PaperSize paper(name, p->smaller, p->larger, unit_table.getUnit(p->unit)); _paperSizeTable[name] = paper; Gtk::TreeModel::Row row = *(_paperSizeListStore->append()); row[_paperSizeListColumns.nameColumn] = name; -- cgit v1.2.3 From 625d70be1e222b3cfbbf6527b2829b645f369cd2 Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Tue, 6 Aug 2013 22:48:28 +0200 Subject: Adapted sp_file_new for use with templates (bzr r12379.2.19) --- src/ui/dialog/template-widget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index 66121a73a..7e0599049 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -62,7 +62,7 @@ void TemplateWidget::create() if (_current_template.is_procedural) {} else { - sp_file_open(_current_template.path, NULL, REPLACE_EMPTY | ADD_TO_RECENT | IS_FROM_TEMPLATE); + sp_file_new(_current_template.path); } } -- cgit v1.2.3 From c9946d39f8b2d37991be9a02e3b0f133f48bdb22 Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Sat, 10 Aug 2013 15:23:01 +0200 Subject: Existing templates metadata added. Small keywords processing fix. (bzr r12379.2.20) --- src/ui/dialog/template-load-tab.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/ui') diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index ade595eaa..b37b68ae3 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -207,6 +207,7 @@ TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(const Glib:: rdoc = sp_repr_read_file(path.data(), SP_SVG_NS_URI); Inkscape::XML::Node *myRoot; Inkscape::XML::Node *dataNode; + std::cerr << path.c_str(); if (rdoc){ myRoot = rdoc->root(); if (strcmp(myRoot->name(), "svg:svg") != 0){ // Wrong file format @@ -236,9 +237,13 @@ TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(const Glib:: Glib::ustring data = dataNode->firstChild()->content(); while (!data.empty()){ int pos = data.find_first_of(" "); + if (pos == Glib::ustring::npos) + pos = data.size(); + Glib::ustring keyword = dgettext("Document template keyword", data.substr(0, pos).data()); result.keywords.insert(keyword); _keywords.insert(keyword); + if (pos == data.size()) break; data.erase(0, pos+1); -- cgit v1.2.3 From 05f008356889de30ff55df1f73030003ed7cc312 Mon Sep 17 00:00:00 2001 From: Eric Greveson Date: Mon, 12 Aug 2013 16:39:48 +0100 Subject: Allow Object to Path verb from non-GUI (DBus) interface (bzr r12473.1.1) --- src/ui/dialog/livepatheffect-editor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp index 6c6f3a582..6dc9c1ee3 100644 --- a/src/ui/dialog/livepatheffect-editor.cpp +++ b/src/ui/dialog/livepatheffect-editor.cpp @@ -416,7 +416,7 @@ LivePathEffectEditor::onAdd() // If item is a SPRect, convert it to path first: if ( SP_IS_RECT(item) ) { - sp_selected_path_to_curves(current_desktop, false); + sp_selected_path_to_curves(sel, current_desktop, false); item = sel->singleItem(); // get new item } -- cgit v1.2.3 From ca6b42152e492dc4e1a4554aae7ae1712eeecab7 Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Tue, 13 Aug 2013 12:10:07 +0200 Subject: Cleanups before merge (bzr r12379.2.21) --- src/ui/dialog/template-load-tab.cpp | 3 +-- src/ui/dialog/template-load-tab.h | 1 - src/ui/dialog/template-widget.cpp | 4 ++-- src/ui/dialog/template-widget.h | 6 +++--- 4 files changed, 6 insertions(+), 8 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index b37b68ae3..4fee4c5e7 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -14,7 +14,6 @@ #include #include #include -#include #include "interface.h" #include "file.h" @@ -207,7 +206,7 @@ TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(const Glib:: rdoc = sp_repr_read_file(path.data(), SP_SVG_NS_URI); Inkscape::XML::Node *myRoot; Inkscape::XML::Node *dataNode; - std::cerr << path.c_str(); + if (rdoc){ myRoot = rdoc->root(); if (strcmp(myRoot->name(), "svg:svg") != 0){ // Wrong file format diff --git a/src/ui/dialog/template-load-tab.h b/src/ui/dialog/template-load-tab.h index c3c512374..50f3e0be2 100644 --- a/src/ui/dialog/template-load-tab.h +++ b/src/ui/dialog/template-load-tab.h @@ -71,7 +71,6 @@ protected: void _loadTemplates(); void _initLists(); - // Gtk::HBox _main_box; Gtk::VBox _tlist_box; Gtk::HBox _search_box; TemplateWidget *_info_widget; diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index 7e0599049..0e05f292c 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -30,7 +30,7 @@ TemplateWidget::TemplateWidget() , _short_description_label(_(" ")) , _template_author_label(_(" ")) , _template_name_label(_("no template selected")) - , _preview_image(" ") + , _preview_image() , _preview_render() { pack_start(_template_name_label, Gtk::PACK_SHRINK, 10); @@ -41,7 +41,7 @@ TemplateWidget::TemplateWidget() _preview_box.pack_start(_preview_render, Gtk::PACK_EXPAND_PADDING, 10); _short_description_label.set_line_wrap(true); - _short_description_label.set_size_request(200); + //_short_description_label.set_size_request(200); Gtk::Alignment *align; align = manage(new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER, 0.0, 0.0)); diff --git a/src/ui/dialog/template-widget.h b/src/ui/dialog/template-widget.h index 3c95208de..c7847460f 100644 --- a/src/ui/dialog/template-widget.h +++ b/src/ui/dialog/template-widget.h @@ -31,12 +31,12 @@ private: TemplateLoadTab::TemplateData _current_template; Gtk::Button _more_info_button; - Gtk::Label _short_description_label; - Gtk::Label _template_author_label; - Gtk::Label _template_name_label; Gtk::HBox _preview_box; Gtk::Image _preview_image; Dialog::SVGPreview _preview_render; + Gtk::Label _short_description_label; + Gtk::Label _template_author_label; + Gtk::Label _template_name_label; void _displayTemplateDetails(); }; -- cgit v1.2.3 From 0167937d063bb0e313aba987cbc69b59e18d2ed4 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Thu, 15 Aug 2013 01:15:59 +0200 Subject: Fix warning and hopefully fix build failures on Launchpad (bzr r12478) --- src/ui/dialog/template-load-tab.cpp | 5 ++++- src/ui/dialog/template-widget.cpp | 2 -- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index 4fee4c5e7..0123f663f 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -14,6 +14,9 @@ #include #include #include +#include +#include +#include #include "interface.h" #include "file.h" @@ -235,7 +238,7 @@ TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(const Glib:: if ((dataNode = sp_repr_lookup_name(myRoot, "inkscape:_keywords")) != NULL){ Glib::ustring data = dataNode->firstChild()->content(); while (!data.empty()){ - int pos = data.find_first_of(" "); + std::size_t pos = data.find_first_of(" "); if (pos == Glib::ustring::npos) pos = data.size(); diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index 0e05f292c..dfc26913f 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -30,8 +30,6 @@ TemplateWidget::TemplateWidget() , _short_description_label(_(" ")) , _template_author_label(_(" ")) , _template_name_label(_("no template selected")) - , _preview_image() - , _preview_render() { pack_start(_template_name_label, Gtk::PACK_SHRINK, 10); pack_start(_template_author_label, Gtk::PACK_SHRINK, 0); -- cgit v1.2.3 From 0be39e335f73b5b7770f1580871f48ca1791ced4 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Thu, 15 Aug 2013 10:07:55 +0100 Subject: Fix Gtk+ 3 build failure and make check (bzr r12479) --- src/ui/dialog/template-load-tab.cpp | 3 ++- src/ui/dialog/template-widget.cpp | 8 ++++---- src/ui/dialog/template-widget.h | 3 ++- 3 files changed, 8 insertions(+), 6 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index 0123f663f..265ee8026 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -8,9 +8,10 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "template-load-tab.h" #include "template-widget.h" +#include "template-load-tab.h" + #include #include #include diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index dfc26913f..be7e2b515 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -1,5 +1,3 @@ - - /** @file * @brief New From Template - templates widget - implementation */ @@ -11,15 +9,17 @@ */ #include "template-widget.h" -#include "template-load-tab.h" -#include "file.h" #include #include #include #include + #include +#include +#include "template-load-tab.h" +#include "file.h" namespace Inkscape { namespace UI { diff --git a/src/ui/dialog/template-widget.h b/src/ui/dialog/template-widget.h index c7847460f..f7e1267ce 100644 --- a/src/ui/dialog/template-widget.h +++ b/src/ui/dialog/template-widget.h @@ -11,10 +11,11 @@ #ifndef INKSCAPE_SEEN_UI_DIALOG_TEMPLATE_WIDGET_H #define INKSCAPE_SEEN_UI_DIALOG_TEMPLATE_WIDGET_H -#include "template-load-tab.h" #include "filedialogimpl-gtkmm.h" + #include +#include "template-load-tab.h" namespace Inkscape { namespace UI { -- cgit v1.2.3 From 69ac4cffff595c46b3f8dd2bcceab6bccf6e4581 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Thu, 15 Aug 2013 21:10:29 +0200 Subject: Add option to write out path data using only relative coordinates (in addition to using only absolute coordinates or using a mixture of absolute and relative coordinates optimized for length). (bzr r12480) --- src/ui/dialog/inkscape-preferences.cpp | 8 ++++++-- src/ui/dialog/inkscape-preferences.h | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 7890b0b4c..b06c1fd1f 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -879,8 +879,12 @@ void InkscapePreferences::initPageIO() _page_svgoutput.add_group_header( _("Path data")); - _svgoutput_allowrelativecoordinates.init( _("Allow relative coordinates"), "/options/svgoutput/allowrelativecoordinates", true); - _page_svgoutput.add_line( true, "", _svgoutput_allowrelativecoordinates, "", _("If set, relative coordinates may be used in path data"), false); + int const numPathstringFormat = 3; + Glib::ustring pathstringFormatLabels[numPathstringFormat] = {_("Absolute"), _("Relative"), _("Optimized")}; + int pathstringFormatValues[numPathstringFormat] = {0, 1, 2}; + + _svgoutput_pathformat.init("/options/svgoutput/pathstring_format", pathstringFormatLabels, pathstringFormatValues, numPathstringFormat, 2); + _page_svgoutput.add_line( true, _("Path string format"), _svgoutput_pathformat, "", _("Path data should be written: only with absolute coordinates, only with relative coordinates, or optimized for string length (mixed absolute and relative coordinates)"), false); _svgoutput_forcerepeatcommands.init( _("Force repeat commands"), "/options/svgoutput/forcerepeatcommands", false); _page_svgoutput.add_line( true, "", _svgoutput_forcerepeatcommands, "", _("Force repeating of the same path command (for example, 'L 1,2 L 3,4' instead of 'L 1,2 3,4')"), false); diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h index 37c05df05..56222fb22 100644 --- a/src/ui/dialog/inkscape-preferences.h +++ b/src/ui/dialog/inkscape-preferences.h @@ -426,7 +426,7 @@ protected: UI::Widget::PrefSpinButton _svgoutput_minimumexponent; UI::Widget::PrefCheckButton _svgoutput_inlineattrs; UI::Widget::PrefSpinButton _svgoutput_indent; - UI::Widget::PrefCheckButton _svgoutput_allowrelativecoordinates; + UI::Widget::PrefCombo _svgoutput_pathformat; UI::Widget::PrefCheckButton _svgoutput_forcerepeatcommands; // Attribute Checking controls for SVG Output page: -- cgit v1.2.3 From e9468d5c8bc974ee96dc7537e0d13fe2def0e615 Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Sat, 24 Aug 2013 23:36:04 +0200 Subject: Add listing procedural templates in NewFromTemplate dialog. (bzr r12481.1.1) --- src/ui/dialog/template-load-tab.cpp | 100 ++++++++++++++++++++++++------------ src/ui/dialog/template-load-tab.h | 4 ++ 2 files changed, 72 insertions(+), 32 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index 265ee8026..280b3b073 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -18,6 +18,8 @@ #include #include #include +#include +#include #include "interface.h" #include "file.h" @@ -27,6 +29,8 @@ #include "xml/repr.h" #include "xml/document.h" #include "xml/node.h" +#include "extension/db.h" +#include "extension/effect.h" namespace Inkscape { @@ -187,6 +191,10 @@ void TemplateLoadTab::_loadTemplates() // system templates dir _getTemplatesFromDir(INKSCAPE_TEMPLATESDIR + _loading_path); + + + // procedural templates + _getProceduralTemplates(); } @@ -209,7 +217,6 @@ TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(const Glib:: Inkscape::XML::Document *rdoc; rdoc = sp_repr_read_file(path.data(), SP_SVG_NS_URI); Inkscape::XML::Node *myRoot; - Inkscape::XML::Node *dataNode; if (rdoc){ myRoot = rdoc->root(); @@ -221,37 +228,7 @@ TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(const Glib:: if (myRoot == NULL) // No template info return result; - - if ((dataNode = sp_repr_lookup_name(myRoot, "inkscape:_name")) != NULL) - result.display_name = dgettext("Document template name", dataNode->firstChild()->content()); - if ((dataNode = sp_repr_lookup_name(myRoot, "inkscape:author")) != NULL) - result.author = dataNode->firstChild()->content(); - if ((dataNode = sp_repr_lookup_name(myRoot, "inkscape:_short")) != NULL) - result.short_description = dgettext("Document template short description", dataNode->firstChild()->content()); - if ((dataNode = sp_repr_lookup_name(myRoot, "inkscape:_long") )!= NULL) - result.long_description = dgettext("Document template long description", dataNode->firstChild()->content()); - if ((dataNode = sp_repr_lookup_name(myRoot, "inkscape:preview")) != NULL) - result.preview_name = dataNode->firstChild()->content(); - if ((dataNode = sp_repr_lookup_name(myRoot, "inkscape:date")) != NULL){ - result.creation_date = dataNode->firstChild()->content(); - } - - if ((dataNode = sp_repr_lookup_name(myRoot, "inkscape:_keywords")) != NULL){ - Glib::ustring data = dataNode->firstChild()->content(); - while (!data.empty()){ - std::size_t pos = data.find_first_of(" "); - if (pos == Glib::ustring::npos) - pos = data.size(); - - Glib::ustring keyword = dgettext("Document template keyword", data.substr(0, pos).data()); - result.keywords.insert(keyword); - _keywords.insert(keyword); - - if (pos == data.size()) - break; - data.erase(0, pos+1); - } - } + _getDataFromNode(myRoot, result); } return result; @@ -277,5 +254,64 @@ void TemplateLoadTab::_getTemplatesFromDir(const Glib::ustring &path) } } + +void TemplateLoadTab::_getProceduralTemplates() +{ + std::list effects; + Inkscape::Extension::db.get_effect_list(effects); + + std::list::iterator it = effects.begin(); + while (it != effects.end()){ + Inkscape::XML::Node *myRoot; + myRoot = (*it)->get_repr(); + myRoot = sp_repr_lookup_name(myRoot, "inkscape:_templateinfo"); + + if (myRoot){ + TemplateData result; + result.display_name = (*it)->get_name(); + result.is_procedural = true; + result.path = ""; + _getDataFromNode(myRoot, result); + _tdata[result.display_name] = result; + } + ++it; + } +} + + +void TemplateLoadTab::_getDataFromNode(Inkscape::XML::Node *dataNode, TemplateData &data) +{ + Inkscape::XML::Node *currentData; + if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:_name")) != NULL) + data.display_name = dgettext("Document template name", currentData->firstChild()->content()); + if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:author")) != NULL) + data.author = currentData->firstChild()->content(); + if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:_short")) != NULL) + data.short_description = dgettext("Document template short description", currentData->firstChild()->content()); + if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:_long") )!= NULL) + data.long_description = dgettext("Document template long description", currentData->firstChild()->content()); + if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:preview")) != NULL) + data.preview_name = currentData->firstChild()->content(); + if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:date")) != NULL) + data.creation_date = currentData->firstChild()->content(); + + if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:_keywords")) != NULL){ + Glib::ustring tplKeywords = currentData->firstChild()->content(); + while (!tplKeywords.empty()){ + std::size_t pos = tplKeywords.find_first_of(" "); + if (pos == Glib::ustring::npos) + pos = tplKeywords.size(); + + Glib::ustring keyword = dgettext("Document template keyword", tplKeywords.substr(0, pos).data()); + data.keywords.insert(keyword); + _keywords.insert(keyword); + + if (pos == tplKeywords.size()) + break; + tplKeywords.erase(0, pos+1); + } + } +} + } } diff --git a/src/ui/dialog/template-load-tab.h b/src/ui/dialog/template-load-tab.h index 50f3e0be2..c3817cf1b 100644 --- a/src/ui/dialog/template-load-tab.h +++ b/src/ui/dialog/template-load-tab.h @@ -19,6 +19,8 @@ #include #include +#include "xml/node.h" + namespace Inkscape { namespace UI { @@ -91,6 +93,8 @@ private: SearchType _current_search_type; + void _getDataFromNode(Inkscape::XML::Node *, TemplateData &); + void _getProceduralTemplates(); void _getTemplatesFromDir(const Glib::ustring &); void _keywordSelected(); TemplateData _processTemplateFile(const Glib::ustring &); -- cgit v1.2.3 From 77f61343ff18f29f05331131c2fe2bd810a64498 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Sun, 25 Aug 2013 19:42:22 -0400 Subject: Use real world units for page sizes. (bzr r12475.1.1) --- src/ui/dialog/document-properties.cpp | 30 +++++++++++++-- src/ui/widget/page-sizer.cpp | 69 +++++++++++++++++++---------------- src/ui/widget/page-sizer.h | 8 +++- 3 files changed, 70 insertions(+), 37 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 77fb182e5..430f28474 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -1433,9 +1433,33 @@ void DocumentProperties::update() if (nv->doc_units) _rum_deflt.setUnit (nv->doc_units->abbr); - double const doc_w_px = sp_desktop_document(dt)->getWidth(); - double const doc_h_px = sp_desktop_document(dt)->getHeight(); - _page_sizer.setDim (doc_w_px, doc_h_px); + double const doc_w = sp_desktop_document(dt)->getRoot()->width.value; + Glib::ustring doc_w_unit = unit_table.getUnit(sp_desktop_document(dt)->getRoot()->width.unit).abbr; + if (doc_w_unit == "") { + if (nv->units) { + doc_w_unit = nv->units->abbr; + } else { + if (nv->doc_units) { + doc_w_unit = nv->doc_units->abbr; + } else { + doc_w_unit = "px"; + } + } + } + double const doc_h = sp_desktop_document(dt)->getRoot()->height.value; + Glib::ustring doc_h_unit = unit_table.getUnit(sp_desktop_document(dt)->getRoot()->height.unit).abbr; + if (doc_h_unit == "") { + if (nv->units) { + doc_h_unit = nv->units->abbr; + } else { + if (nv->doc_units) { + doc_h_unit = nv->doc_units->abbr; + } else { + doc_h_unit = "px"; + } + } + } + _page_sizer.setDim(Inkscape::Util::Quantity(doc_w, doc_w_unit), Inkscape::Util::Quantity(doc_h, doc_h_unit)); _page_sizer.updateFitMarginsUI(nv->getRepr()); //-----------------------------------------------------------guide page diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index 8287452d7..5a289096c 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -442,6 +442,7 @@ PageSizer::init () _portrait_connection = _portraitButton.signal_toggled().connect (sigc::mem_fun (*this, &PageSizer::on_portrait)); _changedw_connection = _dimensionWidth.signal_value_changed().connect (sigc::mem_fun (*this, &PageSizer::on_value_changed)); _changedh_connection = _dimensionHeight.signal_value_changed().connect (sigc::mem_fun (*this, &PageSizer::on_value_changed)); + _changedu_connection = _dimensionUnits.getUnitMenu()->signal_changed().connect (sigc::mem_fun (*this, &PageSizer::on_units_changed)); _fitPageButton.signal_clicked().connect(sigc::mem_fun(*this, &PageSizer::fire_fit_canvas_to_selection_or_drawing)); show_all_children(); @@ -454,11 +455,11 @@ PageSizer::init () * 'changeList' is true, then adjust the paperSizeList to show the closest * standard page size. * - * \param w, h given in px + * \param w, h * \param changeList whether to modify the paper size list */ void -PageSizer::setDim (double w, double h, bool changeList) +PageSizer::setDim (Inkscape::Util::Quantity w, Inkscape::Util::Quantity h, bool changeList) { static bool _called = false; if (_called) { @@ -476,19 +477,19 @@ PageSizer::setDim (double w, double h, bool changeList) if (SP_ACTIVE_DESKTOP && !_widgetRegistry->isUpdating()) { SPDocument *doc = sp_desktop_document(SP_ACTIVE_DESKTOP); double const old_height = doc->getHeight(); - doc->setWidth (Inkscape::Util::Quantity(w, "px")); - doc->setHeight (Inkscape::Util::Quantity(h, "px")); + doc->setWidth (w); + doc->setHeight (h); // The origin for the user is in the lower left corner; this point should remain stationary when // changing the page size. The SVG's origin however is in the upper left corner, so we must compensate for this - Geom::Translate const vert_offset(Geom::Point(0, (old_height - h))); + Geom::Translate const vert_offset(Geom::Point(0, (old_height - h.quantity))); doc->getRoot()->translateChildItems(vert_offset); DocumentUndo::done(doc, SP_VERB_NONE, _("Set page size")); } - if ( w != h ) { + if ( w.quantity != h.quantity ) { _landscapeButton.set_sensitive(true); _portraitButton.set_sensitive (true); - _landscape = ( w > h ); + _landscape = ( w.quantity > h.quantity ); _landscapeButton.set_active(_landscape ? true : false); _portraitButton.set_active (_landscape ? false : true); } else { @@ -503,9 +504,10 @@ PageSizer::setDim (double w, double h, bool changeList) _paperSizeListSelection->select(row); } - Unit const& unit = _dimensionUnits.getUnit(); - _dimensionWidth.setValue (w / unit.factor); - _dimensionHeight.setValue (h / unit.factor); + _dimensionWidth.setUnit(w.unit->abbr); + _dimensionWidth.setValue (w.quantity); + _dimensionHeight.setUnit(h.unit->abbr); + _dimensionHeight.setValue (h.quantity); _paper_size_list_connection.unblock(); _landscape_connection.unblock(); @@ -547,12 +549,12 @@ PageSizer::updateFitMarginsUI(Inkscape::XML::Node *nv_repr) * paperSizeListStore->children().end() if no such paper exists. */ Gtk::ListStore::iterator -PageSizer::find_paper_size (double w, double h) const +PageSizer::find_paper_size (Inkscape::Util::Quantity w, Inkscape::Util::Quantity h) const { - double smaller = w; - double larger = h; - if ( h < w ) { - smaller = h; larger = w; + double smaller = w.quantity; + double larger = h.quantity; + if ( h.quantity < w.quantity ) { + smaller = h.quantity; larger = w.quantity; } g_return_val_if_fail(smaller <= larger, _paperSizeListStore->children().end()); @@ -562,8 +564,8 @@ PageSizer::find_paper_size (double w, double h) const iter != _paperSizeTable.end() ; ++iter) { PaperSize paper = iter->second; Inkscape::Util::Unit const &i_unit = paper.unit; - double smallX = Inkscape::Util::Quantity::convert(paper.smaller, i_unit, "px"); - double largeX = Inkscape::Util::Quantity::convert(paper.larger, i_unit, "px"); + double smallX = Inkscape::Util::Quantity::convert(paper.smaller, i_unit, *w.unit); + double largeX = Inkscape::Util::Quantity::convert(paper.larger, i_unit, *w.unit); g_return_val_if_fail(smallX <= largeX, _paperSizeListStore->children().end()); @@ -643,8 +645,8 @@ PageSizer::on_paper_size_list_changed() return; } PaperSize paper = piter->second; - double w = paper.smaller; - double h = paper.larger; + Inkscape::Util::Quantity w = Inkscape::Util::Quantity(paper.smaller, paper.unit); + Inkscape::Util::Quantity h = Inkscape::Util::Quantity(paper.larger, paper.unit); if (std::find(lscape_papers.begin(), lscape_papers.end(), paper.name.c_str()) != lscape_papers.end()) { // enforce landscape mode if this is desired for the given page format @@ -654,9 +656,6 @@ PageSizer::on_paper_size_list_changed() _landscape = _landscapeButton.get_active(); } - w = Inkscape::Util::Quantity::convert(w, paper.unit, "px"); - h = Inkscape::Util::Quantity::convert(h, paper.unit, "px"); - if (_landscape) setDim (h, w, false); else @@ -673,9 +672,9 @@ PageSizer::on_portrait() { if (!_portraitButton.get_active()) return; - double w = _dimensionWidth.getValue ("px"); - double h = _dimensionHeight.getValue ("px"); - if (h < w) { + Inkscape::Util::Quantity w = Inkscape::Util::Quantity(_dimensionWidth.getValue(""), _dimensionWidth.getUnit()); + Inkscape::Util::Quantity h = Inkscape::Util::Quantity(_dimensionHeight.getValue(""), _dimensionHeight.getUnit()); + if (h.quantity < w.quantity) { setDim (h, w); } } @@ -689,9 +688,9 @@ PageSizer::on_landscape() { if (!_landscapeButton.get_active()) return; - double w = _dimensionWidth.getValue ("px"); - double h = _dimensionHeight.getValue ("px"); - if (w < h) { + Inkscape::Util::Quantity w = Inkscape::Util::Quantity(_dimensionWidth.getValue(""), _dimensionWidth.getUnit()); + Inkscape::Util::Quantity h = Inkscape::Util::Quantity(_dimensionHeight.getValue(""), _dimensionHeight.getUnit()); + if (w.quantity < h.quantity) { setDim (h, w); } } @@ -703,11 +702,17 @@ void PageSizer::on_value_changed() { if (_widgetRegistry->isUpdating()) return; - - setDim (_dimensionWidth.getValue("px"), - _dimensionHeight.getValue("px")); + if (_unit != _dimensionUnits.getUnit().abbr) return; + setDim (Inkscape::Util::Quantity(_dimensionWidth.getValue(""), _dimensionUnits.getUnit()), + Inkscape::Util::Quantity(_dimensionHeight.getValue(""), _dimensionUnits.getUnit())); +} +void +PageSizer::on_units_changed() +{ + _unit = _dimensionUnits.getUnit().abbr; + setDim (Inkscape::Util::Quantity(_dimensionWidth.getValue(""), _dimensionUnits.getUnit()), + Inkscape::Util::Quantity(_dimensionHeight.getValue(""), _dimensionUnits.getUnit())); } - } // namespace Widget } // namespace UI diff --git a/src/ui/widget/page-sizer.h b/src/ui/widget/page-sizer.h index 34ed7592d..95836a005 100644 --- a/src/ui/widget/page-sizer.h +++ b/src/ui/widget/page-sizer.h @@ -161,7 +161,7 @@ public: * Set the page size to the given dimensions. If 'changeList' is * true, then reset the paper size list to the closest match */ - void setDim (double w, double h, bool changeList=true); + void setDim (Inkscape::Util::Quantity w, Inkscape::Util::Quantity h, bool changeList=true); /** * Updates the scalar widgets for the fit margins. (Just changes the value @@ -179,7 +179,7 @@ protected: /** * Find the closest standard paper size in the table, to the */ - Gtk::ListStore::iterator find_paper_size (double w, double h) const; + Gtk::ListStore::iterator find_paper_size (Inkscape::Util::Quantity w, Inkscape::Util::Quantity h) const; void fire_fit_canvas_to_selection_or_drawing(); @@ -252,13 +252,17 @@ protected: //callback void on_value_changed(); + void on_units_changed(); sigc::connection _changedw_connection; sigc::connection _changedh_connection; + sigc::connection _changedu_connection; Registry *_widgetRegistry; //### state - whether we are currently landscape or portrait bool _landscape; + + Glib::ustring _unit; }; -- cgit v1.2.3 From f10048be170a45921ae8fc65ccd2588a9ad2897d Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Tue, 27 Aug 2013 12:32:55 -0400 Subject: Added viewBox implement document unit support. (bzr r12475.1.2) --- src/ui/dialog/aboutbox.cpp | 5 ++-- src/ui/dialog/document-properties.cpp | 43 ++++++++++++++++++++--------------- src/ui/dialog/document-properties.h | 4 ++++ src/ui/dialog/export.cpp | 6 ++--- src/ui/dialog/print.cpp | 8 +++---- src/ui/widget/page-sizer.cpp | 5 ++-- 6 files changed, 42 insertions(+), 29 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/aboutbox.cpp b/src/ui/dialog/aboutbox.cpp index 6f1137e46..121773b6d 100644 --- a/src/ui/dialog/aboutbox.cpp +++ b/src/ui/dialog/aboutbox.cpp @@ -34,6 +34,7 @@ #include "svg-view-widget.h" #include "sp-text.h" #include "text-editing.h" +#include "util/units.h" #include "inkscape-version.h" @@ -175,8 +176,8 @@ Gtk::Widget *build_splash_widget() { GtkWidget *v=sp_svg_view_widget_new(doc); - double width=doc->getWidth(); - double height=doc->getHeight(); + double width=doc->getWidth().value("px"); + double height=doc->getHeight().value("px"); doc->doUnref(); diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 430f28474..272b85d2a 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -54,6 +54,8 @@ #include #include +#include <2geom/transforms.h> + using std::pair; namespace Inkscape { @@ -169,6 +171,9 @@ DocumentProperties::DocumentProperties() signalDocumentReplaced().connect(sigc::mem_fun(*this, &DocumentProperties::_handleDocumentReplaced)); signalActivateDesktop().connect(sigc::mem_fun(*this, &DocumentProperties::_handleActivateDesktop)); signalDeactiveDesktop().connect(sigc::mem_fun(*this, &DocumentProperties::_handleDeactivateDesktop)); + + _rum_deflt.getUnitMenu()->signal_changed().connect(sigc::mem_fun(*this, &DocumentProperties::onDocUnitChange)); + _old_doc_unit = _rum_deflt.getUnit(); } void DocumentProperties::init() @@ -1436,28 +1441,12 @@ void DocumentProperties::update() double const doc_w = sp_desktop_document(dt)->getRoot()->width.value; Glib::ustring doc_w_unit = unit_table.getUnit(sp_desktop_document(dt)->getRoot()->width.unit).abbr; if (doc_w_unit == "") { - if (nv->units) { - doc_w_unit = nv->units->abbr; - } else { - if (nv->doc_units) { - doc_w_unit = nv->doc_units->abbr; - } else { - doc_w_unit = "px"; - } - } + doc_w_unit = "px"; } double const doc_h = sp_desktop_document(dt)->getRoot()->height.value; Glib::ustring doc_h_unit = unit_table.getUnit(sp_desktop_document(dt)->getRoot()->height.unit).abbr; if (doc_h_unit == "") { - if (nv->units) { - doc_h_unit = nv->units->abbr; - } else { - if (nv->doc_units) { - doc_h_unit = nv->doc_units->abbr; - } else { - doc_h_unit = "px"; - } - } + doc_h_unit = "px"; } _page_sizer.setDim(Inkscape::Util::Quantity(doc_w, doc_w_unit), Inkscape::Util::Quantity(doc_h, doc_h_unit)); _page_sizer.updateFitMarginsUI(nv->getRepr()); @@ -1642,6 +1631,24 @@ void DocumentProperties::onRemoveGrid() } } +/** Callback for document unit change. */ +void DocumentProperties::onDocUnitChange() +{ + SPDocument *doc = SP_ACTIVE_DOCUMENT; + Inkscape::Util::Unit doc_unit = _rum_deflt.getUnit(); + + // Set viewBox + Inkscape::Util::Quantity width = doc->getWidth(); + Inkscape::Util::Quantity height = doc->getHeight(); + doc->setViewBox(Geom::Rect::from_xywh(0, 0, width.value(doc_unit), height.value(doc_unit))); + + // Scale and translate objects + gdouble scale = Inkscape::Util::Quantity::convert(1, _old_doc_unit, doc_unit); + doc->getRoot()->scaleChildItemsRec(Geom::Scale(scale), Geom::Point(0, doc->getHeight().value("px"))); + + _old_doc_unit = doc_unit; + DocumentUndo::done(doc, SP_VERB_NONE, _("Changed document unit")); +} } // namespace Dialog } // namespace UI diff --git a/src/ui/dialog/document-properties.h b/src/ui/dialog/document-properties.h index 56fed30c4..56abf9741 100644 --- a/src/ui/dialog/document-properties.h +++ b/src/ui/dialog/document-properties.h @@ -216,6 +216,10 @@ private: // callback methods for buttons on grids page. void onNewGrid(); void onRemoveGrid(); + + // callback for document unit change + Inkscape::Util::Unit _old_doc_unit; + void onDocUnitChange(); }; } // namespace Dialog diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 2c92608d7..c98e23000 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -762,7 +762,7 @@ void Export::onAreaToggled () } case SELECTION_PAGE: bbox = Geom::Rect(Geom::Point(0.0, 0.0), - Geom::Point(doc->getWidth(), doc->getHeight())); + Geom::Point(doc->getWidth().value("px"), doc->getHeight().value("px"))); // std::cout << "Using selection: PAGE" << std::endl; key = SELECTION_PAGE; @@ -1475,8 +1475,8 @@ void Export::detectSize() { doc = sp_desktop_document (SP_ACTIVE_DESKTOP); Geom::Point x(0.0, 0.0); - Geom::Point y(doc->getWidth(), - doc->getHeight()); + Geom::Point y(doc->getWidth().value("px"), + doc->getHeight().value("px")); Geom::Rect bbox(x, y); if (bbox_equal(bbox,current_bbox)) { diff --git a/src/ui/dialog/print.cpp b/src/ui/dialog/print.cpp index 4c8c77f96..3ce75327f 100644 --- a/src/ui/dialog/print.cpp +++ b/src/ui/dialog/print.cpp @@ -49,8 +49,8 @@ static void draw_page( if (junk->_tab->as_bitmap()) { // Render as exported PNG - gdouble width = (junk->_doc)->getWidth(); - gdouble height = (junk->_doc)->getHeight(); + gdouble width = (junk->_doc)->getWidth().value("px"); + gdouble height = (junk->_doc)->getHeight().value("px"); gdouble dpi = junk->_tab->bitmap_dpi(); std::string tmp_png; std::string tmp_base = "inkscape-print-png-XXXXXX"; @@ -195,8 +195,8 @@ Print::Print(SPDocument *doc, SPItem *base) : // set up paper size to match the document size gtk_print_operation_set_unit (_printop, GTK_UNIT_POINTS); GtkPageSetup *page_setup = gtk_page_setup_new(); - gdouble doc_width = _doc->getWidth() * Inkscape::Util::Quantity::convert(1, "px", "pt"); - gdouble doc_height = _doc->getHeight() * Inkscape::Util::Quantity::convert(1, "px", "pt"); + gdouble doc_width = _doc->getWidth().value("pt"); + gdouble doc_height = _doc->getHeight().value("pt"); GtkPaperSize *paper_size; if (doc_width > doc_height) { gtk_page_setup_set_orientation (page_setup, GTK_PAGE_ORIENTATION_LANDSCAPE); diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index 5a289096c..94c7b453a 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -476,12 +476,12 @@ PageSizer::setDim (Inkscape::Util::Quantity w, Inkscape::Util::Quantity h, bool if (SP_ACTIVE_DESKTOP && !_widgetRegistry->isUpdating()) { SPDocument *doc = sp_desktop_document(SP_ACTIVE_DESKTOP); - double const old_height = doc->getHeight(); + Inkscape::Util::Quantity const old_height = doc->getHeight(); doc->setWidth (w); doc->setHeight (h); // The origin for the user is in the lower left corner; this point should remain stationary when // changing the page size. The SVG's origin however is in the upper left corner, so we must compensate for this - Geom::Translate const vert_offset(Geom::Point(0, (old_height - h.quantity))); + Geom::Translate const vert_offset(Geom::Point(0, (old_height.value("px") - h.value("px")))); doc->getRoot()->translateChildItems(vert_offset); DocumentUndo::done(doc, SP_VERB_NONE, _("Set page size")); } @@ -709,6 +709,7 @@ PageSizer::on_value_changed() void PageSizer::on_units_changed() { + if (_widgetRegistry->isUpdating()) return; _unit = _dimensionUnits.getUnit().abbr; setDim (Inkscape::Util::Quantity(_dimensionWidth.getValue(""), _dimensionUnits.getUnit()), Inkscape::Util::Quantity(_dimensionHeight.getValue(""), _dimensionUnits.getUnit())); -- cgit v1.2.3 From df50dc11aa33a9ceeaa0cac84dd3a869680e998f Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Tue, 27 Aug 2013 22:53:42 -0400 Subject: Use Quantity comparisons in PageSizer. (bzr r12475.1.8) --- src/ui/widget/page-sizer.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/ui') diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index 94c7b453a..051937c43 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -486,10 +486,10 @@ PageSizer::setDim (Inkscape::Util::Quantity w, Inkscape::Util::Quantity h, bool DocumentUndo::done(doc, SP_VERB_NONE, _("Set page size")); } - if ( w.quantity != h.quantity ) { + if ( w != h ) { _landscapeButton.set_sensitive(true); _portraitButton.set_sensitive (true); - _landscape = ( w.quantity > h.quantity ); + _landscape = ( w > h ); _landscapeButton.set_active(_landscape ? true : false); _portraitButton.set_active (_landscape ? false : true); } else { @@ -553,7 +553,7 @@ PageSizer::find_paper_size (Inkscape::Util::Quantity w, Inkscape::Util::Quantity { double smaller = w.quantity; double larger = h.quantity; - if ( h.quantity < w.quantity ) { + if ( h < w ) { smaller = h.quantity; larger = w.quantity; } @@ -674,7 +674,7 @@ PageSizer::on_portrait() return; Inkscape::Util::Quantity w = Inkscape::Util::Quantity(_dimensionWidth.getValue(""), _dimensionWidth.getUnit()); Inkscape::Util::Quantity h = Inkscape::Util::Quantity(_dimensionHeight.getValue(""), _dimensionHeight.getUnit()); - if (h.quantity < w.quantity) { + if (h < w) { setDim (h, w); } } @@ -690,7 +690,7 @@ PageSizer::on_landscape() return; Inkscape::Util::Quantity w = Inkscape::Util::Quantity(_dimensionWidth.getValue(""), _dimensionWidth.getUnit()); Inkscape::Util::Quantity h = Inkscape::Util::Quantity(_dimensionHeight.getValue(""), _dimensionHeight.getUnit()); - if (w.quantity < h.quantity) { + if (w < h) { setDim (h, w); } } -- cgit v1.2.3 From 3bfb610bb7719d49821fe5381ae449789c3cb968 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Tue, 27 Aug 2013 23:32:14 -0400 Subject: Improve code readability. (bzr r12475.1.9) --- src/ui/clipboard.cpp | 4 ++-- src/ui/dialog/print.cpp | 4 ++-- src/ui/dialog/text-edit.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/ui') diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 629960613..084b2ebd8 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -1084,8 +1084,8 @@ void ClipboardManagerImpl::_onGet(Gtk::SelectionData &sel, guint /*info*/) Geom::Point origin (_clipboardSPDoc->getRoot()->x.computed, _clipboardSPDoc->getRoot()->y.computed); Geom::Rect area = Geom::Rect(origin, origin + _clipboardSPDoc->getDimensions()); - unsigned long int width = (unsigned long int) (area.width() * dpi / Inkscape::Util::Quantity::convert(1, "in", "px") + 0.5); - unsigned long int height = (unsigned long int) (area.height() * dpi / Inkscape::Util::Quantity::convert(1, "in", "px") + 0.5); + unsigned long int width = (unsigned long int) (Inkscape::Util::Quantity::convert(area.width(), "px", "in") * dpi + 0.5); + unsigned long int height = (unsigned long int) (Inkscape::Util::Quantity::convert(area.height(), "in", "px") * dpi + 0.5); // read from namedview Inkscape::XML::Node *nv = sp_repr_lookup_name (_clipboardSPDoc->rroot, "sodipodi:namedview"); diff --git a/src/ui/dialog/print.cpp b/src/ui/dialog/print.cpp index 3ce75327f..e6dae278b 100644 --- a/src/ui/dialog/print.cpp +++ b/src/ui/dialog/print.cpp @@ -72,8 +72,8 @@ static void draw_page( sp_export_png_file(junk->_doc, tmp_png.c_str(), 0.0, 0.0, width, height, - (unsigned long)(width * dpi / Inkscape::Util::Quantity::convert(1, "in", "px")), - (unsigned long)(height * dpi / Inkscape::Util::Quantity::convert(1, "in", "px")), + (unsigned long)(Inkscape::Util::Quantity::convert(width, "px", "in") * dpi), + (unsigned long)(Inkscape::Util::Quantity::convert(height, "px", "in") * dpi), dpi, dpi, bgcolor, NULL, NULL, true, NULL); // This doesn't seem to work: diff --git a/src/ui/dialog/text-edit.cpp b/src/ui/dialog/text-edit.cpp index 4a25f723b..9124681a0 100644 --- a/src/ui/dialog/text-edit.cpp +++ b/src/ui/dialog/text-edit.cpp @@ -401,7 +401,7 @@ void TextEdit::setPreviewText (Glib::ustring font_spec, Glib::ustring phrase) Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int unit = prefs->getInt("/options/font/unitType", SP_CSS_UNIT_PT); - double pt_size = sp_style_css_size_units_to_px(sp_font_selector_get_size(fsel), unit) * Inkscape::Util::Quantity::convert(1, "px", "pt"); + double pt_size = Inkscape::Util::Quantity::convert(sp_style_css_size_units_to_px(sp_font_selector_get_size(fsel), unit), "px", "pt"); // Pango font size is in 1024ths of a point // C++11: Glib::ustring size = std::to_string( pt_size * PANGO_SCALE ); -- cgit v1.2.3 From ba0f4a7717d67ce1a901d07506bdabc7dc72cae1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 1 Sep 2013 06:11:46 +1000 Subject: update cmakefiles (bzr r12493) --- src/ui/CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/ui') diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index b592d2527..c95dd35cc 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -54,6 +54,7 @@ set(ui_SRC dialog/livepatheffect-editor.cpp dialog/memory.cpp dialog/messages.cpp + dialog/new-from-template.cpp dialog/object-attributes.cpp dialog/object-properties.cpp dialog/ocaldialogs.cpp @@ -65,6 +66,8 @@ set(ui_SRC dialog/spellcheck.cpp dialog/svg-fonts-dialog.cpp dialog/swatches.cpp + dialog/template-load-tab.cpp + dialog/template-widget.cpp dialog/text-edit.cpp dialog/tile.cpp dialog/tracedialog.cpp @@ -166,16 +169,20 @@ set(ui_SRC dialog/livepatheffect-editor.h dialog/memory.h dialog/messages.h + dialog/new-from-template.h dialog/object-attributes.h dialog/object-properties.h dialog/ocaldialogs.h dialog/panel-dialog.h dialog/print-colors-preview-dialog.h dialog/print.h + dialog/spellcheck.h dialog/svg-fonts-dialog.h dialog/swatches.h dialog/symbols.h + dialog/template-load-tab.h + dialog/template-widget.h dialog/text-edit.h dialog/tile.h dialog/tracedialog.h -- cgit v1.2.3 From c9e56074607678b3c11e381b2462acf66b147789 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Sun, 1 Sep 2013 12:46:33 -0400 Subject: Fix PNG export with non-px default unit [Bug #1215104]. (bzr r12495) --- src/ui/dialog/export.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 2c92608d7..0b20c08a2 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -201,11 +201,11 @@ Export::Export (void) : earlier than that */ unit_selector = new Inkscape::UI::Widget::UnitMenu(); unit_selector->setUnitType(Inkscape::Util::UNIT_TYPE_LINEAR); - unitChangedConn = unit_selector->signal_changed().connect(sigc::mem_fun(*this, &Export::onUnitChanged)); SPDesktop *desktop = SP_ACTIVE_DESKTOP; if (desktop) unit_selector->setUnit(sp_desktop_namedview(desktop)->doc_units->abbr); + unitChangedConn = unit_selector->signal_changed().connect(sigc::mem_fun(*this, &Export::onUnitChanged)); unitbox.pack_end(*unit_selector, false, false, 0); unitbox.pack_end(units_label, false, false, 3); -- cgit v1.2.3 From 57154184731bf7d482be5bc2a67a74d11e491e2d Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Mon, 2 Sep 2013 02:03:47 +0200 Subject: Allow EMF import from Wine apps on Linux (bzr r12500) --- src/ui/clipboard.cpp | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'src/ui') diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 629960613..22d42d525 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -94,12 +94,6 @@ #ifdef WIN32 #include -// Clipboard Formats: http://msdn.microsoft.com/en-us/library/ms649013(VS.85).aspx -// On Windows, most graphical applications can handle CF_DIB/CF_BITMAP and/or CF_ENHMETAFILE -// GTK automatically presents an "image/bmp" target as CF_DIB/CF_BITMAP -// Presenting "image/x-emf" as CF_ENHMETAFILE must be done by Inkscape ? -#define CLIPBOARD_WIN32_EMF_TARGET "CF_ENHMETAFILE" -#define CLIPBOARD_WIN32_EMF_MIME "image/x-emf" #endif namespace Inkscape { @@ -179,13 +173,18 @@ ClipboardManagerImpl::ClipboardManagerImpl() _text_style(NULL), _clipboard( Gtk::Clipboard::get() ) { + // Clipboard Formats: http://msdn.microsoft.com/en-us/library/ms649013(VS.85).aspx + // On Windows, most graphical applications can handle CF_DIB/CF_BITMAP and/or CF_ENHMETAFILE + // GTK automatically presents an "image/bmp" target as CF_DIB/CF_BITMAP + // Presenting "image/x-emf" as CF_ENHMETAFILE must be done by Inkscape ? + // push supported clipboard targets, in order of preference _preferred_targets.push_back("image/x-inkscape-svg"); _preferred_targets.push_back("image/svg+xml"); _preferred_targets.push_back("image/svg+xml-compressed"); -#ifdef WIN32 - _preferred_targets.push_back(CLIPBOARD_WIN32_EMF_MIME); -#endif + _preferred_targets.push_back("image/x-emf"); + _preferred_targets.push_back("CF_ENHMETAFILE"); + _preferred_targets.push_back("WCF_ENHMETAFILE"); // seen on Wine _preferred_targets.push_back("application/pdf"); _preferred_targets.push_back("image/x-adobe-illustrator"); } @@ -981,7 +980,7 @@ SPDocument *ClipboardManagerImpl::_retrieveClipboard(Glib::ustring required_targ Glib::ustring target = best_target; #ifdef WIN32 - if (best_target == CLIPBOARD_WIN32_EMF_TARGET) + if (best_target == "CF_ENHMETAFILE" || best_target == "WCF_ENHMETAFILE") { // Try to save clipboard data as en emf file (using win32 api) if (OpenClipboard(NULL)) { HGLOBAL hglb = GetClipboardData(CF_ENHMETAFILE); @@ -989,7 +988,7 @@ SPDocument *ClipboardManagerImpl::_retrieveClipboard(Glib::ustring required_targ HENHMETAFILE hemf = CopyEnhMetaFile((HENHMETAFILE) hglb, filename); if (hemf) { file_saved = true; - target = CLIPBOARD_WIN32_EMF_MIME; + target = "image/x-emf"; DeleteEnhMetaFile(hemf); } } @@ -1020,6 +1019,10 @@ SPDocument *ClipboardManagerImpl::_retrieveClipboard(Glib::ustring required_targ if (target == "image/x-inkscape-svg") { target = "image/svg+xml"; } + // Use the EMF extension to import metafiles + if (target == "CF_ENHMETAFILE" || target == "WCF_ENHMETAFILE") { + target = "image/x-emf"; + } Inkscape::Extension::DB::InputList inlist; Inkscape::Extension::db.get_input_list(inlist); @@ -1213,10 +1216,10 @@ Glib::ustring ClipboardManagerImpl::_getBestTarget() // clipboard target debugging snippet /* - g_debug("Begin clipboard targets"); + g_message("Begin clipboard targets"); for ( std::list::iterator x = targets.begin() ; x != targets.end(); ++x ) - g_debug("Clipboard target: %s", (*x).data()); - g_debug("End clipboard targets\n"); + g_message("Clipboard target: %s", (*x).data()); + g_message("End clipboard targets\n"); //*/ for (std::list::iterator i = _preferred_targets.begin() ; -- cgit v1.2.3 From 100be92caf253e8743126da4264e84a060c82182 Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Wed, 4 Sep 2013 11:50:07 +0200 Subject: Creating documents from procedural templates added. (bzr r12481.1.2) --- src/ui/dialog/template-load-tab.cpp | 2 ++ src/ui/dialog/template-load-tab.h | 2 ++ src/ui/dialog/template-widget.cpp | 59 +++++++++++++++++++++++-------------- src/ui/dialog/template-widget.h | 1 + 4 files changed, 42 insertions(+), 22 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index 280b3b073..11511d7fc 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -271,6 +271,8 @@ void TemplateLoadTab::_getProceduralTemplates() result.display_name = (*it)->get_name(); result.is_procedural = true; result.path = ""; + result.tpl_effect = *it; + _getDataFromNode(myRoot, result); _tdata[result.display_name] = result; } diff --git a/src/ui/dialog/template-load-tab.h b/src/ui/dialog/template-load-tab.h index c3817cf1b..cdf8a0ade 100644 --- a/src/ui/dialog/template-load-tab.h +++ b/src/ui/dialog/template-load-tab.h @@ -20,6 +20,7 @@ #include #include "xml/node.h" +#include "extension/effect.h" namespace Inkscape { @@ -42,6 +43,7 @@ public: Glib::ustring preview_name; Glib::ustring creation_date; std::set keywords; + Inkscape::Extension::Effect *tpl_effect; }; TemplateLoadTab(); diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index be7e2b515..21ea709f2 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -20,6 +20,10 @@ #include "template-load-tab.h" #include "file.h" +#include "extension/implementation/implementation.h" + +#include "inkscape.h" +#include "desktop.h" namespace Inkscape { namespace UI { @@ -30,6 +34,7 @@ TemplateWidget::TemplateWidget() , _short_description_label(_(" ")) , _template_author_label(_(" ")) , _template_name_label(_("no template selected")) + , _effect_prefs(NULL) { pack_start(_template_name_label, Gtk::PACK_SHRINK, 10); pack_start(_template_author_label, Gtk::PACK_SHRINK, 0); @@ -55,10 +60,13 @@ TemplateWidget::TemplateWidget() void TemplateWidget::create() { - if (_current_template.path == "") + if (_current_template.display_name == "") return; - if (_current_template.is_procedural) {} + if (_current_template.is_procedural){ + SPDesktop *desc = sp_file_new_default(); + _current_template.tpl_effect->effect(desc); + } else { sp_file_new(_current_template.path); } @@ -68,34 +76,41 @@ void TemplateWidget::create() void TemplateWidget::display(TemplateLoadTab::TemplateData data) { _current_template = data; - if (data.is_procedural){} - else{ - _template_name_label.set_text(_current_template.display_name); - _template_author_label.set_text(_current_template.author); - _short_description_label.set_text(_current_template.short_description); + + _template_name_label.set_text(_current_template.display_name); + // _template_author_label.set_text(_current_template.author); + _short_description_label.set_text(_current_template.short_description); - Glib::ustring imagePath = Glib::build_filename(Glib::path_get_dirname(_current_template.path), _current_template.preview_name); - if (data.preview_name != ""){ - _preview_image.set(imagePath); - _preview_image.show(); - _preview_render.hide(); - } - else{ - _preview_render.showImage(data.path); - _preview_render.show(); - _preview_image.hide(); - } + _preview_render.hide(); + _preview_image.hide(); + + Glib::ustring imagePath = Glib::build_filename(Glib::path_get_dirname(_current_template.path), _current_template.preview_name); + if (data.preview_name != ""){ + _preview_image.set(imagePath); + _preview_image.show(); + } + else if (!data.is_procedural){ + _preview_render.showImage(data.path); + _preview_render.show(); + } + + if (_effect_prefs != NULL){ + remove (*_effect_prefs); + _effect_prefs = NULL; + } + if (data.is_procedural){ + _effect_prefs = data.tpl_effect->get_imp()->prefs_effect(data.tpl_effect, SP_ACTIVE_DESKTOP, NULL, NULL); // SP_ACTIVE_DESKTOP? + pack_start(*_effect_prefs); } } void TemplateWidget::_displayTemplateDetails() { - if (_current_template.path == "") - return; + Glib::ustring message = _current_template.display_name + "\n\n"; - Glib::ustring message = _current_template.display_name + "\n\n" + - _("Path: ") + _current_template.path + "\n\n"; + if (_current_template.path != "") + message += _("Path: ") + _current_template.path + "\n\n"; if (_current_template.long_description != "") message += _("Description: ") + _current_template.long_description + "\n\n"; diff --git a/src/ui/dialog/template-widget.h b/src/ui/dialog/template-widget.h index f7e1267ce..a41a14a38 100644 --- a/src/ui/dialog/template-widget.h +++ b/src/ui/dialog/template-widget.h @@ -38,6 +38,7 @@ private: Gtk::Label _short_description_label; Gtk::Label _template_author_label; Gtk::Label _template_name_label; + Gtk::Widget *_effect_prefs; void _displayTemplateDetails(); }; -- cgit v1.2.3 From 2bc1f3fc0275dee7b934ab584457fe3e4754816c Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Sat, 7 Sep 2013 08:46:37 +0200 Subject: Fix for bug #1219175 (Typing in Layers Dialog searches hidden/unhidden state instead of layer name). Fixed bugs: - https://launchpad.net/bugs/1219175 (bzr r12503) --- src/ui/dialog/layers.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/dialog/layers.cpp b/src/ui/dialog/layers.cpp index c41046123..c01903f94 100644 --- a/src/ui/dialog/layers.cpp +++ b/src/ui/dialog/layers.cpp @@ -838,7 +838,8 @@ LayersPanel::LayersPanel() : _name_column->add_attribute(_text_renderer->property_text(), _model->_colLabel); _tree.set_expander_column( *_tree.get_column(nameColNum) ); - + _tree.set_search_column(nameColNum + 1); + _compositeSettings.setSubject(&_subject); _selectedConnection = _tree.get_selection()->signal_changed().connect( sigc::mem_fun(*this, &LayersPanel::_pushTreeSelectionToCurrent) ); -- cgit v1.2.3 From 69c1405758767e06059f0bfc38b938f7bf069692 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Sun, 8 Sep 2013 10:17:05 -0400 Subject: Add a check so objects removed from the document dont crash inkscape, happens on close bc event race condition or misorder of what to destroy Fixed bugs: - https://launchpad.net/bugs/1220143 (bzr r12504) --- src/ui/dialog/filter-effects-dialog.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index 4401d5658..4ce2eafd1 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -1310,7 +1310,8 @@ void FilterEffectsDialog::FilterModifier::on_name_edited(const Glib::ustring& pa void FilterEffectsDialog::FilterModifier::on_filter_reorder(const Gtk::TreeModel::Path& path) { for(Gtk::TreeModel::iterator i = _model->children().begin(); i != _model->children().end(); ++i) { SPObject* object = (*i)[_columns.filter]; - object->getRepr()->setPosition(0); + if(object && object->getRepr()) + object->getRepr()->setPosition(0); } } -- cgit v1.2.3 From 0661bbe927d7847e2d88c3f4ec51e59a549f8c78 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Wed, 11 Sep 2013 18:47:47 -0400 Subject: Fix document unit change undo bug. (bzr r12475.1.14) --- src/ui/dialog/document-properties.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/ui') diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 272b85d2a..a2712bf68 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -35,6 +35,7 @@ #include "sp-object-repr.h" #include "sp-root.h" #include "sp-script.h" +#include "svg/stringstream.h" #include "ui/widget/color-picker.h" #include "ui/widget/scalar-unit.h" #include "ui/dialog/filedialog.h" @@ -172,6 +173,7 @@ DocumentProperties::DocumentProperties() signalActivateDesktop().connect(sigc::mem_fun(*this, &DocumentProperties::_handleActivateDesktop)); signalDeactiveDesktop().connect(sigc::mem_fun(*this, &DocumentProperties::_handleDeactivateDesktop)); + _rum_deflt._changed_connection.block(); _rum_deflt.getUnitMenu()->signal_changed().connect(sigc::mem_fun(*this, &DocumentProperties::onDocUnitChange)); _old_doc_unit = _rum_deflt.getUnit(); } @@ -1637,6 +1639,17 @@ void DocumentProperties::onDocUnitChange() SPDocument *doc = SP_ACTIVE_DOCUMENT; Inkscape::Util::Unit doc_unit = _rum_deflt.getUnit(); + // Don't execute when change is being undone + if (!DocumentUndo::getUndoSensitive(doc)) { + return; + } + + // Set document unit + Inkscape::SVGOStringStream os; + os << doc_unit.abbr; + Inkscape::XML::Node *repr = sp_desktop_namedview(getDesktop())->getRepr(); + repr->setAttribute("inkscape:document-units", os.str().c_str()); + // Set viewBox Inkscape::Util::Quantity width = doc->getWidth(); Inkscape::Util::Quantity height = doc->getHeight(); @@ -1646,6 +1659,8 @@ void DocumentProperties::onDocUnitChange() gdouble scale = Inkscape::Util::Quantity::convert(1, _old_doc_unit, doc_unit); doc->getRoot()->scaleChildItemsRec(Geom::Scale(scale), Geom::Point(0, doc->getHeight().value("px"))); + doc->setModifiedSinceSave(); + _old_doc_unit = doc_unit; DocumentUndo::done(doc, SP_VERB_NONE, _("Changed document unit")); } -- cgit v1.2.3 From 93167c446a8a8e5574e94cda37dc91c17072513b Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Wed, 11 Sep 2013 19:35:54 -0400 Subject: Finish fixing document unit change undo bug. (bzr r12475.1.15) --- src/ui/dialog/document-properties.cpp | 10 ++++++---- src/ui/dialog/document-properties.h | 1 - 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index a2712bf68..1b2761b13 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -175,7 +175,6 @@ DocumentProperties::DocumentProperties() _rum_deflt._changed_connection.block(); _rum_deflt.getUnitMenu()->signal_changed().connect(sigc::mem_fun(*this, &DocumentProperties::onDocUnitChange)); - _old_doc_unit = _rum_deflt.getUnit(); } void DocumentProperties::init() @@ -1637,6 +1636,11 @@ void DocumentProperties::onRemoveGrid() void DocumentProperties::onDocUnitChange() { SPDocument *doc = SP_ACTIVE_DOCUMENT; + Inkscape::XML::Node *repr = sp_desktop_namedview(getDesktop())->getRepr(); + Inkscape::Util::Unit old_doc_unit = unit_table.getUnit("px"); + if(repr->attribute("inkscape:document-units")) { + old_doc_unit = unit_table.getUnit(repr->attribute("inkscape:document-units")); + } Inkscape::Util::Unit doc_unit = _rum_deflt.getUnit(); // Don't execute when change is being undone @@ -1647,7 +1651,6 @@ void DocumentProperties::onDocUnitChange() // Set document unit Inkscape::SVGOStringStream os; os << doc_unit.abbr; - Inkscape::XML::Node *repr = sp_desktop_namedview(getDesktop())->getRepr(); repr->setAttribute("inkscape:document-units", os.str().c_str()); // Set viewBox @@ -1656,12 +1659,11 @@ void DocumentProperties::onDocUnitChange() doc->setViewBox(Geom::Rect::from_xywh(0, 0, width.value(doc_unit), height.value(doc_unit))); // Scale and translate objects - gdouble scale = Inkscape::Util::Quantity::convert(1, _old_doc_unit, doc_unit); + gdouble scale = Inkscape::Util::Quantity::convert(1, old_doc_unit, doc_unit); doc->getRoot()->scaleChildItemsRec(Geom::Scale(scale), Geom::Point(0, doc->getHeight().value("px"))); doc->setModifiedSinceSave(); - _old_doc_unit = doc_unit; DocumentUndo::done(doc, SP_VERB_NONE, _("Changed document unit")); } diff --git a/src/ui/dialog/document-properties.h b/src/ui/dialog/document-properties.h index 56abf9741..e3ca91731 100644 --- a/src/ui/dialog/document-properties.h +++ b/src/ui/dialog/document-properties.h @@ -218,7 +218,6 @@ private: void onRemoveGrid(); // callback for document unit change - Inkscape::Util::Unit _old_doc_unit; void onDocUnitChange(); }; -- 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 294f3f988ad4864d164e90ba68e84795108a3803 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Thu, 12 Sep 2013 19:30:14 +0200 Subject: fix Windows build (bzr r12507) --- src/ui/clipboard.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/ui') diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 22d42d525..aeb977078 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -1242,7 +1242,7 @@ Glib::ustring ClipboardManagerImpl::_getBestTarget() CloseClipboard(); if (format == CF_ENHMETAFILE) { - return CLIPBOARD_WIN32_EMF_TARGET; + return "CF_ENHMETAFILE"; } if (format == CF_DIB || format == CF_BITMAP) { return CLIPBOARD_GDK_PIXBUF_TARGET; @@ -1250,7 +1250,7 @@ Glib::ustring ClipboardManagerImpl::_getBestTarget() } if (IsClipboardFormatAvailable(CF_ENHMETAFILE)) { - return CLIPBOARD_WIN32_EMF_TARGET; + return "CF_ENHMETAFILE"; } #endif if (_clipboard->wait_is_image_available()) { @@ -1314,7 +1314,7 @@ void ClipboardManagerImpl::_setClipboardTargets() if (OpenClipboard(NULL)) { if ( _clipboardSPDoc != NULL ) { - const Glib::ustring target = CLIPBOARD_WIN32_EMF_MIME; + const Glib::ustring target = "image/x-emf"; Inkscape::Extension::DB::OutputList outlist; Inkscape::Extension::db.get_output_list(outlist); -- 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 0697088a2e3fbb3f7777db721e8c5e4661311dbe Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Fri, 13 Sep 2013 23:14:45 +0200 Subject: Improve the functions which create GdkPixbuf from Cairo surface and vice versa. Simplifies some code. Also introduce proper refcounting into svg_preview_cache.cpp and fix its users. (bzr r12512) --- src/ui/cache/svg_preview_cache.cpp | 19 +++--- src/ui/dialog/color-item.cpp | 12 +--- src/ui/dialog/symbols.cpp | 118 +++++++++++++++++++------------------ src/ui/widget/color-preview.cpp | 11 +--- 4 files changed, 77 insertions(+), 83 deletions(-) (limited to 'src/ui') diff --git a/src/ui/cache/svg_preview_cache.cpp b/src/ui/cache/svg_preview_cache.cpp index 74e94b827..a09489f6d 100644 --- a/src/ui/cache/svg_preview_cache.cpp +++ b/src/ui/cache/svg_preview_cache.cpp @@ -33,7 +33,7 @@ #include "ui/cache/svg_preview_cache.h" -GdkPixbuf* render_pixbuf(Inkscape::Drawing &drawing, double scale_factor, const Geom::Rect& dbox, unsigned psize) +GdkPixbuf* render_pixbuf(Inkscape::Drawing &drawing, double scale_factor, Geom::Rect const &dbox, unsigned psize) { Geom::Affine t(Geom::Scale(scale_factor, scale_factor)); drawing.root()->setTransform(Geom::Scale(scale_factor)); @@ -61,13 +61,7 @@ GdkPixbuf* render_pixbuf(Inkscape::Drawing &drawing, double scale_factor, const drawing.render(ct, area, Inkscape::DrawingItem::RENDER_BYPASS_CACHE); cairo_surface_flush(s); - GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data(cairo_image_surface_get_data(s), - GDK_COLORSPACE_RGB, - TRUE, - 8, psize, psize, cairo_image_surface_get_stride(s), - ink_cairo_pixbuf_cleanup, s); - convert_pixbuf_argb32_to_normal(pixbuf); - + GdkPixbuf* pixbuf = ink_pixbuf_create_from_cairo_surface(s); return pixbuf; } @@ -81,6 +75,12 @@ SvgPreview::SvgPreview() SvgPreview::~SvgPreview() { + for (std::map::iterator i = _pixmap_cache.begin(); + i != _pixmap_cache.end(); ++i) + { + g_object_unref(i->second); + i->second = NULL; + } } Glib::ustring SvgPreview::cache_key(gchar const *uri, gchar const *name, unsigned psize) const { @@ -102,6 +102,7 @@ GdkPixbuf* SvgPreview::get_preview_from_cache(const Glib::ustring& key) { } void SvgPreview::set_preview_in_cache(const Glib::ustring& key, GdkPixbuf* px) { + g_object_ref(px); _pixmap_cache[key] = px; } @@ -123,6 +124,8 @@ GdkPixbuf* SvgPreview::get_preview(const gchar* uri, const gchar* id, Inkscape:: void SvgPreview::remove_preview_from_cache(const Glib::ustring& key) { std::map::iterator found = _pixmap_cache.find(key); if ( found != _pixmap_cache.end() ) { + g_object_unref(found->second); + found->second = NULL; _pixmap_cache.erase(key); } } diff --git a/src/ui/dialog/color-item.cpp b/src/ui/dialog/color-item.cpp index 2292b66fc..7940c28ae 100644 --- a/src/ui/dialog/color-item.cpp +++ b/src/ui/dialog/color-item.cpp @@ -235,11 +235,7 @@ static void colorItemDragBegin( GtkWidget */*widget*/, GdkDragContext* dc, gpoin cairo_pattern_destroy(gradient); cairo_surface_flush(s); - pixbuf = gdk_pixbuf_new_from_data(cairo_image_surface_get_data(s), - GDK_COLORSPACE_RGB, TRUE, 8, - width, height, cairo_image_surface_get_stride(s), - ink_cairo_pixbuf_cleanup, s); - convert_pixbuf_argb32_to_normal(pixbuf); + pixbuf = ink_pixbuf_create_from_cairo_surface(s); } else { Glib::RefPtr thumb = Gdk::Pixbuf::create( Gdk::COLORSPACE_RGB, false, 8, width, height ); guint32 fillWith = (0xff000000 & (item->def.getR() << 24)) @@ -561,11 +557,7 @@ void ColorItem::_regenPreview(EekPreview * preview) cairo_destroy(ct); cairo_surface_flush(s); - GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data( cairo_image_surface_get_data(s), - GDK_COLORSPACE_RGB, TRUE, 8, - w, h, cairo_image_surface_get_stride(s), - ink_cairo_pixbuf_cleanup, s); - convert_pixbuf_argb32_to_normal(pixbuf); + GdkPixbuf* pixbuf = ink_pixbuf_create_from_cairo_surface(s); eek_preview_set_pixbuf( preview, pixbuf ); } diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index 26bc52947..6427eb9cc 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -420,12 +420,12 @@ void SymbolsDialog::iconChanged() { // First look for default style stored in gchar const* style = symbol->getAttribute("inkscape:symbol-style"); if( !style ) { - // If no default style in , look in documents. - if( symbolDocument == currentDocument ) { - style = style_from_use( symbol_id.c_str(), currentDocument ); - } else { - style = symbolDocument->getReprRoot()->attribute("style"); - } + // If no default style in , look in documents. + if( symbolDocument == currentDocument ) { + style = style_from_use( symbol_id.c_str(), currentDocument ); + } else { + style = symbolDocument->getReprRoot()->attribute("style"); + } } ClipboardManager *cm = ClipboardManager::get(); @@ -489,8 +489,8 @@ SPDocument* read_vss( gchar* fullname, gchar* filename ) { while( std::getline( iss, line ) ) { // std::cout << line << std::endl; if( line.find( "svg:svg" ) == std::string::npos ) { - tmpSVGOutput += line; - tmpSVGOutput += "\n"; + tmpSVGOutput += line; + tmpSVGOutput += "\n"; } } @@ -499,23 +499,23 @@ SPDocument* read_vss( gchar* fullname, gchar* filename ) { tmpSVGOutput += " \n"; tmpSVGOutput += "\n"; - + return SPDocument::createNewDocFromMem( tmpSVGOutput.c_str(), strlen( tmpSVGOutput.c_str()), 0 ); } #endif - + /* Hunts preference directories for symbol files */ void SymbolsDialog::get_symbols() { std::list directories; if( Inkscape::IO::file_test( INKSCAPE_SYMBOLSDIR, G_FILE_TEST_EXISTS ) && - Inkscape::IO::file_test( INKSCAPE_SYMBOLSDIR, G_FILE_TEST_IS_DIR ) ) { + Inkscape::IO::file_test( INKSCAPE_SYMBOLSDIR, G_FILE_TEST_IS_DIR ) ) { directories.push_back( INKSCAPE_SYMBOLSDIR ); } if( Inkscape::IO::file_test( profile_path("symbols"), G_FILE_TEST_EXISTS ) && - Inkscape::IO::file_test( profile_path("symbols"), G_FILE_TEST_IS_DIR ) ) { + Inkscape::IO::file_test( profile_path("symbols"), G_FILE_TEST_IS_DIR ) ) { directories.push_back( profile_path("symbols") ); } @@ -526,46 +526,46 @@ void SymbolsDialog::get_symbols() { GDir *dir = g_dir_open( (*it).c_str(), 0, &err ); if( dir ) { - gchar *filename = 0; - while( (filename = (gchar *)g_dir_read_name( dir ) ) != NULL) { + gchar *filename = 0; + while( (filename = (gchar *)g_dir_read_name( dir ) ) != NULL) { - gchar *fullname = g_build_filename((*it).c_str(), filename, NULL); + gchar *fullname = g_build_filename((*it).c_str(), filename, NULL); - if ( !Inkscape::IO::file_test( fullname, G_FILE_TEST_IS_DIR ) ) { + if ( !Inkscape::IO::file_test( fullname, G_FILE_TEST_IS_DIR ) ) { - Glib::ustring fn( filename ); - Glib::ustring tag = fn.substr( fn.find_last_of(".") + 1 ); + Glib::ustring fn( filename ); + Glib::ustring tag = fn.substr( fn.find_last_of(".") + 1 ); - SPDocument* symbol_doc = NULL; + SPDocument* symbol_doc = NULL; #ifdef WITH_LIBVISIO - if( tag.compare( "vss" ) == 0 ) { - - symbol_doc = read_vss( fullname, filename ); - if( symbol_doc ) { - symbolSets[Glib::ustring(filename)]= symbol_doc; - symbolSet->append(filename); - } - } + if( tag.compare( "vss" ) == 0 ) { + + symbol_doc = read_vss( fullname, filename ); + if( symbol_doc ) { + symbolSets[Glib::ustring(filename)]= symbol_doc; + symbolSet->append(filename); + } + } #endif - // Try to read all remaining files as SVG - if( !symbol_doc ) { + // Try to read all remaining files as SVG + if( !symbol_doc ) { - symbol_doc = SPDocument::createNewDoc( fullname, FALSE ); - if( symbol_doc ) { + symbol_doc = SPDocument::createNewDoc( fullname, FALSE ); + if( symbol_doc ) { gchar *title = symbol_doc->getRoot()->title(); if( title == NULL ) { title = _("Unnamed Symbols"); } - symbolSets[Glib::ustring(title)] = symbol_doc; - symbolSet->append(title); - } - } - - } - g_free( fullname ); - } - g_dir_close( dir ); + symbolSets[Glib::ustring(title)] = symbol_doc; + symbolSet->append(title); + } + } + + } + g_free( fullname ); + } + g_dir_close( dir ); } } } @@ -627,16 +627,16 @@ gchar const* SymbolsDialog::style_from_use( gchar const* id, SPDocument* documen for( ; l != NULL; l = l->next ) { SPObject* use = SP_OBJECT(l->data); if( SP_IS_USE( use ) ) { - gchar const *href = use->getRepr()->attribute("xlink:href"); - if( href ) { - Glib::ustring href2(href); - Glib::ustring id2(id); - id2 = "#" + id2; - if( !href2.compare(id2) ) { - style = use->getRepr()->attribute("style"); - break; - } - } + gchar const *href = use->getRepr()->attribute("xlink:href"); + if( href ) { + Glib::ustring href2(href); + Glib::ustring id2(id); + id2 = "#" + id2; + if( !href2.compare(id2) ) { + style = use->getRepr()->attribute("style"); + break; + } + } } } return style; @@ -749,9 +749,13 @@ SymbolsDialog::create_symbol_image(gchar const *symbol_id, SPObject *symbol) /* Update to renderable state */ Glib::ustring key = svg_preview_cache.cache_key(previewDocument->getURI(), symbol_id, psize); //std::cout << " Key: " << key << std::endl; - // FIX ME - //Glib::RefPtr pixbuf = Glib::wrap(svg_preview_cache.get_preview_from_cache(key)); - Glib::RefPtr pixbuf = Glib::RefPtr(0); + + Glib::RefPtr pixbuf(NULL); + GdkPixbuf *pixbuf_gobj = svg_preview_cache.get_preview_from_cache(key); + if (pixbuf_gobj) { + g_object_ref(pixbuf_gobj); // the reference in svg_preview_cache will get destroyed when it's freed + pixbuf = Glib::wrap(pixbuf_gobj); + } // Find object's bbox in document. // Note symbols can have own viewport... ignore for now. @@ -776,8 +780,8 @@ SymbolsDialog::create_symbol_image(gchar const *symbol_id, SPObject *symbol) } if( fitSymbol->get_active() ) { - /* Fit */ - scale = psize/std::max(width,height); + /* Fit */ + scale = psize/std::max(width,height); } pixbuf = Glib::wrap(render_pixbuf(renderDrawing, scale, *dbox, psize)); @@ -814,8 +818,8 @@ void SymbolsDialog::setTargetDesktop(SPDesktop *desktop) if (this->currentDesktop != desktop) { this->currentDesktop = desktop; if( !symbolSets[symbolSet->get_active_text()] ) { - // Symbol set is from Current document, update - rebuild(); + // Symbol set is from Current document, update + rebuild(); } } } diff --git a/src/ui/widget/color-preview.cpp b/src/ui/widget/color-preview.cpp index 4b4a7b738..5bcd16528 100644 --- a/src/ui/widget/color-preview.cpp +++ b/src/ui/widget/color-preview.cpp @@ -73,9 +73,9 @@ ColorPreview::on_expose_event (GdkEventExpose *event) if (get_is_drawable()) { Cairo::RefPtr cr = get_window()->create_cairo_context(); - cr->rectangle(event->area.x, event->area.y, + cr->rectangle(event->area.x, event->area.y, event->area.width, event->area.height); - cr->clip(); + cr->clip(); result = on_draw(cr); } @@ -176,12 +176,7 @@ ColorPreview::toPixbuf (int width, int height) cairo_destroy(ct); cairo_surface_flush(s); - GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data( cairo_image_surface_get_data(s), - GDK_COLORSPACE_RGB, TRUE, 8, - width, height, cairo_image_surface_get_stride(s), - ink_cairo_pixbuf_cleanup, s); - convert_pixbuf_argb32_to_normal(pixbuf); - + GdkPixbuf* pixbuf = ink_pixbuf_create_from_cairo_surface(s); return pixbuf; } -- cgit v1.2.3 From 09c1fee60bcd713fe66178021053d59e3f649660 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Sat, 14 Sep 2013 16:37:55 -0400 Subject: Fix bug with tool handles during document unit change. (bzr r12475.1.17) --- src/ui/dialog/document-properties.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/ui') diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 1b2761b13..0c39876ea 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -31,11 +31,13 @@ #include "inkscape.h" #include "io/sys.h" #include "preferences.h" +#include "shape-editor.h" #include "sp-namedview.h" #include "sp-object-repr.h" #include "sp-root.h" #include "sp-script.h" #include "svg/stringstream.h" +#include "tools-switch.h" #include "ui/widget/color-picker.h" #include "ui/widget/scalar-unit.h" #include "ui/dialog/filedialog.h" @@ -1658,9 +1660,16 @@ void DocumentProperties::onDocUnitChange() Inkscape::Util::Quantity height = doc->getHeight(); doc->setViewBox(Geom::Rect::from_xywh(0, 0, width.value(doc_unit), height.value(doc_unit))); + // TODO: Fix bug in nodes tool instead of switching away from it + if (tools_active(getDesktop()) == TOOLS_NODES) { + tools_switch(getDesktop(), TOOLS_SELECT); + } + // Scale and translate objects gdouble scale = Inkscape::Util::Quantity::convert(1, old_doc_unit, doc_unit); + ShapeEditor::blockSetItem(true); doc->getRoot()->scaleChildItemsRec(Geom::Scale(scale), Geom::Point(0, doc->getHeight().value("px"))); + ShapeEditor::blockSetItem(false); doc->setModifiedSinceSave(); -- 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 aecd69b561e8f514f50bda8f47ec8380a6285948 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Sun, 15 Sep 2013 13:31:53 +0200 Subject: UI message uniformisation (bzr r12521) --- src/ui/dialog/inkscape-preferences.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index b06c1fd1f..e9cf2e753 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -884,7 +884,7 @@ void InkscapePreferences::initPageIO() int pathstringFormatValues[numPathstringFormat] = {0, 1, 2}; _svgoutput_pathformat.init("/options/svgoutput/pathstring_format", pathstringFormatLabels, pathstringFormatValues, numPathstringFormat, 2); - _page_svgoutput.add_line( true, _("Path string format"), _svgoutput_pathformat, "", _("Path data should be written: only with absolute coordinates, only with relative coordinates, or optimized for string length (mixed absolute and relative coordinates)"), false); + _page_svgoutput.add_line( true, _("Path string format:"), _svgoutput_pathformat, "", _("Path data should be written: only with absolute coordinates, only with relative coordinates, or optimized for string length (mixed absolute and relative coordinates)"), false); _svgoutput_forcerepeatcommands.init( _("Force repeat commands"), "/options/svgoutput/forcerepeatcommands", false); _page_svgoutput.add_line( true, "", _svgoutput_forcerepeatcommands, "", _("Force repeating of the same path command (for example, 'L 1,2 L 3,4' instead of 'L 1,2 3,4')"), false); -- cgit v1.2.3 From 5dc7ab56d1f8bf9b51367702e13788f8eea00aaf Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Sun, 15 Sep 2013 21:58:27 +0200 Subject: Removed search templates case sensitivity (bzr r12481.1.4) --- src/ui/dialog/template-load-tab.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index 11511d7fc..ababd4ca3 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -156,7 +156,7 @@ void TemplateLoadTab::_refreshTemplatesList() case LIST_KEYWORD: { for (std::map::iterator it = _tdata.begin() ; it != _tdata.end() ; ++it) { - if (it->second.keywords.count(_current_keyword) != 0){ + if (it->second.keywords.count(_current_keyword.lowercase()) != 0){ Gtk::TreeModel::iterator iter = _tlist_store->append(); Gtk::TreeModel::Row row = *iter; row[_columns.textValue] = it->first; @@ -167,11 +167,11 @@ void TemplateLoadTab::_refreshTemplatesList() case USER_SPECIFIED : { for (std::map::iterator it = _tdata.begin() ; it != _tdata.end() ; ++it) { - if (it->second.keywords.count(_current_keyword) != 0 || - it->second.display_name.find(_current_keyword) != Glib::ustring::npos || - it->second.author.find(_current_keyword) != Glib::ustring::npos || - it->second.short_description.find(_current_keyword) != Glib::ustring::npos || - it->second.long_description.find(_current_keyword) != Glib::ustring::npos ) + if (it->second.keywords.count(_current_keyword.lowercase()) != 0 || + it->second.display_name.lowercase().find(_current_keyword.lowercase()) != Glib::ustring::npos || + it->second.author.lowercase().find(_current_keyword.lowercase()) != Glib::ustring::npos || + it->second.short_description.lowercase().find(_current_keyword.lowercase()) != Glib::ustring::npos || + it->second.long_description.lowercase().find(_current_keyword.lowercase()) != Glib::ustring::npos ) { Gtk::TreeModel::iterator iter = _tlist_store->append(); Gtk::TreeModel::Row row = *iter; @@ -192,7 +192,6 @@ void TemplateLoadTab::_loadTemplates() // system templates dir _getTemplatesFromDir(INKSCAPE_TEMPLATESDIR + _loading_path); - // procedural templates _getProceduralTemplates(); } @@ -305,8 +304,8 @@ void TemplateLoadTab::_getDataFromNode(Inkscape::XML::Node *dataNode, TemplateDa pos = tplKeywords.size(); Glib::ustring keyword = dgettext("Document template keyword", tplKeywords.substr(0, pos).data()); - data.keywords.insert(keyword); - _keywords.insert(keyword); + data.keywords.insert(keyword.lowercase()); + _keywords.insert(keyword.lowercase()); if (pos == tplKeywords.size()) break; -- cgit v1.2.3 From fbaf8db2eb5c15ac84348f9e9de3303c78860f62 Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Sun, 15 Sep 2013 22:36:28 +0200 Subject: Fixed available undo after new template creation. (bzr r12481.1.6) --- src/ui/dialog/template-widget.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/ui') diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index 21ea709f2..6ead7ef8d 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -24,6 +24,9 @@ #include "inkscape.h" #include "desktop.h" +#include "desktop-handles.h" +#include "document.h" +#include "document-undo.h" namespace Inkscape { namespace UI { @@ -66,6 +69,7 @@ void TemplateWidget::create() if (_current_template.is_procedural){ SPDesktop *desc = sp_file_new_default(); _current_template.tpl_effect->effect(desc); + DocumentUndo::clearUndo(sp_desktop_document(desc)); } else { sp_file_new(_current_template.path); -- cgit v1.2.3 From bd94128f84bc367d11815c53347eb8d5b5557c5e Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Sun, 15 Sep 2013 23:18:47 +0200 Subject: Fix procedural templates "modified" status. (bzr r12481.1.7) --- src/ui/dialog/template-widget.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/ui') diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index 6ead7ef8d..1e0900a07 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -70,6 +70,7 @@ void TemplateWidget::create() SPDesktop *desc = sp_file_new_default(); _current_template.tpl_effect->effect(desc); DocumentUndo::clearUndo(sp_desktop_document(desc)); + sp_desktop_document(desc)->setModifiedSinceSave(false); } else { sp_file_new(_current_template.path); -- cgit v1.2.3 From 5614df9770b985070122b3c08b45902317c9bd15 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Sun, 15 Sep 2013 19:07:21 -0400 Subject: Enable unit evaluation in toolbars. (bzr r12475.1.22) --- src/ui/widget/spinbutton.cpp | 10 ++++++++-- src/ui/widget/spinbutton.h | 5 +++++ 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'src/ui') diff --git a/src/ui/widget/spinbutton.cpp b/src/ui/widget/spinbutton.cpp index c107979a8..2c95e8b5a 100644 --- a/src/ui/widget/spinbutton.cpp +++ b/src/ui/widget/spinbutton.cpp @@ -14,6 +14,7 @@ #include "spinbutton.h" #include "unit-menu.h" +#include "unit-tracker.h" #include "util/expression-evaluator.h" #include "event-context.h" @@ -33,8 +34,13 @@ int SpinButton::on_input(double* newvalue) { try { Inkscape::Util::GimpEevlQuantity result; - if (_unit_menu) { - Unit unit = _unit_menu->getUnit(); + if (_unit_menu || _unit_tracker) { + Unit unit; + if (_unit_menu) { + unit = _unit_menu->getUnit(); + } else { + unit = _unit_tracker->getActiveUnit(); + } result = Inkscape::Util::gimp_eevl_evaluate (get_text().c_str(), &unit); // check if output dimension corresponds to input unit if (result.dimension != (unit.isAbsolute() ? 1 : 0) ) { diff --git a/src/ui/widget/spinbutton.h b/src/ui/widget/spinbutton.h index fe5d699e7..c772fe2a2 100644 --- a/src/ui/widget/spinbutton.h +++ b/src/ui/widget/spinbutton.h @@ -25,6 +25,7 @@ namespace UI { namespace Widget { class UnitMenu; +class UnitTracker; /** * SpinButton widget, that allows entry of simple math expressions (also units, when linked with UnitMenu), @@ -50,14 +51,18 @@ public: _unit_menu(NULL) { connect_signals(); + _unit_tracker = NULL; }; virtual ~SpinButton() {}; void setUnitMenu(UnitMenu* unit_menu) { _unit_menu = unit_menu; }; + + void addUnitTracker(UnitTracker* ut) { _unit_tracker = ut; }; protected: UnitMenu *_unit_menu; /// Linked unit menu for unit conversion in entered expressions. + UnitTracker *_unit_tracker; // Linked unit tracker for unit conversion in entered expressions. void connect_signals(); -- cgit v1.2.3 From f55a53ef2d861b634ad83622edc5e26430baeae0 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Sun, 15 Sep 2013 23:59:14 -0400 Subject: C++ify expression evaluator. (bzr r12475.1.23) --- src/ui/widget/spinbutton.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/ui') diff --git a/src/ui/widget/spinbutton.cpp b/src/ui/widget/spinbutton.cpp index 2c95e8b5a..62c17f821 100644 --- a/src/ui/widget/spinbutton.cpp +++ b/src/ui/widget/spinbutton.cpp @@ -33,7 +33,7 @@ SpinButton::connect_signals() { int SpinButton::on_input(double* newvalue) { try { - Inkscape::Util::GimpEevlQuantity result; + Inkscape::Util::EvaluatorQuantity result; if (_unit_menu || _unit_tracker) { Unit unit; if (_unit_menu) { @@ -41,13 +41,15 @@ int SpinButton::on_input(double* newvalue) } else { unit = _unit_tracker->getActiveUnit(); } - result = Inkscape::Util::gimp_eevl_evaluate (get_text().c_str(), &unit); + Inkscape::Util::ExpressionEvaluator eval = Inkscape::Util::ExpressionEvaluator(get_text().c_str(), &unit); + result = eval.evaluate(); // check if output dimension corresponds to input unit if (result.dimension != (unit.isAbsolute() ? 1 : 0) ) { throw Inkscape::Util::EvaluatorException("Input dimensions do not match with parameter dimensions.",""); } } else { - result = Inkscape::Util::gimp_eevl_evaluate (get_text().c_str(), NULL); + Inkscape::Util::ExpressionEvaluator eval = Inkscape::Util::ExpressionEvaluator(get_text().c_str(), NULL); + result = eval.evaluate(); } *newvalue = result.value; -- cgit v1.2.3 From c549b2977183241cecc95d40839d31d99eb76699 Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Wed, 18 Sep 2013 17:04:03 +0200 Subject: Fix "default_*" template names treatment. (bzr r12481.1.8) --- src/ui/dialog/template-load-tab.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index ababd4ca3..c884df2b1 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -244,7 +244,7 @@ void TemplateLoadTab::_getTemplatesFromDir(const Glib::ustring &path) Glib::ustring file = Glib::build_filename(path, dir.read_name()); while (file != path){ - if (Glib::str_has_suffix(file, ".svg") && !Glib::str_has_prefix(Glib::path_get_basename(file), "default")){ + if (Glib::str_has_suffix(file, ".svg") && !Glib::str_has_prefix(Glib::path_get_basename(file), "default.")){ TemplateData tmp = _processTemplateFile(file); if (tmp.display_name != "") _tdata[tmp.display_name] = tmp; -- 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 From 074dfbc9661c5d2b1d2b29b0eb3dabb632b676a4 Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Fri, 20 Sep 2013 16:20:17 +0200 Subject: Small style fixes. (bzr r12481.1.10) --- src/ui/dialog/template-widget.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index 1e0900a07..64be57a45 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -19,14 +19,14 @@ #include #include "template-load-tab.h" -#include "file.h" -#include "extension/implementation/implementation.h" - -#include "inkscape.h" #include "desktop.h" #include "desktop-handles.h" #include "document.h" #include "document-undo.h" +#include "file.h" +#include "extension/implementation/implementation.h" +#include "inkscape.h" + namespace Inkscape { namespace UI { -- cgit v1.2.3 From 18bc66ea42cb3e7ad8d2b77ba70bd06d1b88cc7c Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Fri, 20 Sep 2013 16:48:10 +0200 Subject: Change paths storage to std::string. (bzr r12481.1.12) --- src/ui/dialog/template-load-tab.cpp | 6 +++--- src/ui/dialog/template-load-tab.h | 9 +++++---- src/ui/dialog/template-widget.cpp | 5 +++-- 3 files changed, 11 insertions(+), 9 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index c884df2b1..127a7e4f5 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -197,7 +197,7 @@ void TemplateLoadTab::_loadTemplates() } -TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(const Glib::ustring &path) +TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(const std::string &path) { TemplateData result; result.path = path; @@ -234,7 +234,7 @@ TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(const Glib:: } -void TemplateLoadTab::_getTemplatesFromDir(const Glib::ustring &path) +void TemplateLoadTab::_getTemplatesFromDir(const std::string &path) { if ( !Glib::file_test(path, Glib::FILE_TEST_EXISTS) || !Glib::file_test(path, Glib::FILE_TEST_IS_DIR)) @@ -242,7 +242,7 @@ void TemplateLoadTab::_getTemplatesFromDir(const Glib::ustring &path) Glib::Dir dir(path); - Glib::ustring file = Glib::build_filename(path, dir.read_name()); + std::string file = Glib::build_filename(path, dir.read_name()); while (file != path){ if (Glib::str_has_suffix(file, ".svg") && !Glib::str_has_prefix(Glib::path_get_basename(file), "default.")){ TemplateData tmp = _processTemplateFile(file); diff --git a/src/ui/dialog/template-load-tab.h b/src/ui/dialog/template-load-tab.h index cdf8a0ade..744a2a9fb 100644 --- a/src/ui/dialog/template-load-tab.h +++ b/src/ui/dialog/template-load-tab.h @@ -18,6 +18,7 @@ #include #include #include +#include #include "xml/node.h" #include "extension/effect.h" @@ -35,7 +36,7 @@ public: struct TemplateData { bool is_procedural; - Glib::ustring path; + std::string path; Glib::ustring display_name; Glib::ustring author; Glib::ustring short_description; @@ -64,7 +65,7 @@ protected: Glib::ustring _current_keyword; Glib::ustring _current_template; - Glib::ustring _loading_path; + std::string _loading_path; std::map _tdata; std::set _keywords; @@ -97,9 +98,9 @@ private: void _getDataFromNode(Inkscape::XML::Node *, TemplateData &); void _getProceduralTemplates(); - void _getTemplatesFromDir(const Glib::ustring &); + void _getTemplatesFromDir(const std::string &); void _keywordSelected(); - TemplateData _processTemplateFile(const Glib::ustring &); + TemplateData _processTemplateFile(const std::string &); }; } diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index 64be57a45..916d968ec 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -89,13 +89,14 @@ void TemplateWidget::display(TemplateLoadTab::TemplateData data) _preview_render.hide(); _preview_image.hide(); - Glib::ustring imagePath = Glib::build_filename(Glib::path_get_dirname(_current_template.path), _current_template.preview_name); + std::string imagePath = Glib::build_filename(Glib::path_get_dirname(_current_template.path), _current_template.preview_name); if (data.preview_name != ""){ _preview_image.set(imagePath); _preview_image.show(); } else if (!data.is_procedural){ - _preview_render.showImage(data.path); + Glib::ustring gPath = data.path.c_str(); + _preview_render.showImage(gPath); _preview_render.show(); } -- cgit v1.2.3 From 0d4a38635fc26ed09d56b46e462b373489c8a4e2 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sat, 21 Sep 2013 11:42:33 +0100 Subject: Fix format security errors Fixed bugs: - https://launchpad.net/bugs/1193025 (bzr r12563) --- src/ui/dialog/print.cpp | 6 +++--- src/ui/dialog/spellcheck.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/print.cpp b/src/ui/dialog/print.cpp index e6dae278b..03ac9dc64 100644 --- a/src/ui/dialog/print.cpp +++ b/src/ui/dialog/print.cpp @@ -101,7 +101,7 @@ static void draw_page( unlink (tmp_png.c_str()); } else { - g_warning(_("Could not open temporary PNG for bitmap printing")); + g_warning("%s", _("Could not open temporary PNG for bitmap printing")); } } else { @@ -144,11 +144,11 @@ static void draw_page( ret = ctx->finish(); } else { - g_warning(_("Could not set up Document")); + g_warning("%s", _("Could not set up Document")); } } else { - g_warning(_("Failed to set CairoRenderContext")); + g_warning("%s", _("Failed to set CairoRenderContext")); } // Clean up diff --git a/src/ui/dialog/spellcheck.cpp b/src/ui/dialog/spellcheck.cpp index 9cc18c02c..45106755c 100644 --- a/src/ui/dialog/spellcheck.cpp +++ b/src/ui/dialog/spellcheck.cpp @@ -459,7 +459,7 @@ SpellCheck::finished () if (_stops) label = g_strdup_printf(_("Finished, %d words added to dictionary"), _adds); else - label = g_strdup_printf(_("Finished, nothing suspicious found")); + label = g_strdup_printf("%s", _("Finished, nothing suspicious found")); banner_label.set_markup(label); g_free(label); } -- cgit v1.2.3 From 9ba75e8a819b3fa9e266f6bd46ccee65322f89b0 Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Sat, 21 Sep 2013 22:30:40 +0200 Subject: Fix templates parameters names. (bzr r12481.1.13) --- src/ui/dialog/template-load-tab.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index 127a7e4f5..4517c4472 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -287,7 +287,7 @@ void TemplateLoadTab::_getDataFromNode(Inkscape::XML::Node *dataNode, TemplateDa data.display_name = dgettext("Document template name", currentData->firstChild()->content()); if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:author")) != NULL) data.author = currentData->firstChild()->content(); - if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:_short")) != NULL) + if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:_shortdesc")) != NULL) data.short_description = dgettext("Document template short description", currentData->firstChild()->content()); if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:_long") )!= NULL) data.long_description = dgettext("Document template long description", currentData->firstChild()->content()); -- cgit v1.2.3 From 8921f8000318d636ae8ce2a1198f92161f1dba9f Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Sat, 21 Sep 2013 23:32:09 +0200 Subject: Small style fixes. (bzr r12481.1.15) --- src/ui/dialog/template-load-tab.cpp | 8 ++++---- src/ui/dialog/template-widget.cpp | 6 +----- src/ui/dialog/template-widget.h | 2 +- 3 files changed, 6 insertions(+), 10 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index 4517c4472..8e33cf503 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -18,19 +18,19 @@ #include #include #include -#include #include +#include +#include "extension/db.h" +#include "extension/effect.h" +#include "inkscape.h" #include "interface.h" #include "file.h" #include "path-prefix.h" #include "preferences.h" -#include "inkscape.h" #include "xml/repr.h" #include "xml/document.h" #include "xml/node.h" -#include "extension/db.h" -#include "extension/effect.h" namespace Inkscape { diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index 916d968ec..ef022c421 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -35,19 +35,16 @@ namespace UI { TemplateWidget::TemplateWidget() : _more_info_button(_("More info")) , _short_description_label(_(" ")) - , _template_author_label(_(" ")) , _template_name_label(_("no template selected")) , _effect_prefs(NULL) { pack_start(_template_name_label, Gtk::PACK_SHRINK, 10); - pack_start(_template_author_label, Gtk::PACK_SHRINK, 0); pack_start(_preview_box, Gtk::PACK_SHRINK, 0); _preview_box.pack_start(_preview_image, Gtk::PACK_EXPAND_PADDING, 15); _preview_box.pack_start(_preview_render, Gtk::PACK_EXPAND_PADDING, 10); _short_description_label.set_line_wrap(true); - //_short_description_label.set_size_request(200); Gtk::Alignment *align; align = manage(new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER, 0.0, 0.0)); @@ -83,7 +80,6 @@ void TemplateWidget::display(TemplateLoadTab::TemplateData data) _current_template = data; _template_name_label.set_text(_current_template.display_name); - // _template_author_label.set_text(_current_template.author); _short_description_label.set_text(_current_template.short_description); _preview_render.hide(); @@ -105,7 +101,7 @@ void TemplateWidget::display(TemplateLoadTab::TemplateData data) _effect_prefs = NULL; } if (data.is_procedural){ - _effect_prefs = data.tpl_effect->get_imp()->prefs_effect(data.tpl_effect, SP_ACTIVE_DESKTOP, NULL, NULL); // SP_ACTIVE_DESKTOP? + _effect_prefs = data.tpl_effect->get_imp()->prefs_effect(data.tpl_effect, SP_ACTIVE_DESKTOP, NULL, NULL); pack_start(*_effect_prefs); } } diff --git a/src/ui/dialog/template-widget.h b/src/ui/dialog/template-widget.h index a41a14a38..bb35d26a0 100644 --- a/src/ui/dialog/template-widget.h +++ b/src/ui/dialog/template-widget.h @@ -17,6 +17,7 @@ #include "template-load-tab.h" + namespace Inkscape { namespace UI { @@ -36,7 +37,6 @@ private: Gtk::Image _preview_image; Dialog::SVGPreview _preview_render; Gtk::Label _short_description_label; - Gtk::Label _template_author_label; Gtk::Label _template_name_label; Gtk::Widget *_effect_prefs; -- cgit v1.2.3 From 37b7de3efa31c7aa3094aed7c849a08e7f7bedfd Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Sun, 22 Sep 2013 20:26:44 -0400 Subject: Fix percentage document size handling. Fixed bugs: - https://launchpad.net/bugs/1228852 (bzr r12577) --- src/ui/dialog/document-properties.cpp | 10 ++++++++-- src/ui/widget/page-sizer.cpp | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index ec04f6d98..37d0ce213 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -1440,15 +1440,21 @@ void DocumentProperties::update() if (nv->doc_units) _rum_deflt.setUnit (nv->doc_units->abbr); - double const doc_w = sp_desktop_document(dt)->getRoot()->width.value; + double doc_w = sp_desktop_document(dt)->getRoot()->width.value; Glib::ustring doc_w_unit = unit_table.getUnit(sp_desktop_document(dt)->getRoot()->width.unit).abbr; if (doc_w_unit == "") { doc_w_unit = "px"; + } else if (doc_w_unit == "%" && sp_desktop_document(dt)->getRoot()->viewBox_set) { + doc_w_unit = "px"; + doc_w = sp_desktop_document(dt)->getRoot()->viewBox.width(); } - double const doc_h = sp_desktop_document(dt)->getRoot()->height.value; + double doc_h = sp_desktop_document(dt)->getRoot()->height.value; Glib::ustring doc_h_unit = unit_table.getUnit(sp_desktop_document(dt)->getRoot()->height.unit).abbr; if (doc_h_unit == "") { doc_h_unit = "px"; + } else if (doc_h_unit == "%" && sp_desktop_document(dt)->getRoot()->viewBox_set) { + doc_h_unit = "px"; + doc_h = sp_desktop_document(dt)->getRoot()->viewBox.height(); } _page_sizer.setDim(Inkscape::Util::Quantity(doc_w, doc_w_unit), Inkscape::Util::Quantity(doc_h, doc_h_unit)); _page_sizer.updateFitMarginsUI(nv->getRepr()); diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index 051937c43..2379dc181 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -474,6 +474,8 @@ PageSizer::setDim (Inkscape::Util::Quantity w, Inkscape::Util::Quantity h, bool _changedw_connection.block(); _changedh_connection.block(); + _unit = w.unit->abbr; + if (SP_ACTIVE_DESKTOP && !_widgetRegistry->isUpdating()) { SPDocument *doc = sp_desktop_document(SP_ACTIVE_DESKTOP); Inkscape::Util::Quantity const old_height = doc->getHeight(); -- cgit v1.2.3 From d61c35fdf2ffc449d916fc6ab33c20c177d22894 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20dos=20Santos=20Oliveira?= Date: Mon, 23 Sep 2013 14:55:42 -0300 Subject: Disable smooth output in Inkscape PixelArtDialog (bzr r12578) --- 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 e07cbccb5..ff527434e 100644 --- a/src/ui/dialog/pixelartdialog.cpp +++ b/src/ui/dialog/pixelartdialog.cpp @@ -129,7 +129,9 @@ private: Gtk::RadioButton voronoiRadioButton; Gtk::RadioButton noOptimizeRadioButton; +#if LIBDEPIXELIZE_INKSCAPE_ENABLE_SMOOTH Gtk::RadioButton optimizeRadioButton; +#endif // LIBDEPIXELIZE_INKSCAPE_ENABLE_SMOOTH SPDesktop *desktop; DesktopTracker deskTrack; @@ -247,12 +249,14 @@ PixelArtDialogImpl::PixelArtDialogImpl() : outputVBox.pack_start(noOptimizeRadioButton, false, false); +#if LIBDEPIXELIZE_INKSCAPE_ENABLE_SMOOTH 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); +#endif // LIBDEPIXELIZE_INKSCAPE_ENABLE_SMOOTH outputFrame.set_label(_("Output")); outputFrame.add(outputVBox); @@ -308,7 +312,11 @@ Tracer::Kopf2011::Options PixelArtDialogImpl::options() options.islandsWeight = islandsWeightSpinner.get_value_as_int(); options.sparsePixelsMultiplier = sparsePixelsMultiplierSpinner.get_value(); options.sparsePixelsRadius = sparsePixelsRadiusSpinner.get_value_as_int(); +#if LIBDEPIXELIZE_INKSCAPE_ENABLE_SMOOTH options.optimize = optimizeRadioButton.get_active(); +#else // LIBDEPIXELIZE_INKSCAPE_ENABLE_SMOOTH + options.optimize = false; +#endif // LIBDEPIXELIZE_INKSCAPE_ENABLE_SMOOTH options.nthreads = Inkscape::Preferences::get() ->getIntLimited("/options/threading/numthreads", @@ -450,7 +458,11 @@ void PixelArtDialogImpl::setDefaults() sparsePixelsMultiplierSpinner.set_value(Tracer::Kopf2011::Options ::SPARSE_PIXELS_MULTIPLIER); +#if LIBDEPIXELIZE_INKSCAPE_ENABLE_SMOOTH optimizeRadioButton.set_active(); +#else // LIBDEPIXELIZE_INKSCAPE_ENABLE_SMOOTH + noOptimizeRadioButton.set_active(); +#endif // LIBDEPIXELIZE_INKSCAPE_ENABLE_SMOOTH ignorePreview = false; -- cgit v1.2.3 From 62b2cd734e684a93d1b9215aa8044c620939170d Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Tue, 24 Sep 2013 00:11:51 +0200 Subject: fix crash on uninitialized unittracker for spinbuttons. fixes crash on changing major grid line number, possibly other random crashes Fixed bugs: - https://launchpad.net/bugs/1229183 (bzr r12581) --- src/ui/widget/spinbutton.cpp | 4 ++-- src/ui/widget/spinbutton.h | 12 +++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'src/ui') diff --git a/src/ui/widget/spinbutton.cpp b/src/ui/widget/spinbutton.cpp index 62c17f821..1114ff32b 100644 --- a/src/ui/widget/spinbutton.cpp +++ b/src/ui/widget/spinbutton.cpp @@ -65,7 +65,7 @@ int SpinButton::on_input(double* newvalue) bool SpinButton::on_my_focus_in_event(GdkEventFocus* /*event*/) { - on_focus_in_value = get_value(); + _on_focus_in_value = get_value(); return false; // do not consume the event } @@ -92,7 +92,7 @@ bool SpinButton::on_my_key_press_event(GdkEventKey* event) void SpinButton::undo() { - set_value(on_focus_in_value); + set_value(_on_focus_in_value); } diff --git a/src/ui/widget/spinbutton.h b/src/ui/widget/spinbutton.h index c772fe2a2..812b5f515 100644 --- a/src/ui/widget/spinbutton.h +++ b/src/ui/widget/spinbutton.h @@ -38,7 +38,9 @@ class SpinButton : public Gtk::SpinButton public: SpinButton(double climb_rate = 0.0, guint digits = 0) : Gtk::SpinButton(climb_rate, digits), - _unit_menu(NULL) + _unit_menu(NULL), + _unit_tracker(NULL), + _on_focus_in_value(0.) { connect_signals(); }; @@ -48,10 +50,11 @@ public: explicit SpinButton(Gtk::Adjustment& adjustment, double climb_rate = 0.0, guint digits = 0) #endif : Gtk::SpinButton(adjustment, climb_rate, digits), - _unit_menu(NULL) + _unit_menu(NULL), + _unit_tracker(NULL), + _on_focus_in_value(0.) { connect_signals(); - _unit_tracker = NULL; }; virtual ~SpinButton() {}; @@ -63,6 +66,7 @@ public: protected: UnitMenu *_unit_menu; /// Linked unit menu for unit conversion in entered expressions. UnitTracker *_unit_tracker; // Linked unit tracker for unit conversion in entered expressions. + double _on_focus_in_value; void connect_signals(); @@ -95,8 +99,6 @@ protected: */ void undo(); - double on_focus_in_value; - private: // noncopyable SpinButton(const SpinButton&); -- cgit v1.2.3 From eba05095970a9ee1de53703f5533efbbfbf91715 Mon Sep 17 00:00:00 2001 From: Bryce Harrington Date: Tue, 24 Sep 2013 11:31:44 -0700 Subject: Fix my email address through codebase (bzr r12588) --- src/ui/dialog/layer-properties.cpp | 2 +- src/ui/dialog/layer-properties.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/layer-properties.cpp b/src/ui/dialog/layer-properties.cpp index 3feed2afe..b9e5d4883 100644 --- a/src/ui/dialog/layer-properties.cpp +++ b/src/ui/dialog/layer-properties.cpp @@ -3,7 +3,7 @@ * Dialog for renaming layers. */ /* Author: - * Bryce W. Harrington + * Bryce W. Harrington * Andrius R. * Abhishek Sharma * diff --git a/src/ui/dialog/layer-properties.h b/src/ui/dialog/layer-properties.h index d38b8edf5..d114c6ba5 100644 --- a/src/ui/dialog/layer-properties.h +++ b/src/ui/dialog/layer-properties.h @@ -2,7 +2,7 @@ * @brief Dialog for renaming layers */ /* Author: - * Bryce W. Harrington + * Bryce W. Harrington * * Copyright (C) 2004 Bryce Harrington * -- cgit v1.2.3 From 2f017d2ef4974eba04515b9a155656ce9f2f7822 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Tue, 24 Sep 2013 23:32:23 +0200 Subject: Refactored SPUse. (bzr r11608.1.128) --- src/ui/dialog/livepatheffect-editor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp index 6dc9c1ee3..0102977e4 100644 --- a/src/ui/dialog/livepatheffect-editor.cpp +++ b/src/ui/dialog/livepatheffect-editor.cpp @@ -296,7 +296,7 @@ LivePathEffectEditor::onSelectionChanged(Inkscape::Selection *sel) } } else if ( SP_IS_USE(item) ) { // test whether linked object is supported by the CLONE_ORIGINAL LPE - SPItem *orig = sp_use_get_original( SP_USE(item) ); + SPItem *orig = SP_USE(item)->get_original(); if ( SP_IS_SHAPE(orig) || SP_IS_TEXT(orig) ) { @@ -433,7 +433,7 @@ LivePathEffectEditor::onAdd() // convert to path, apply CLONE_ORIGINAL LPE, link it to the cloned path // test whether linked object is supported by the CLONE_ORIGINAL LPE - SPItem *orig = sp_use_get_original( SP_USE(item) ); + SPItem *orig = SP_USE(item)->get_original(); if ( SP_IS_SHAPE(orig) || SP_IS_TEXT(orig) ) { -- cgit v1.2.3 From 96190a607cf8edbcb8d4d2f88f0e451cf6abfa83 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Wed, 25 Sep 2013 23:51:52 +0200 Subject: C++ify calling a few SPLPEItem functions, much more work than expected... slowly slowly... (bzr r12593) --- src/ui/clipboard.cpp | 2 +- src/ui/dialog/livepatheffect-editor.cpp | 2 +- src/ui/tool/path-manipulator.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/ui') diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 1d91a3b4d..ed28cabbd 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -724,7 +724,7 @@ void ClipboardManagerImpl::_copyUsedDefs(SPItem *item) // For lpe items, copy lpe stack if applicable if (SP_IS_LPE_ITEM(item)) { SPLPEItem *lpeitem = SP_LPE_ITEM (item); - if (sp_lpe_item_has_path_effect(lpeitem)) { + if (lpeitem->hasPathEffect()) { for (PathEffectList::iterator it = lpeitem->path_effect_list->begin(); it != lpeitem->path_effect_list->end(); ++it) { LivePathEffectObject *lpeobj = (*it)->lpeobject; diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp index 6dc9c1ee3..2319d2c70 100644 --- a/src/ui/dialog/livepatheffect-editor.cpp +++ b/src/ui/dialog/livepatheffect-editor.cpp @@ -279,7 +279,7 @@ LivePathEffectEditor::onSelectionChanged(Inkscape::Selection *sel) current_lpeitem = lpeitem; set_sensitize_all(true); - if ( sp_lpe_item_has_path_effect(lpeitem) ) { + if ( lpeitem->hasPathEffect() ) { Inkscape::LivePathEffect::Effect *lpe = sp_lpe_item_get_current_lpe(lpeitem); if (lpe) { showParams(*lpe); diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index ac023beaa..673eba97a 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -1201,8 +1201,8 @@ void PathManipulator::_createGeometryFromControlPoints(bool alert_LPE) Geom::PathVector pathv = builder.peek() * (_edit_transform * _i2d_transform).inverse(); _spcurve->set_pathvector(pathv); if (alert_LPE) { - if (SP_IS_LPE_ITEM(_path) && sp_lpe_item_has_path_effect(SP_LPE_ITEM(_path))) { - PathEffectList effect_list = sp_lpe_item_get_effect_list(SP_LPE_ITEM(_path)); + if (_path->hasPathEffect()) { + PathEffectList effect_list = sp_lpe_item_get_effect_list(_path); LivePathEffect::LPEPowerStroke *lpe_pwr = dynamic_cast( effect_list.front()->lpeobject->get_lpe() ); if (lpe_pwr) { lpe_pwr->adjustForNewPath(pathv); -- cgit v1.2.3 From 90c7ce56fa03e18efa7296d12c6ca48f8e322e60 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Thu, 26 Sep 2013 22:25:56 +0200 Subject: random code cleanup (bzr r12596) --- src/ui/tool/path-manipulator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 673eba97a..6e14e8e97 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -1328,7 +1328,7 @@ void PathManipulator::_setGeometry() if (_path->getRepr()->attribute("inkscape:original-d")) _path->set_original_curve(_spcurve, false, false); else - SP_SHAPE(_path)->setCurve(_spcurve, false); + _path->setCurve(_spcurve, false); } } -- cgit v1.2.3 From e6402fab7e8e858314ea0ea3b5c496c17a2c272b Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Thu, 26 Sep 2013 23:01:36 +0200 Subject: cppcheck: performance (bzr r12598) --- src/ui/dialog/template-widget.cpp | 2 +- src/ui/widget/unit-tracker.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index 7e34e5a58..898903f2b 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -120,7 +120,7 @@ void TemplateWidget::_displayTemplateDetails() if (_current_template.long_description != "") message += _("Description: ") + _current_template.long_description + "\n\n"; - if (_current_template.keywords.size() > 0){ + if (~_current_template.keywords.empty()){ message += _("Keywords: "); for (std::set::iterator it = _current_template.keywords.begin(); it != _current_template.keywords.end(); ++it) message += *it + " "; diff --git a/src/ui/widget/unit-tracker.cpp b/src/ui/widget/unit-tracker.cpp index 5b2dc031b..f9b0c3a44 100644 --- a/src/ui/widget/unit-tracker.cpp +++ b/src/ui/widget/unit-tracker.cpp @@ -41,7 +41,7 @@ UnitTracker::UnitTracker(UnitType unit_type) : UnitTable::UnitMap::iterator m_iter = m.begin(); while(m_iter != m.end()) { Glib::ustring text = (*m_iter).first; - m_iter++; + ++m_iter; gtk_list_store_append(_store, &iter); gtk_list_store_set(_store, &iter, COLUMN_STRING, text.c_str(), -1); } -- cgit v1.2.3 From 0b3a91c8ff18bd30b42beb71244ff9b0542ed2ca Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 28 Sep 2013 21:58:24 +0200 Subject: fix two memleaks (bzr r12617) --- src/ui/dialog/svg-fonts-dialog.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/svg-fonts-dialog.cpp b/src/ui/dialog/svg-fonts-dialog.cpp index ab5f4c0e9..56ecfdecc 100644 --- a/src/ui/dialog/svg-fonts-dialog.cpp +++ b/src/ui/dialog/svg-fonts-dialog.cpp @@ -541,7 +541,9 @@ void SvgFontsDialog::set_glyph_description_from_selected_path(){ Geom::PathVector pathv = sp_svg_read_pathv(node->attribute("d")); //XML Tree being directly used here while it shouldn't be. - glyph->getRepr()->setAttribute("d", (char*) sp_svg_write_path (flip_coordinate_system(pathv))); + gchar *str = sp_svg_write_path (flip_coordinate_system(pathv)); + glyph->getRepr()->setAttribute("d", str); + g_free(str); DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph curves")); update_glyphs(); @@ -578,7 +580,9 @@ void SvgFontsDialog::missing_glyph_description_from_selected_path(){ if (SP_IS_MISSING_GLYPH(obj)){ //XML Tree being directly used here while it shouldn't be. - obj->getRepr()->setAttribute("d", (char*) sp_svg_write_path (flip_coordinate_system(pathv))); + gchar *str = sp_svg_write_path (flip_coordinate_system(pathv)); + obj->getRepr()->setAttribute("d", str); + g_free(str); DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph curves")); } } -- cgit v1.2.3 From 402facfad7ee68aa208b1f8f9966e7492c8cc13f Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Mon, 30 Sep 2013 22:49:26 +0200 Subject: string leaks (bzr r12640) --- src/ui/dialog/ocaldialogs.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/ocaldialogs.cpp b/src/ui/dialog/ocaldialogs.cpp index f87288494..90230286e 100644 --- a/src/ui/dialog/ocaldialogs.cpp +++ b/src/ui/dialog/ocaldialogs.cpp @@ -1017,7 +1017,7 @@ void SearchResultList::populate_from_xml(xmlNode * a_node) } else if (!strcmp(reinterpret_cast(cur_node->name), "enclosure")) { - xmlChar *xml_url = xmlGetProp(cur_node, reinterpret_cast(g_strdup("url"))); + xmlChar *xml_url = xmlGetProp(cur_node, reinterpret_cast("url")); char* url = reinterpret_cast(xml_url); char* filename = g_path_get_basename(url); @@ -1027,7 +1027,7 @@ void SearchResultList::populate_from_xml(xmlNode * a_node) } else if (!strcmp(reinterpret_cast(cur_node->name), "thumbnail")) { - xmlChar *xml_thumbnail_url = xmlGetProp(cur_node, reinterpret_cast(g_strdup("url"))); + xmlChar *xml_thumbnail_url = xmlGetProp(cur_node, reinterpret_cast("url")); char* thumbnail_url = reinterpret_cast(xml_thumbnail_url); char* thumbnail_filename = g_path_get_basename(thumbnail_url); -- cgit v1.2.3 From d60357c24c3b0b67c9372b26fc94d9328efcf22f Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Mon, 30 Sep 2013 22:53:03 +0200 Subject: fix previous commit (bzr r12641) --- src/ui/dialog/ocaldialogs.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/ocaldialogs.cpp b/src/ui/dialog/ocaldialogs.cpp index 90230286e..ca0edfadd 100644 --- a/src/ui/dialog/ocaldialogs.cpp +++ b/src/ui/dialog/ocaldialogs.cpp @@ -1017,7 +1017,7 @@ void SearchResultList::populate_from_xml(xmlNode * a_node) } else if (!strcmp(reinterpret_cast(cur_node->name), "enclosure")) { - xmlChar *xml_url = xmlGetProp(cur_node, reinterpret_cast("url")); + xmlChar *xml_url = xmlGetProp(cur_node, reinterpret_cast("url")); char* url = reinterpret_cast(xml_url); char* filename = g_path_get_basename(url); @@ -1027,7 +1027,7 @@ void SearchResultList::populate_from_xml(xmlNode * a_node) } else if (!strcmp(reinterpret_cast(cur_node->name), "thumbnail")) { - xmlChar *xml_thumbnail_url = xmlGetProp(cur_node, reinterpret_cast("url")); + xmlChar *xml_thumbnail_url = xmlGetProp(cur_node, reinterpret_cast("url")); char* thumbnail_url = reinterpret_cast(xml_thumbnail_url); char* thumbnail_filename = g_path_get_basename(thumbnail_url); -- cgit v1.2.3 From 31c244b7e2d06d67d67142696351507b1a08bb09 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Wed, 2 Oct 2013 03:28:57 +0200 Subject: Fix segment welding in the node tool hanging when a two-point segment and at least one additional point is selected. Fixes LP bug #710101. Fixed bugs: - https://launchpad.net/bugs/710101 (bzr r12650) --- src/ui/tool/path-manipulator.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/ui') diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 6e14e8e97..b775c0637 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -459,7 +459,10 @@ void PathManipulator::weldSegments() if (j->selected()) ++num_selected; else ++num_unselected; } - if (num_selected < 3) continue; + + // if 2 or fewer nodes are selected, there can't be any middle points to remove. + if (num_selected <= 2) continue; + if (num_unselected == 0 && sp->closed()) { // if all nodes in a closed subpath are selected, the operation doesn't make much sense continue; @@ -489,14 +492,16 @@ void PathManipulator::weldSegments() } if (num_points > 2) { // remove nodes in the middle + // TODO: fit bezier to the former shape sel_beg = sel_beg.next(); while (sel_beg != sel_end.prev()) { NodeList::iterator next = sel_beg.next(); sp->erase(sel_beg); sel_beg = next; } - sel_beg = sel_end; } + sel_beg = sel_end; + // decrease num_selected by the number of points processed num_selected -= num_points; } } -- cgit v1.2.3 From 8390b213aa2b3456664d7820b75a9f25458b1cd3 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Fri, 4 Oct 2013 18:01:05 +0200 Subject: Do not allow NULL _spcurve to be set in PathManipulator. Fixes crasher bug #488035. Fixed bugs: - https://launchpad.net/bugs/488035 (bzr r12655) --- src/ui/tool/path-manipulator.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/ui') diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index b775c0637..3d080ad19 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -1309,6 +1309,10 @@ void PathManipulator::_getGeometry() } else { _spcurve->unref(); _spcurve = _path->get_curve_for_edit(); + // never allow NULL to sneak in here! + if (_spcurve == NULL) { + _spcurve = new SPCurve(); + } } } -- cgit v1.2.3 From b40810c40eb3631a47ca16968d96294f795baee8 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Fri, 4 Oct 2013 22:53:18 +0200 Subject: fix bug (added some comments to jabiertxof's patch) Fixed bugs: - https://launchpad.net/bugs/1235032 (bzr r12658) --- src/ui/tool/path-manipulator.cpp | 5 +++-- src/ui/tool/path-manipulator.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src/ui') diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 3d080ad19..36f78af9d 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -203,7 +203,7 @@ void PathManipulator::writeXML() sp_object_ref(_path); _path->deleteObject(true, true); sp_object_unref(_path); - _path = 0; + _path = NULL; } _observer->unblock(); } @@ -1206,7 +1206,8 @@ void PathManipulator::_createGeometryFromControlPoints(bool alert_LPE) Geom::PathVector pathv = builder.peek() * (_edit_transform * _i2d_transform).inverse(); _spcurve->set_pathvector(pathv); if (alert_LPE) { - if (_path->hasPathEffect()) { + /// \todo note that _path can be an Inkscape::LivePathEffect::Effect* too, kind of confusing, rework member naming? + if (SP_IS_LPE_ITEM(_path) && _path->hasPathEffect()) { PathEffectList effect_list = sp_lpe_item_get_effect_list(_path); LivePathEffect::LPEPowerStroke *lpe_pwr = dynamic_cast( effect_list.front()->lpeobject->get_lpe() ); if (lpe_pwr) { diff --git a/src/ui/tool/path-manipulator.h b/src/ui/tool/path-manipulator.h index 1444272e8..e01e8617f 100644 --- a/src/ui/tool/path-manipulator.h +++ b/src/ui/tool/path-manipulator.h @@ -131,7 +131,7 @@ private: SubpathList _subpaths; MultiPathManipulator &_multi_path_manipulator; - SPPath *_path; + SPPath *_path; ///< can be an SPPath or an Inkscape::LivePathEffect::Effect !!! SPCurve *_spcurve; // in item coordinates SPCanvasItem *_outline; CurveDragPoint *_dragpoint; // an invisible control point hoverng over curve -- cgit v1.2.3 From 9a2c4ca30ed332442428594438848b9de2e589a9 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Fri, 4 Oct 2013 23:18:20 +0200 Subject: C++ (bzr r12659) --- src/ui/dialog/livepatheffect-editor.cpp | 14 +++++++------- src/ui/tool/path-manipulator.cpp | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp index e96b57170..96f8c9446 100644 --- a/src/ui/dialog/livepatheffect-editor.cpp +++ b/src/ui/dialog/livepatheffect-editor.cpp @@ -332,7 +332,7 @@ LivePathEffectEditor::effect_list_reload(SPLPEItem *lpeitem) { effectlist_store->clear(); - PathEffectList effectlist = sp_lpe_item_get_effect_list(lpeitem); + PathEffectList effectlist = lpeitem->getEffectList(); PathEffectList::iterator it; for( it = effectlist.begin() ; it!=effectlist.end(); ++it) { @@ -491,13 +491,13 @@ void LivePathEffectEditor::onUp() Inkscape::Selection *sel = _getSelection(); if ( sel && !sel->isEmpty() ) { SPItem *item = sel->singleItem(); - if ( item && SP_IS_LPE_ITEM(item) ) { - sp_lpe_item_up_current_path_effect(SP_LPE_ITEM(item)); + if ( SPLPEItem *lpeitem = SP_LPE_ITEM(item) ) { + lpeitem->upCurrentPathEffect(); DocumentUndo::done( sp_desktop_document(current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Move path effect up") ); - effect_list_reload(SP_LPE_ITEM(item)); + effect_list_reload(lpeitem); } } } @@ -507,13 +507,13 @@ void LivePathEffectEditor::onDown() Inkscape::Selection *sel = _getSelection(); if ( sel && !sel->isEmpty() ) { SPItem *item = sel->singleItem(); - if ( item && SP_IS_LPE_ITEM(item) ) { - sp_lpe_item_down_current_path_effect(SP_LPE_ITEM(item)); + if ( SPLPEItem *lpeitem = SP_LPE_ITEM(item) ) { + lpeitem->downCurrentPathEffect(); DocumentUndo::done( sp_desktop_document(current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Move path effect down") ); - effect_list_reload(SP_LPE_ITEM(item)); + effect_list_reload(lpeitem); } } } diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 36f78af9d..d12e2958b 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -1208,7 +1208,7 @@ void PathManipulator::_createGeometryFromControlPoints(bool alert_LPE) if (alert_LPE) { /// \todo note that _path can be an Inkscape::LivePathEffect::Effect* too, kind of confusing, rework member naming? if (SP_IS_LPE_ITEM(_path) && _path->hasPathEffect()) { - PathEffectList effect_list = sp_lpe_item_get_effect_list(_path); + PathEffectList effect_list = _path->getEffectList(); LivePathEffect::LPEPowerStroke *lpe_pwr = dynamic_cast( effect_list.front()->lpeobject->get_lpe() ); if (lpe_pwr) { lpe_pwr->adjustForNewPath(pathv); -- cgit v1.2.3 From 4f857ae84089672e9c7378d327e54889f64c62fb Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Fri, 4 Oct 2013 23:57:28 +0200 Subject: C++ (bzr r12660) --- src/ui/clipboard.cpp | 4 ++-- src/ui/dialog/livepatheffect-editor.cpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/ui') diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index ed28cabbd..da6fed86b 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -938,7 +938,7 @@ void ClipboardManagerImpl::_applyPathEffect(SPItem *item, gchar const *effectsta { SPLPEItem *lpeitem = SP_LPE_ITEM(item); // for each effect in the stack, check if we need to fork it before adding it to the item - sp_lpe_item_fork_path_effects_if_necessary(lpeitem, 1); + lpeitem->forkPathEffectsIfNecessary(1); std::istringstream iss(effectstack); std::string href; @@ -949,7 +949,7 @@ void ClipboardManagerImpl::_applyPathEffect(SPItem *item, gchar const *effectsta return; } LivePathEffectObject *lpeobj = LIVEPATHEFFECT(obj); - sp_lpe_item_add_path_effect(lpeitem, lpeobj); + lpeitem->addPathEffect(lpeobj); } } } diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp index 96f8c9446..30b16cee0 100644 --- a/src/ui/dialog/livepatheffect-editor.cpp +++ b/src/ui/dialog/livepatheffect-editor.cpp @@ -280,7 +280,7 @@ LivePathEffectEditor::onSelectionChanged(Inkscape::Selection *sel) set_sensitize_all(true); if ( lpeitem->hasPathEffect() ) { - Inkscape::LivePathEffect::Effect *lpe = sp_lpe_item_get_current_lpe(lpeitem); + Inkscape::LivePathEffect::Effect *lpe = lpeitem->getCurrentLPE(); if (lpe) { showParams(*lpe); lpe_list_locked = true; @@ -475,7 +475,7 @@ LivePathEffectEditor::onRemove() if ( sel && !sel->isEmpty() ) { SPItem *item = sel->singleItem(); if ( item && SP_IS_LPE_ITEM(item) ) { - sp_lpe_item_remove_current_path_effect(SP_LPE_ITEM(item), false); + SP_LPE_ITEM(item)->removeCurrentPathEffect(false); DocumentUndo::done( sp_desktop_document(current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Remove path effect") ); @@ -530,7 +530,7 @@ void LivePathEffectEditor::on_effect_selection_changed() if (lperef && current_lpeitem) { if (lperef->lpeobject->get_lpe()) { lpe_list_locked = true; // prevent reload of the list which would lose selection - sp_lpe_item_set_current_path_effect(current_lpeitem, lperef); + current_lpeitem->setCurrentPathEffect(lperef); showParams(*lperef->lpeobject->get_lpe()); } } -- cgit v1.2.3 From 706294ff1fa82c86089221d8ee4a0d5bd032925a Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sat, 5 Oct 2013 05:54:43 +0200 Subject: Rewrite the internals of the unit code for somewhat better performance (bzr r12661) --- src/ui/widget/selected-style.cpp | 2 +- src/ui/widget/unit-menu.cpp | 8 +++----- src/ui/widget/unit-tracker.cpp | 8 ++++---- 3 files changed, 8 insertions(+), 10 deletions(-) (limited to 'src/ui') diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index 894700046..97581aa83 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -313,7 +313,7 @@ SelectedStyle::SelectedStyle(bool /*layout*/) Inkscape::Util::UnitTable::UnitMap::iterator iter = m.begin(); while(iter != m.end()) { Gtk::RadioMenuItem *mi = Gtk::manage(new Gtk::RadioMenuItem(_sw_group)); - mi->add(*(new Gtk::Label((*iter).first, 0.0, 0.5))); + mi->add(*(new Gtk::Label(iter->first, 0.0, 0.5))); _unit_mis = g_slist_append(_unit_mis, mi); Inkscape::Util::Unit const *u = new Inkscape::Util::Unit(unit_table.getUnit(iter->first)); mi->signal_activate().connect(sigc::bind(sigc::mem_fun(*this, &SelectedStyle::on_popup_units), *u)); diff --git a/src/ui/widget/unit-menu.cpp b/src/ui/widget/unit-menu.cpp index 111226774..684016471 100644 --- a/src/ui/widget/unit-menu.cpp +++ b/src/ui/widget/unit-menu.cpp @@ -33,11 +33,9 @@ bool UnitMenu::setUnitType(UnitType unit_type) { // Expand the unit widget with unit entries from the unit table UnitTable::UnitMap m = unit_table.units(unit_type); - UnitTable::UnitMap::iterator iter = m.begin(); - while(iter != m.end()) { - Glib::ustring text = (*iter).first; - append(text); - ++iter; + + for (UnitTable::UnitMap::iterator i = m.begin(); i != m.end(); ++i) { + append(i->first); } _type = unit_type; set_active_text(unit_table.primary(unit_type)); diff --git a/src/ui/widget/unit-tracker.cpp b/src/ui/widget/unit-tracker.cpp index f9b0c3a44..155f3fafe 100644 --- a/src/ui/widget/unit-tracker.cpp +++ b/src/ui/widget/unit-tracker.cpp @@ -38,10 +38,10 @@ UnitTracker::UnitTracker(UnitType unit_type) : GtkTreeIter iter; UnitTable::UnitMap m = unit_table.units(unit_type); - UnitTable::UnitMap::iterator m_iter = m.begin(); - while(m_iter != m.end()) { - Glib::ustring text = (*m_iter).first; - ++m_iter; + + + for (UnitTable::UnitMap::iterator m_iter = m.begin(); m_iter != m.end(); ++m_iter) { + Glib::ustring text = m_iter->first; gtk_list_store_append(_store, &iter); gtk_list_store_set(_store, &iter, COLUMN_STRING, text.c_str(), -1); } -- cgit v1.2.3 From f5d74fe46345673252807be3b6812bbb0469e457 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Tue, 8 Oct 2013 12:22:49 +0200 Subject: Seamlessly switch between SVG circle, ellipse, and path (arc) elements while using the Circle, Ellipse, and Arc tool. (bzr r12670) --- src/ui/dialog/find.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/dialog/find.cpp b/src/ui/dialog/find.cpp index def7b5bdb..37f2761df 100644 --- a/src/ui/dialog/find.cpp +++ b/src/ui/dialog/find.cpp @@ -664,7 +664,7 @@ bool Find::item_type_match (SPItem *item) if ( SP_IS_RECT(item)) { return ( all ||check_rects.get_active()); - } else if (SP_IS_GENERICELLIPSE(item) || SP_IS_ELLIPSE(item) || SP_IS_ARC(item) || SP_IS_CIRCLE(item)) { + } else if (SP_IS_GENERICELLIPSE(item)) { return ( all || check_ellipses.get_active()); } else if (SP_IS_STAR(item) || SP_IS_POLYGON(item)) { -- cgit v1.2.3 From 30422af227381c9aa900690586d25adec4fa262f Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Wed, 9 Oct 2013 21:09:49 +0200 Subject: Documentation/Translation. Fix for Bug #1236382 (Typos in comments and message, localization context needed) by Yuri Chornoivan. Fixed bugs: - https://launchpad.net/bugs/1236382 (bzr r12673) --- src/ui/dialog/filedialogimpl-win32.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/filedialogimpl-win32.h b/src/ui/dialog/filedialogimpl-win32.h index 2e6bb4bb8..29bcb9a45 100644 --- a/src/ui/dialog/filedialogimpl-win32.h +++ b/src/ui/dialog/filedialogimpl-win32.h @@ -140,7 +140,7 @@ public: /// Shows the file dialog, and blocks until a file /// has been selected. - /// @return Returns true if the the user selected a + /// @return Returns true if the user selected a /// file, or false if the user pressed cancel. bool show(); @@ -341,7 +341,7 @@ public: /// Shows the file dialog, and blocks until a file /// has been selected. - /// @return Returns true if the the user selected a + /// @return Returns true if the user selected a /// file, or false if the user pressed cancel. bool show(); -- cgit v1.2.3 From 6af4b5c656ebdff4aebc7ed01bd6076748b5dd95 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Wed, 9 Oct 2013 23:41:20 +0200 Subject: Fix cycling through nodes with tab key. Fixed bugs: - https://launchpad.net/bugs/1237667 (bzr r12675) --- src/ui/tool/node-tool.cpp | 12 +----------- src/ui/tool/node-tool.h | 1 - 2 files changed, 1 insertion(+), 12 deletions(-) (limited to 'src/ui') diff --git a/src/ui/tool/node-tool.cpp b/src/ui/tool/node-tool.cpp index 4b236e94c..76e33e506 100644 --- a/src/ui/tool/node-tool.cpp +++ b/src/ui/tool/node-tool.cpp @@ -534,11 +534,7 @@ bool InkNodeTool::root_handler(GdkEvent* event) { 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); - SPEventContext::root_handler(event); - - return FALSE; + return SPEventContext::root_handler(event); } void InkNodeTool::update_tip(GdkEvent *event) { @@ -607,12 +603,6 @@ void InkNodeTool::update_tip(GdkEvent *event) { } } -bool InkNodeTool::item_handler(SPItem* item, GdkEvent* event) { - SPEventContext::item_handler(item, event); - - return FALSE; -} - void InkNodeTool::select_area(Geom::Rect const &sel, GdkEventButton *event) { using namespace Inkscape::UI; diff --git a/src/ui/tool/node-tool.h b/src/ui/tool/node-tool.h index ce022cec6..c41f50650 100644 --- a/src/ui/tool/node-tool.h +++ b/src/ui/tool/node-tool.h @@ -49,7 +49,6 @@ public: virtual void setup(); virtual void set(const Inkscape::Preferences::Entry& val); virtual bool root_handler(GdkEvent* event); - virtual bool item_handler(SPItem* item, GdkEvent* event); virtual const std::string& getPrefsPath(); -- cgit v1.2.3 From a970dc423d59ea844bdb1af48d5d9419a5e2a287 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sun, 13 Oct 2013 00:24:05 +0200 Subject: Units: stop newing Unit objects. pass around pointers to "undeletable" Unit objects in the UnitTable. I think we should move to using indexed units, and pass around the index of the unit in the unittable, or smth like that... ? (bzr r12679) --- src/ui/dialog/clonetiler.cpp | 10 +++++----- src/ui/dialog/document-properties.cpp | 10 +++++----- src/ui/dialog/export.cpp | 4 ++-- src/ui/dialog/guides.cpp | 2 +- src/ui/tool/node.cpp | 13 ++++++------- src/ui/widget/page-sizer.cpp | 9 ++++----- src/ui/widget/page-sizer.h | 4 ++-- src/ui/widget/preferences-widget.cpp | 2 +- src/ui/widget/registered-widget.h | 2 +- src/ui/widget/scalar-unit.cpp | 10 +++++----- src/ui/widget/scalar-unit.h | 2 +- src/ui/widget/selected-style.cpp | 14 +++++++------- src/ui/widget/selected-style.h | 4 ++-- src/ui/widget/spinbutton.cpp | 6 +++--- src/ui/widget/style-swatch.cpp | 2 +- src/ui/widget/unit-menu.cpp | 25 +++++++++++++------------ src/ui/widget/unit-menu.h | 2 +- src/ui/widget/unit-tracker.cpp | 27 ++++++++++++++------------- src/ui/widget/unit-tracker.h | 8 ++++---- 19 files changed, 78 insertions(+), 78 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index b3675440b..87c399339 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -1107,7 +1107,7 @@ CloneTiler::CloneTiler (void) : #endif double value = prefs->getDouble(prefs_path + "fillwidth", 50.0); - Inkscape::Util::Unit const unit = unit_menu->getUnit(); + Inkscape::Util::Unit const *unit = unit_menu->getUnit(); gdouble const units = Inkscape::Util::Quantity::convert(value, "px", unit); fill_width->set_value (units); @@ -1140,7 +1140,7 @@ CloneTiler::CloneTiler (void) : #endif double value = prefs->getDouble(prefs_path + "fillheight", 50.0); - Inkscape::Util::Unit const unit = unit_menu->getUnit(); + Inkscape::Util::Unit const *unit = unit_menu->getUnit(); gdouble const units = Inkscape::Util::Quantity::convert(value, "px", unit); fill_height->set_value (units); @@ -2948,7 +2948,7 @@ void CloneTiler::clonetiler_switch_to_fill(GtkToggleButton * /*tb*/, GtkWidget * void CloneTiler::clonetiler_fill_width_changed(GtkAdjustment *adj, Inkscape::UI::Widget::UnitMenu *u) { gdouble const raw_dist = gtk_adjustment_get_value (adj); - Inkscape::Util::Unit const unit = u->getUnit(); + Inkscape::Util::Unit const *unit = u->getUnit(); gdouble const pixels = Inkscape::Util::Quantity::convert(raw_dist, unit, "px"); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -2958,7 +2958,7 @@ void CloneTiler::clonetiler_fill_width_changed(GtkAdjustment *adj, Inkscape::UI: void CloneTiler::clonetiler_fill_height_changed(GtkAdjustment *adj, Inkscape::UI::Widget::UnitMenu *u) { gdouble const raw_dist = gtk_adjustment_get_value (adj); - Inkscape::Util::Unit const unit = u->getUnit(); + Inkscape::Util::Unit const *unit = u->getUnit(); gdouble const pixels = Inkscape::Util::Quantity::convert(raw_dist, unit, "px"); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -2971,7 +2971,7 @@ void CloneTiler::clonetiler_unit_changed() gdouble width_pixels = prefs->getDouble(prefs_path + "fillwidth"); gdouble height_pixels = prefs->getDouble(prefs_path + "fillheight"); - Inkscape::Util::Unit unit = unit_menu->getUnit(); + Inkscape::Util::Unit const *unit = unit_menu->getUnit(); gdouble width_value = Inkscape::Util::Quantity::convert(width_pixels, "px", unit); gdouble height_value = Inkscape::Util::Quantity::convert(height_pixels, "px", unit); diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 37d0ce213..a6019c55c 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -1441,7 +1441,7 @@ void DocumentProperties::update() _rum_deflt.setUnit (nv->doc_units->abbr); double doc_w = sp_desktop_document(dt)->getRoot()->width.value; - Glib::ustring doc_w_unit = unit_table.getUnit(sp_desktop_document(dt)->getRoot()->width.unit).abbr; + Glib::ustring doc_w_unit = unit_table.getUnit(sp_desktop_document(dt)->getRoot()->width.unit)->abbr; if (doc_w_unit == "") { doc_w_unit = "px"; } else if (doc_w_unit == "%" && sp_desktop_document(dt)->getRoot()->viewBox_set) { @@ -1449,7 +1449,7 @@ void DocumentProperties::update() doc_w = sp_desktop_document(dt)->getRoot()->viewBox.width(); } double doc_h = sp_desktop_document(dt)->getRoot()->height.value; - Glib::ustring doc_h_unit = unit_table.getUnit(sp_desktop_document(dt)->getRoot()->height.unit).abbr; + Glib::ustring doc_h_unit = unit_table.getUnit(sp_desktop_document(dt)->getRoot()->height.unit)->abbr; if (doc_h_unit == "") { doc_h_unit = "px"; } else if (doc_h_unit == "%" && sp_desktop_document(dt)->getRoot()->viewBox_set) { @@ -1644,11 +1644,11 @@ void DocumentProperties::onDocUnitChange() { SPDocument *doc = SP_ACTIVE_DOCUMENT; Inkscape::XML::Node *repr = sp_desktop_namedview(getDesktop())->getRepr(); - Inkscape::Util::Unit old_doc_unit = unit_table.getUnit("px"); + Inkscape::Util::Unit const *old_doc_unit = unit_table.getUnit("px"); if(repr->attribute("inkscape:document-units")) { old_doc_unit = unit_table.getUnit(repr->attribute("inkscape:document-units")); } - Inkscape::Util::Unit doc_unit = _rum_deflt.getUnit(); + Inkscape::Util::Unit const *doc_unit = _rum_deflt.getUnit(); // Don't execute when change is being undone if (!DocumentUndo::getUndoSensitive(doc)) { @@ -1657,7 +1657,7 @@ void DocumentProperties::onDocUnitChange() // Set document unit Inkscape::SVGOStringStream os; - os << doc_unit.abbr; + os << doc_unit->abbr; repr->setAttribute("inkscape:document-units", os.str().c_str()); // Set viewBox diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 577793496..f1f7cf6c1 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -1884,7 +1884,7 @@ void Export::setValuePx(Glib::RefPtr& adj, double val) void Export::setValuePx( Gtk::Adjustment *adj, double val) #endif { - const Unit unit = unit_selector->getUnit(); + Unit const *unit = unit_selector->getUnit(); setValue(adj, Inkscape::Util::Quantity::convert(val, "px", unit)); @@ -1934,7 +1934,7 @@ float Export::getValuePx( Gtk::Adjustment *adj ) #endif { float value = getValue( adj); - const Unit unit = unit_selector->getUnit(); + Unit const *unit = unit_selector->getUnit(); return Inkscape::Util::Quantity::convert(value, unit, "px"); } // end of sp_export_value_get_px() diff --git a/src/ui/dialog/guides.cpp b/src/ui/dialog/guides.cpp index 2de387364..5dfafa78d 100644 --- a/src/ui/dialog/guides.cpp +++ b/src/ui/dialog/guides.cpp @@ -59,7 +59,7 @@ Glib::ustring GuidelinePropertiesDialog::_angle_unit_status = DEG; // initialize GuidelinePropertiesDialog::~GuidelinePropertiesDialog() { // save current status _relative_toggle_status = _relative_toggle.get_active(); - _angle_unit_status = _spin_angle.getUnit().abbr; + _angle_unit_status = _spin_angle.getUnit()->abbr; } void GuidelinePropertiesDialog::showDialog(SPGuide *guide, SPDesktop *desktop) { diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 82eb697bd..76ec68c3e 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -493,9 +493,9 @@ Glib::ustring Handle::_getDragTip(GdkEventMotion */*event*/) const Inkscape::Util::Quantity x_q = Inkscape::Util::Quantity(dist[Geom::X], "px"); Inkscape::Util::Quantity y_q = Inkscape::Util::Quantity(dist[Geom::Y], "px"); Inkscape::Util::Quantity len_q = Inkscape::Util::Quantity(length(), "px"); - GString *x = g_string_new(x_q.string(*_desktop->namedview->doc_units).c_str()); - GString *y = g_string_new(y_q.string(*_desktop->namedview->doc_units).c_str()); - GString *len = g_string_new(len_q.string(*_desktop->namedview->doc_units).c_str()); + GString *x = g_string_new(x_q.string(_desktop->namedview->doc_units).c_str()); + GString *y = g_string_new(y_q.string(_desktop->namedview->doc_units).c_str()); + GString *len = g_string_new(len_q.string(_desktop->namedview->doc_units).c_str()); Glib::ustring ret = format_tip(C_("Path handle tip", "Move handle by %s, %s; angle %.2f°, length %s"), x->str, y->str, angle, len->str); g_string_free(x, TRUE); @@ -1300,10 +1300,9 @@ Glib::ustring Node::_getDragTip(GdkEventMotion */*event*/) const Inkscape::Util::Quantity x_q = Inkscape::Util::Quantity(dist[Geom::X], "px"); Inkscape::Util::Quantity y_q = Inkscape::Util::Quantity(dist[Geom::Y], "px"); - GString *x = g_string_new(x_q.string(*_desktop->namedview->doc_units).c_str()); - GString *y = g_string_new(y_q.string(*_desktop->namedview->doc_units).c_str()); - Glib::ustring ret = format_tip(C_("Path node tip", "Move node by %s, %s"), - x->str, y->str); + GString *x = g_string_new(x_q.string(_desktop->namedview->doc_units).c_str()); + GString *y = g_string_new(y_q.string(_desktop->namedview->doc_units).c_str()); + Glib::ustring ret = format_tip(C_("Path node tip", "Move node by %s, %s"), x->str, y->str); g_string_free(x, TRUE); g_string_free(y, TRUE); return ret; diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index 2379dc181..b13567adb 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -565,9 +565,8 @@ PageSizer::find_paper_size (Inkscape::Util::Quantity w, Inkscape::Util::Quantity for (iter = _paperSizeTable.begin() ; iter != _paperSizeTable.end() ; ++iter) { PaperSize paper = iter->second; - Inkscape::Util::Unit const &i_unit = paper.unit; - double smallX = Inkscape::Util::Quantity::convert(paper.smaller, i_unit, *w.unit); - double largeX = Inkscape::Util::Quantity::convert(paper.larger, i_unit, *w.unit); + double smallX = Inkscape::Util::Quantity::convert(paper.smaller, paper.unit, w.unit); + double largeX = Inkscape::Util::Quantity::convert(paper.larger, paper.unit, w.unit); g_return_val_if_fail(smallX <= largeX, _paperSizeListStore->children().end()); @@ -704,7 +703,7 @@ void PageSizer::on_value_changed() { if (_widgetRegistry->isUpdating()) return; - if (_unit != _dimensionUnits.getUnit().abbr) return; + if (_unit != _dimensionUnits.getUnit()->abbr) return; setDim (Inkscape::Util::Quantity(_dimensionWidth.getValue(""), _dimensionUnits.getUnit()), Inkscape::Util::Quantity(_dimensionHeight.getValue(""), _dimensionUnits.getUnit())); } @@ -712,7 +711,7 @@ void PageSizer::on_units_changed() { if (_widgetRegistry->isUpdating()) return; - _unit = _dimensionUnits.getUnit().abbr; + _unit = _dimensionUnits.getUnit()->abbr; setDim (Inkscape::Util::Quantity(_dimensionWidth.getValue(""), _dimensionUnits.getUnit()), Inkscape::Util::Quantity(_dimensionHeight.getValue(""), _dimensionUnits.getUnit())); } diff --git a/src/ui/widget/page-sizer.h b/src/ui/widget/page-sizer.h index 95836a005..dc8e34d82 100644 --- a/src/ui/widget/page-sizer.h +++ b/src/ui/widget/page-sizer.h @@ -64,7 +64,7 @@ public: PaperSize(const Glib::ustring &nameArg, double smallerArg, double largerArg, - Inkscape::Util::Unit unitArg) + Inkscape::Util::Unit const *unitArg) { name = nameArg; smaller = smallerArg; @@ -108,7 +108,7 @@ public: /** * The units (px, pt, mm, etc) of this specification */ - Inkscape::Util::Unit unit; + Inkscape::Util::Unit const *unit; /// pointer to object in UnitTable, do not delete private: diff --git a/src/ui/widget/preferences-widget.cpp b/src/ui/widget/preferences-widget.cpp index 567f29f91..3ba00c083 100644 --- a/src/ui/widget/preferences-widget.cpp +++ b/src/ui/widget/preferences-widget.cpp @@ -354,7 +354,7 @@ void PrefSpinUnit::on_my_value_changed() Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (getWidget()->get_visible()) //only take action if user changed value { - prefs->setDoubleUnit(_prefs_path, getValue(getUnit().abbr), getUnit().abbr); + prefs->setDoubleUnit(_prefs_path, getValue(getUnit()->abbr), getUnit()->abbr); } } diff --git a/src/ui/widget/registered-widget.h b/src/ui/widget/registered-widget.h index 93b0cef4e..883a9e1a2 100644 --- a/src/ui/widget/registered-widget.h +++ b/src/ui/widget/registered-widget.h @@ -167,7 +167,7 @@ public: SPDocument *doc_in = NULL ); void setUnit (const Glib::ustring); - Unit getUnit() const { return static_cast(_widget)->getUnit(); }; + Unit const * getUnit() const { return static_cast(_widget)->getUnit(); }; UnitMenu* getUnitMenu() const { return static_cast(_widget); }; sigc::connection _changed_connection; diff --git a/src/ui/widget/scalar-unit.cpp b/src/ui/widget/scalar-unit.cpp index 2f4c1f341..4fa1a7584 100644 --- a/src/ui/widget/scalar-unit.cpp +++ b/src/ui/widget/scalar-unit.cpp @@ -102,7 +102,7 @@ void ScalarUnit::resetUnitType(UnitType unit_type) lastUnits = _unit_menu->getUnitAbbr(); } -Unit ScalarUnit::getUnit() const +Unit const * ScalarUnit::getUnit() const { g_assert(_unit_menu != NULL); return _unit_menu->getUnit(); @@ -228,13 +228,13 @@ void ScalarUnit::on_unit_changed() Glib::ustring abbr = _unit_menu->getUnitAbbr(); _suffix->set_label(abbr); - Inkscape::Util::Unit new_unit = (unit_table.getUnit(abbr)); - Inkscape::Util::Unit old_unit = (unit_table.getUnit(lastUnits)); + Inkscape::Util::Unit const *new_unit = unit_table.getUnit(abbr); + Inkscape::Util::Unit const *old_unit = unit_table.getUnit(lastUnits); double convertedVal = 0; - if (old_unit.type == UNIT_TYPE_DIMENSIONLESS && new_unit.type == UNIT_TYPE_LINEAR) { + if (old_unit->type == UNIT_TYPE_DIMENSIONLESS && new_unit->type == UNIT_TYPE_LINEAR) { convertedVal = PercentageToAbsolute(Scalar::getValue()); - } else if (old_unit.type == UNIT_TYPE_LINEAR && new_unit.type == UNIT_TYPE_DIMENSIONLESS) { + } else if (old_unit->type == UNIT_TYPE_LINEAR && new_unit->type == UNIT_TYPE_DIMENSIONLESS) { convertedVal = AbsoluteToPercentage(Scalar::getValue()); } else { double conversion = _unit_menu->getConversion(lastUnits); diff --git a/src/ui/widget/scalar-unit.h b/src/ui/widget/scalar-unit.h index 4f22f438c..9e310d3bd 100644 --- a/src/ui/widget/scalar-unit.h +++ b/src/ui/widget/scalar-unit.h @@ -82,7 +82,7 @@ public: /** * Gets the object for the currently selected unit. */ - Unit getUnit() const; + Unit const * getUnit() const; /** * Gets the UnitType ID for the unit. diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index 97581aa83..3a6b0c7df 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -315,8 +315,8 @@ SelectedStyle::SelectedStyle(bool /*layout*/) Gtk::RadioMenuItem *mi = Gtk::manage(new Gtk::RadioMenuItem(_sw_group)); mi->add(*(new Gtk::Label(iter->first, 0.0, 0.5))); _unit_mis = g_slist_append(_unit_mis, mi); - Inkscape::Util::Unit const *u = new Inkscape::Util::Unit(unit_table.getUnit(iter->first)); - mi->signal_activate().connect(sigc::bind(sigc::mem_fun(*this, &SelectedStyle::on_popup_units), *u)); + Inkscape::Util::Unit const *u = unit_table.getUnit(iter->first); + mi->signal_activate().connect(sigc::bind(sigc::mem_fun(*this, &SelectedStyle::on_popup_units), u)); _popup_sw.attach(*mi, 0,1, row, row+1); row++; ++iter; @@ -481,7 +481,7 @@ SelectedStyle::setDesktop(SPDesktop *desktop) this ) )); - _sw_unit = const_cast(sp_desktop_namedview(desktop)->doc_units); + _sw_unit = sp_desktop_namedview(desktop)->doc_units; // Set the doc default unit active in the units list gint length = g_slist_length(_unit_mis); @@ -931,8 +931,8 @@ SelectedStyle::on_opacity_click(GdkEventButton *event) return false; } -void SelectedStyle::on_popup_units(Inkscape::Util::Unit &unit) { - _sw_unit = new Inkscape::Util::Unit(unit); +void SelectedStyle::on_popup_units(Inkscape::Util::Unit const *unit) { + _sw_unit = unit; update(); } @@ -940,7 +940,7 @@ void SelectedStyle::on_popup_preset(int i) { SPCSSAttr *css = sp_repr_css_attr_new (); gdouble w; if (_sw_unit) { - w = Inkscape::Util::Quantity::convert(_sw_presets[i], *_sw_unit, "px"); + w = Inkscape::Util::Quantity::convert(_sw_presets[i], _sw_unit, "px"); } else { w = _sw_presets[i]; } @@ -1119,7 +1119,7 @@ SelectedStyle::update() { double w; if (_sw_unit) { - w = Inkscape::Util::Quantity::convert(query->stroke_width.computed, "px", *_sw_unit); + w = Inkscape::Util::Quantity::convert(query->stroke_width.computed, "px", _sw_unit); } else { w = query->stroke_width.computed; } diff --git a/src/ui/widget/selected-style.h b/src/ui/widget/selected-style.h index 0a907f1fd..21e5575ed 100644 --- a/src/ui/widget/selected-style.h +++ b/src/ui/widget/selected-style.h @@ -276,11 +276,11 @@ protected: Gtk::Menu _popup_sw; Gtk::RadioButtonGroup _sw_group; GSList *_unit_mis; - void on_popup_units(Inkscape::Util::Unit &u); + void on_popup_units(Inkscape::Util::Unit const *u); void on_popup_preset(int i); Gtk::MenuItem _popup_sw_remove; - Inkscape::Util::Unit *_sw_unit; + Inkscape::Util::Unit const *_sw_unit; /// points to object in UnitTable, do not delete void *_drop[2]; bool _dropEnabled[2]; diff --git a/src/ui/widget/spinbutton.cpp b/src/ui/widget/spinbutton.cpp index 1114ff32b..6cbc15c1b 100644 --- a/src/ui/widget/spinbutton.cpp +++ b/src/ui/widget/spinbutton.cpp @@ -35,16 +35,16 @@ int SpinButton::on_input(double* newvalue) try { Inkscape::Util::EvaluatorQuantity result; if (_unit_menu || _unit_tracker) { - Unit unit; + Unit const *unit = NULL; if (_unit_menu) { unit = _unit_menu->getUnit(); } else { unit = _unit_tracker->getActiveUnit(); } - Inkscape::Util::ExpressionEvaluator eval = Inkscape::Util::ExpressionEvaluator(get_text().c_str(), &unit); + Inkscape::Util::ExpressionEvaluator eval = Inkscape::Util::ExpressionEvaluator(get_text().c_str(), unit); result = eval.evaluate(); // check if output dimension corresponds to input unit - if (result.dimension != (unit.isAbsolute() ? 1 : 0) ) { + if (result.dimension != (unit->isAbsolute() ? 1 : 0) ) { throw Inkscape::Util::EvaluatorException("Input dimensions do not match with parameter dimensions.",""); } } else { diff --git a/src/ui/widget/style-swatch.cpp b/src/ui/widget/style-swatch.cpp index 49466ce54..a33c1d09f 100644 --- a/src/ui/widget/style-swatch.cpp +++ b/src/ui/widget/style-swatch.cpp @@ -333,7 +333,7 @@ void StyleSwatch::setStyle(SPStyle *query) if (has_stroke) { double w; if (_sw_unit) { - w = Inkscape::Util::Quantity::convert(query->stroke_width.computed, "px", *_sw_unit); + w = Inkscape::Util::Quantity::convert(query->stroke_width.computed, "px", _sw_unit); } else { w = query->stroke_width.computed; } diff --git a/src/ui/widget/unit-menu.cpp b/src/ui/widget/unit-menu.cpp index 684016471..7416a2f02 100644 --- a/src/ui/widget/unit-menu.cpp +++ b/src/ui/widget/unit-menu.cpp @@ -56,7 +56,7 @@ void UnitMenu::addUnit(Unit const& u) append(u.abbr); } -Unit UnitMenu::getUnit() const +Unit const * UnitMenu::getUnit() const { if (get_active_text() == "") { g_assert(_type != UNIT_TYPE_NONE); @@ -79,27 +79,27 @@ Glib::ustring UnitMenu::getUnitAbbr() const if (get_active_text() == "") { return ""; } - return getUnit().abbr; + return getUnit()->abbr; } UnitType UnitMenu::getUnitType() const { - return getUnit().type; + return getUnit()->type; } double UnitMenu::getUnitFactor() const { - return getUnit().factor; + return getUnit()->factor; } int UnitMenu::getDefaultDigits() const { - return getUnit().defaultDigits(); + return getUnit()->defaultDigits(); } double UnitMenu::getDefaultStep() const { - int factor_digits = -1*int(log10(getUnit().factor)); + int factor_digits = -1*int(log10(getUnit()->factor)); return pow(10.0, factor_digits); } @@ -110,19 +110,20 @@ double UnitMenu::getDefaultPage() const double UnitMenu::getConversion(Glib::ustring const &new_unit_abbr, Glib::ustring const &old_unit_abbr) const { - double old_factor = getUnit().factor; - if (old_unit_abbr != "no_unit") - old_factor = unit_table.getUnit(old_unit_abbr).factor; - Unit new_unit = unit_table.getUnit(new_unit_abbr); + double old_factor = getUnit()->factor; + if (old_unit_abbr != "no_unit") { + old_factor = unit_table.getUnit(old_unit_abbr)->factor; + } + Unit const * new_unit = unit_table.getUnit(new_unit_abbr); // Catch the case of zero or negative unit factors (error!) if (old_factor < 0.0000001 || - new_unit.factor < 0.0000001) { + new_unit->factor < 0.0000001) { // TODO: Should we assert here? return 0.00; } - return old_factor / new_unit.factor; + return old_factor / new_unit->factor; } bool UnitMenu::isAbsolute() const diff --git a/src/ui/widget/unit-menu.h b/src/ui/widget/unit-menu.h index 3f4df6bf9..114c536c9 100644 --- a/src/ui/widget/unit-menu.h +++ b/src/ui/widget/unit-menu.h @@ -74,7 +74,7 @@ public: * Returns the Unit object corresponding to the current selection * in the dropdown widget. */ - Unit getUnit() const; + Unit const * getUnit() const; /** * Returns the abbreviated unit name of the selected unit. diff --git a/src/ui/widget/unit-tracker.cpp b/src/ui/widget/unit-tracker.cpp index 155f3fafe..67eb1f48d 100644 --- a/src/ui/widget/unit-tracker.cpp +++ b/src/ui/widget/unit-tracker.cpp @@ -27,6 +27,7 @@ namespace Widget { UnitTracker::UnitTracker(UnitType unit_type) : _active(0), _isUpdating(false), + _activeUnit(NULL), _activeUnitInitialized(false), _store(0), _unitList(0), @@ -74,7 +75,7 @@ bool UnitTracker::isUpdating() const return _isUpdating; } -Inkscape::Util::Unit UnitTracker::getActiveUnit() const +Inkscape::Util::Unit const * UnitTracker::getActiveUnit() const { return _activeUnit; } @@ -101,8 +102,8 @@ void UnitTracker::setActiveUnit(Inkscape::Util::Unit const *unit) void UnitTracker::setActiveUnitByAbbr(gchar const *abbr) { - Inkscape::Util::Unit u = unit_table.getUnit(abbr); - setActiveUnit(&u); + Inkscape::Util::Unit const *u = unit_table.getUnit(abbr); + setActiveUnit(u); } void UnitTracker::addAdjustment(GtkAdjustment *adj) @@ -113,11 +114,11 @@ void UnitTracker::addAdjustment(GtkAdjustment *adj) } } -void UnitTracker::addUnit(Inkscape::Util::Unit const &u) +void UnitTracker::addUnit(Inkscape::Util::Unit const *u) { GtkTreeIter iter; gtk_list_store_append(_store, &iter); - gtk_list_store_set(_store, &iter, COLUMN_STRING, u.abbr.c_str(), -1); + gtk_list_store_set(_store, &iter, COLUMN_STRING, u ? u->abbr.c_str() : "NULL", -1); } void UnitTracker::setFullVal(GtkAdjustment *adj, gdouble val) @@ -197,13 +198,13 @@ void UnitTracker::_setActive(gint active) if (found) { gchar *abbr; gtk_tree_model_get(GTK_TREE_MODEL(_store), &iter, COLUMN_STRING, &abbr, -1); - Inkscape::Util::Unit unit = unit_table.getUnit(abbr); + Inkscape::Util::Unit const *unit = unit_table.getUnit(abbr); found = gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(_store), &iter, NULL, active); if (found) { gchar *newAbbr; gtk_tree_model_get(GTK_TREE_MODEL(_store), &iter, COLUMN_STRING, &newAbbr, -1); - Inkscape::Util::Unit newUnit = unit_table.getUnit(newAbbr); + Inkscape::Util::Unit const *newUnit = unit_table.getUnit(newAbbr); _activeUnit = newUnit; if (_adjList) { @@ -230,7 +231,7 @@ void UnitTracker::_setActive(gint active) } } -void UnitTracker::_fixupAdjustments(Inkscape::Util::Unit const oldUnit, Inkscape::Util::Unit const newUnit) +void UnitTracker::_fixupAdjustments(Inkscape::Util::Unit const *oldUnit, Inkscape::Util::Unit const *newUnit) { _isUpdating = true; for ( GSList *cur = _adjList ; cur ; cur = g_slist_next(cur) ) { @@ -238,13 +239,13 @@ void UnitTracker::_fixupAdjustments(Inkscape::Util::Unit const oldUnit, Inkscape gdouble oldVal = gtk_adjustment_get_value(adj); gdouble val = oldVal; - if ( (oldUnit.type != Inkscape::Util::UNIT_TYPE_DIMENSIONLESS) - && (newUnit.type == Inkscape::Util::UNIT_TYPE_DIMENSIONLESS) ) + if ( (oldUnit->type != Inkscape::Util::UNIT_TYPE_DIMENSIONLESS) + && (newUnit->type == Inkscape::Util::UNIT_TYPE_DIMENSIONLESS) ) { - val = newUnit.factor * 100; + val = newUnit->factor * 100; _priorValues[adj] = Inkscape::Util::Quantity::convert(oldVal, oldUnit, "px"); - } else if ( (oldUnit.type == Inkscape::Util::UNIT_TYPE_DIMENSIONLESS) - && (newUnit.type != Inkscape::Util::UNIT_TYPE_DIMENSIONLESS) ) + } else if ( (oldUnit->type == Inkscape::Util::UNIT_TYPE_DIMENSIONLESS) + && (newUnit->type != Inkscape::Util::UNIT_TYPE_DIMENSIONLESS) ) { if (_priorValues.find(adj) != _priorValues.end()) { val = Inkscape::Util::Quantity::convert(_priorValues[adj], "px", newUnit); diff --git a/src/ui/widget/unit-tracker.h b/src/ui/widget/unit-tracker.h index 19559ae1c..61bb556ef 100644 --- a/src/ui/widget/unit-tracker.h +++ b/src/ui/widget/unit-tracker.h @@ -36,9 +36,9 @@ public: void setActiveUnit(Inkscape::Util::Unit const *unit); void setActiveUnitByAbbr(gchar const *abbr); - Inkscape::Util::Unit getActiveUnit() const; + Inkscape::Util::Unit const * getActiveUnit() const; - void addUnit(Inkscape::Util::Unit const &u); + void addUnit(Inkscape::Util::Unit const *u); void addAdjustment(GtkAdjustment *adj); void setFullVal(GtkAdjustment *adj, gdouble val); @@ -52,13 +52,13 @@ private: static void _actionFinalizedCB(gpointer data, GObject *where_the_object_was); static void _adjustmentFinalizedCB(gpointer data, GObject *where_the_object_was); void _setActive(gint index); - void _fixupAdjustments(Inkscape::Util::Unit const oldUnit, Inkscape::Util::Unit const newUnit); + void _fixupAdjustments(Inkscape::Util::Unit const *oldUnit, Inkscape::Util::Unit const *newUnit); void _actionFinalized(GObject *where_the_object_was); void _adjustmentFinalized(GObject *where_the_object_was); gint _active; bool _isUpdating; - Inkscape::Util::Unit _activeUnit; + Inkscape::Util::Unit const *_activeUnit; bool _activeUnitInitialized; GtkListStore *_store; GSList *_unitList; -- cgit v1.2.3 From d3522575b38c92296da452062d36d1048f18f859 Mon Sep 17 00:00:00 2001 From: buliabyak <> Date: Sun, 13 Oct 2013 14:13:28 -0300 Subject: we don't have nondocked dialogs, so rewrite restoring dialogs on startup via DialogManager; do not grab focus when restoring (bzr r12682) --- src/ui/dialog/dialog-manager.cpp | 9 +++++---- src/ui/dialog/dialog-manager.h | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/dialog-manager.cpp b/src/ui/dialog/dialog-manager.cpp index 17f6ae74d..6d32e3aa8 100644 --- a/src/ui/dialog/dialog-manager.cpp +++ b/src/ui/dialog/dialog-manager.cpp @@ -243,14 +243,14 @@ Dialog *DialogManager::getDialog(GQuark name) { /** * Shows the named dialog, creating it if necessary. */ -void DialogManager::showDialog(gchar const *name) { - showDialog(g_quark_from_string(name)); +void DialogManager::showDialog(gchar const *name, bool grabfocus) { + showDialog(g_quark_from_string(name), grabfocus); } /** * Shows the named dialog, creating it if necessary. */ -void DialogManager::showDialog(GQuark name) { +void DialogManager::showDialog(GQuark name, bool grabfocus) { bool wantTiming = Inkscape::Preferences::get()->getBool("/dialogs/debug/trackAppear", false); GTimer *timer = (wantTiming) ? g_timer_new() : 0; // if needed, must be created/started before getDialog() Dialog *dialog = getDialog(name); @@ -261,7 +261,8 @@ void DialogManager::showDialog(GQuark name) { tracker->setAutodelete(true); timer = 0; } - dialog->present(); + if (grabfocus) + dialog->present(); } if ( timer ) { diff --git a/src/ui/dialog/dialog-manager.h b/src/ui/dialog/dialog-manager.h index 33b166aa1..15573f760 100644 --- a/src/ui/dialog/dialog-manager.h +++ b/src/ui/dialog/dialog-manager.h @@ -44,8 +44,8 @@ public: void registerFactory(GQuark name, DialogFactory factory); Dialog *getDialog(gchar const* dlgName); Dialog *getDialog(GQuark dlgName); - void showDialog(gchar const *name); - void showDialog(GQuark name); + void showDialog(gchar const *name, bool grabfocus=true); + void showDialog(GQuark name, bool grabfocus=true); protected: DialogManager(DialogManager const &d); // no copy -- cgit v1.2.3