diff options
| author | Shlomi Fish <shlomif@shlomifish.org> | 2016-10-08 15:39:06 +0000 |
|---|---|---|
| committer | Shlomi Fish <shlomif@shlomifish.org> | 2016-10-08 15:39:06 +0000 |
| commit | 2a5534a166dff8bfe6b56c8a3b496e989280fbd1 (patch) | |
| tree | dbd8330a6b3dcfb201ee751dbf283a17a41a2dfa /src/ui/tools | |
| parent | Merged. (diff) | |
| parent | [Bug #770681] KEY MAPPING: Comma and period hijacked by scaling. (diff) | |
| download | inkscape-2a5534a166dff8bfe6b56c8a3b496e989280fbd1.tar.gz inkscape-2a5534a166dff8bfe6b56c8a3b496e989280fbd1.zip | |
Merged.
(bzr r15100.1.31)
Diffstat (limited to 'src/ui/tools')
| -rw-r--r-- | src/ui/tools/eraser-tool.cpp | 12 | ||||
| -rw-r--r-- | src/ui/tools/measure-tool.cpp | 112 | ||||
| -rw-r--r-- | src/ui/tools/measure-tool.h | 9 | ||||
| -rw-r--r-- | src/ui/tools/node-tool.cpp | 11 | ||||
| -rw-r--r-- | src/ui/tools/select-tool.cpp | 32 |
5 files changed, 137 insertions, 39 deletions
diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index 38c72cac0..12686160b 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -766,9 +766,17 @@ void EraserTool::set_to_accumulated() { if (bbox && bbox->intersects(*eraserBbox)) { SPClipPath *clip_path = item->clip_ref->getObject(); if (clip_path) { - SPPath *clip_data = SP_PATH(clip_path->firstChild()); + std::vector<SPItem*> selected; + selected.push_back(SP_ITEM(clip_path->firstChild())); + std::vector<Inkscape::XML::Node*> to_select; + std::vector<SPItem*> items(selected); + sp_item_list_to_curves(items, selected, to_select); + Inkscape::XML::Node * clip_data = SP_ITEM(clip_path->firstChild())->getRepr(); + if (!clip_data && !to_select.empty()) { + clip_data = *(to_select.begin()); + } if (clip_data) { - Inkscape::XML::Node *dup_clip = SP_OBJECT(clip_data)->getRepr()->duplicate(xml_doc); + Inkscape::XML::Node *dup_clip = clip_data->duplicate(xml_doc); if (dup_clip) { SPItem * dup_clip_obj = SP_ITEM(item_repr->parent->appendChildRepr(dup_clip)); if (dup_clip_obj) { diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp index c941b9bee..f3185649b 100644 --- a/src/ui/tools/measure-tool.cpp +++ b/src/ui/tools/measure-tool.cpp @@ -378,6 +378,10 @@ MeasureTool::~MeasureTool() sp_canvas_item_destroy(measure_tmp_items[idx]); } measure_tmp_items.clear(); + for (size_t idx = 0; idx < measure_item.size(); ++idx) { + sp_canvas_item_destroy(measure_item[idx]); + } + measure_item.clear(); for (size_t idx = 0; idx < measure_phantom_items.size(); ++idx) { sp_canvas_item_destroy(measure_phantom_items[idx]); } @@ -591,6 +595,12 @@ bool MeasureTool::root_handler(GdkEvent* event) snap_manager.preSnap(scp); snap_manager.unSetup(); } + Geom::Point const motion_w(event->motion.x, event->motion.y); + if(event->motion.state & GDK_SHIFT_MASK) { + showInfoBox(motion_w, true); + } else { + showInfoBox(motion_w, false); + } } else { ret = TRUE; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -1111,6 +1121,108 @@ void MeasureTool::setMeasureCanvasControlLine(Geom::Point start, Geom::Point end } } +void MeasureTool::showItemInfoText(Geom::Point pos, gchar *measure_str, double fontsize) +{ + SPCanvasText *canvas_tooltip = sp_canvastext_new(desktop->getTempGroup(), + desktop, + pos, + measure_str); + sp_canvastext_set_fontsize(canvas_tooltip, fontsize); + canvas_tooltip->rgba = 0xffffffff; + canvas_tooltip->outline = false; + canvas_tooltip->background = true; + canvas_tooltip->anchor_position = TEXT_ANCHOR_LEFT; + canvas_tooltip->rgba_background = 0x00000099; + measure_item.push_back(SP_CANVAS_ITEM(canvas_tooltip)); + sp_canvas_item_show(SP_CANVAS_ITEM(canvas_tooltip)); +} + +void MeasureTool::showInfoBox(Geom::Point cursor, bool into_groups) +{ + SPDesktop *desktop = SP_ACTIVE_DESKTOP; + Inkscape::Util::Unit const * unit = desktop->getNamedView()->getDisplayUnit(); + for (size_t idx = 0; idx < measure_item.size(); ++idx) { + sp_canvas_item_destroy(measure_item[idx]); + } + measure_item.clear(); + + SPItem *newover = desktop->getItemAtPoint(cursor, into_groups); + if (newover) { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + double fontsize = prefs->getDouble("/tools/measure/fontsize", 10.0); + double scale = prefs->getDouble("/tools/measure/scale", 100.0) / 100.0; + int precision = prefs->getInt("/tools/measure/precision", 2); + Glib::ustring unit_name = prefs->getString("/tools/measure/unit"); + if (!unit_name.compare("")) { + unit_name = "px"; + } + Geom::Scale zoom = Geom::Scale(Inkscape::Util::Quantity::convert(desktop->current_zoom(), "px", unit->abbr)).inverse(); + if(newover != over){ + over = newover; + Preferences *prefs = Preferences::get(); + int prefs_bbox = prefs->getBool("/tools/bounding_box", 0); + SPItem::BBoxType bbox_type = !prefs_bbox ? SPItem::VISUAL_BBOX : SPItem::GEOMETRIC_BBOX; + Geom::OptRect bbox = over->bounds(bbox_type); + if (bbox) { + + item_width = Inkscape::Util::Quantity::convert((*bbox).width() * scale, unit->abbr, unit_name); + item_height = Inkscape::Util::Quantity::convert((*bbox).height() * scale, unit->abbr, unit_name); + item_x = Inkscape::Util::Quantity::convert((*bbox).left(), unit->abbr, unit_name); + Geom::Point y_point(0,Inkscape::Util::Quantity::convert((*bbox).bottom() * scale, unit->abbr, "px")); + y_point *= desktop->doc2dt(); + item_y = Inkscape::Util::Quantity::convert(y_point[Geom::Y] * scale, "px", unit_name); + if (SP_IS_SHAPE(over)) { + Geom::PathVector shape = SP_SHAPE(over)->getCurve()->get_pathvector(); + item_length = Geom::length(paths_to_pw(shape)); + item_length = Inkscape::Util::Quantity::convert(item_length * scale, unit->abbr, unit_name); + } + } + } + gchar *measure_str = NULL; + std::stringstream precision_str; + precision_str.imbue(std::locale::classic()); + double origin = Inkscape::Util::Quantity::convert(14, "px", unit->abbr); + Geom::Point rel_position = Geom::Point(origin, origin); + Geom::Point pos = desktop->w2d(cursor); + double gap = Inkscape::Util::Quantity::convert(7 + fontsize, "px", unit->abbr); + if (SP_IS_SHAPE(over)) { + precision_str << _("Length") << ": %." << precision << "f %s"; + measure_str = g_strdup_printf(precision_str.str().c_str(), item_length, unit_name.c_str()); + precision_str.str(""); + showItemInfoText(pos + (rel_position * zoom),measure_str,fontsize); + rel_position = Geom::Point(rel_position[Geom::X], rel_position[Geom::Y] + gap); + } else if (SP_IS_GROUP(over)) { + measure_str = _("Shift to measure into group"); + showItemInfoText(pos + (rel_position * zoom),measure_str,fontsize); + rel_position = Geom::Point(rel_position[Geom::X], rel_position[Geom::Y] + gap); + } + + precision_str << "Y: %." << precision << "f %s"; + measure_str = g_strdup_printf(precision_str.str().c_str(), item_y, unit_name.c_str()); + precision_str.str(""); + showItemInfoText(pos + (rel_position * zoom),measure_str,fontsize); + rel_position = Geom::Point(rel_position[Geom::X], rel_position[Geom::Y] + gap); + + precision_str << "X: %." << precision << "f %s"; + measure_str = g_strdup_printf(precision_str.str().c_str(), item_x, unit_name.c_str()); + precision_str.str(""); + showItemInfoText(pos + (rel_position * zoom),measure_str,fontsize); + rel_position = Geom::Point(rel_position[Geom::X], rel_position[Geom::Y] + gap); + + precision_str << _("Height") << ": %." << precision << "f %s"; + measure_str = g_strdup_printf(precision_str.str().c_str(), item_height, unit_name.c_str()); + precision_str.str(""); + showItemInfoText(pos + (rel_position * zoom),measure_str,fontsize); + rel_position = Geom::Point(rel_position[Geom::X], rel_position[Geom::Y] + gap); + + precision_str << _("Width") << ": %." << precision << "f %s"; + measure_str = g_strdup_printf(precision_str.str().c_str(), item_width, unit_name.c_str()); + precision_str.str(""); + showItemInfoText(pos + (rel_position * zoom),measure_str,fontsize); + g_free(measure_str); + } +} + void MeasureTool::showCanvasItems(bool to_guides, bool to_item, bool to_phantom, Inkscape::XML::Node *measure_repr) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; diff --git a/src/ui/tools/measure-tool.h b/src/ui/tools/measure-tool.h index 14fc9f81a..42122dca1 100644 --- a/src/ui/tools/measure-tool.h +++ b/src/ui/tools/measure-tool.h @@ -54,6 +54,8 @@ public: virtual void setMarker(bool isStart); virtual const std::string& getPrefsPath(); Geom::Point readMeasurePoint(bool is_start); + void showInfoBox(Geom::Point cursor, bool into_groups); + void showItemInfoText(Geom::Point pos, gchar *measure_str, double fontsize); void writeMeasurePoint(Geom::Point point, bool is_start); void setGuide(Geom::Point origin, double angle, const char *label); void setPoint(Geom::Point origin, Inkscape::XML::Node *measure_repr); @@ -77,6 +79,13 @@ private: Geom::Point end_p; std::vector<SPCanvasItem *> measure_tmp_items; std::vector<SPCanvasItem *> measure_phantom_items; + std::vector<SPCanvasItem *> measure_item; + double item_width; + double item_height; + double item_x; + double item_y; + double item_length; + SPItem *over; sigc::connection _knot_start_moved_connection; sigc::connection _knot_start_ungrabbed_connection; sigc::connection _knot_start_click_connection; diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index 2bd4fdea3..f3679b40f 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -285,13 +285,11 @@ void NodeTool::update_helperpath () { if (SP_IS_LPE_ITEM(selection->singleItem())) { Inkscape::LivePathEffect::Effect *lpe = SP_LPE_ITEM(selection->singleItem())->getCurrentLPE(); if (lpe && lpe->isVisible()/* && lpe->showOrigPath()*/) { - Inkscape::UI::ControlPointSelection::Set &selectionNodes = _selected_nodes->allPoints(); + Inkscape::UI::ControlPointSelection *selectionNodes = _selected_nodes; std::vector<Geom::Point> selectedNodesPositions; - for (Inkscape::UI::ControlPointSelection::Set::iterator i = selectionNodes.begin(); i != selectionNodes.end(); ++i) { - if ((*i)->selected()) { - Inkscape::UI::Node *n = dynamic_cast<Inkscape::UI::Node *>(*i); - selectedNodesPositions.push_back(n->position()); - } + for (Inkscape::UI::ControlPointSelection::iterator i = selectionNodes->begin(); i != selectionNodes->end(); ++i) { + Inkscape::UI::Node *n = dynamic_cast<Inkscape::UI::Node *>(*i); + selectedNodesPositions.push_back(n->position()); } lpe->setSelectedNodePoints(selectedNodesPositions); lpe->setCurrentZoom(this->desktop->current_zoom()); @@ -470,6 +468,7 @@ bool NodeTool::root_handler(GdkEvent* event) { switch (event->type) { case GDK_MOTION_NOTIFY: { + update_helperpath(); combine_motion_events(desktop->canvas, event->motion, 0); SPItem *over_item = sp_event_context_find_item (desktop, event_point(event->button), FALSE, TRUE); diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp index 86a2dbed3..0cdeda0b6 100644 --- a/src/ui/tools/select-tool.cpp +++ b/src/ui/tools/select-tool.cpp @@ -1045,37 +1045,7 @@ bool SelectTool::root_handler(GdkEvent* event) { ret = TRUE; break; - - case GDK_KEY_less: - case GDK_KEY_comma: - if (MOD__ALT(event)) { - gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask - sp_selection_scale_screen(selection, -2*mul); - } else if (MOD__CTRL(event)) { - sp_selection_scale_times(selection, 0.5); - } else { - gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask - sp_selection_scale(selection, -offset*mul); - } - - ret = TRUE; - break; - - case GDK_KEY_greater: - case GDK_KEY_period: - if (MOD__ALT(event)) { - gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask - sp_selection_scale_screen(selection, 2*mul); - } else if (MOD__CTRL(event)) { - sp_selection_scale_times(selection, 2); - } else { - gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask - sp_selection_scale(selection, offset*mul); - } - - ret = TRUE; - break; - + case GDK_KEY_Return: if (MOD__CTRL_ONLY(event)) { if (selection->singleItem()) { |
