diff options
| author | Jabiertxof <jabier.arraiza@marker.es> | 2019-10-30 09:37:37 +0000 |
|---|---|---|
| committer | Jabiertxof <jabier.arraiza@marker.es> | 2019-10-30 09:37:37 +0000 |
| commit | 4f5842a050121a1d6ef71c3840b7c0815f485df0 (patch) | |
| tree | ed017e564c494ca0fbc5c05c460b3253a86bce04 /src | |
| parent | CMake/MSYS2: minor dependency update for lxml (diff) | |
| download | inkscape-4f5842a050121a1d6ef71c3840b7c0815f485df0.tar.gz inkscape-4f5842a050121a1d6ef71c3840b7c0815f485df0.zip | |
Improve picking selecton on text
Diffstat (limited to 'src')
| -rw-r--r-- | src/display/drawing-group.cpp | 8 | ||||
| -rw-r--r-- | src/display/drawing-item.cpp | 9 | ||||
| -rw-r--r-- | src/display/drawing-text.cpp | 18 | ||||
| -rw-r--r-- | src/display/drawing-text.h | 3 |
4 files changed, 22 insertions, 16 deletions
diff --git a/src/display/drawing-group.cpp b/src/display/drawing-group.cpp index cd669c6f1..397b30c67 100644 --- a/src/display/drawing-group.cpp +++ b/src/display/drawing-group.cpp @@ -130,15 +130,7 @@ DrawingGroup::_clipItem(DrawingContext &dc, Geom::IntRect const &area) DrawingItem * DrawingGroup::_pickItem(Geom::Point const &p, double delta, unsigned flags) { - bool outline = _drawing.outline() || _drawing.getOutlineSensitive(); for (auto & i : _children) { - if ((dynamic_cast<DrawingText *>(&i) != nullptr) && !outline && !(flags & PICK_AS_CLIP) && _drawbox) { - Geom::Rect expanded = *_drawbox; - expanded.expandBy(delta); - if (expanded.contains(p)) { - return this; - } - } DrawingItem *picked = i.pick(p, delta, flags); if (picked) { return _pick_children ? picked : this; diff --git a/src/display/drawing-item.cpp b/src/display/drawing-item.cpp index 132c070b0..de2014e52 100644 --- a/src/display/drawing-item.cpp +++ b/src/display/drawing-item.cpp @@ -12,12 +12,13 @@ #include <climits> -#include "display/drawing.h" #include "display/drawing-context.h" -#include "display/drawing-item.h" #include "display/drawing-group.h" +#include "display/drawing-item.h" #include "display/drawing-pattern.h" #include "display/drawing-surface.h" +#include "display/drawing-text.h" +#include "display/drawing.h" #include "nr-filter.h" #include "preferences.h" #include "style.h" @@ -997,6 +998,10 @@ DrawingItem::pick(Geom::Point const &p, double delta, unsigned flags) Geom::Rect expanded = *box; expanded.expandBy(delta); + DrawingGlyphs *dglyps = dynamic_cast<DrawingGlyphs *>(this); + if (dglyps && !(flags & PICK_AS_CLIP) && _drawbox) { + expanded = (Geom::Rect)dglyps->getPickBox(); + } if (expanded.contains(p)) { return _pickItem(p, delta, flags); diff --git a/src/display/drawing-text.cpp b/src/display/drawing-text.cpp index 46d05d399..4eb4224d5 100644 --- a/src/display/drawing-text.cpp +++ b/src/display/drawing-text.cpp @@ -123,13 +123,21 @@ unsigned DrawingGlyphs::_updateItem(Geom::IntRect const &/*area*/, UpdateContext Geom::OptRect pb; if (_drawable) { - Geom::PathVector *glyphv = _font->PathVector(42); //we fix to "X" char to allow always a reasonable bbox - if (glyphv && !glyphv->empty()) { - pb = bounds_exact_transformed(*glyphv, ctx.ctm); - pb->expandBy(pb->height()/10.0); //we scale a bit the area to in between char gaps mainly + Geom::PathVector *glyphv = _font->PathVector(_glyph); + if (glyphv && !glyphv->empty()) { + pb = bounds_exact_transformed(*glyphv, ctx.ctm); + } + glyphv = _font->PathVector(42); + if (glyphv && !glyphv->empty()) { + if (pb) { + pb.unionWith(bounds_exact_transformed(*glyphv, ctx.ctm)); + } else { + pb = bounds_exact_transformed(*glyphv, ctx.ctm); + } + pb.expandTo(Geom::Point((*pb).right() + (_width * ctx.ctm.descrim()), (*pb).bottom())); } } - if(!pb){ // Fallback, spaces mostly, this never happendd with fixed gliph + if (!pb) { // Fallback Geom::Rect pbigbox(Geom::Point(0.0, _asc*scale_bigbox*0.66),Geom::Point(_width*scale_bigbox, 0.0)); pb = pbigbox * ctx.ctm; } diff --git a/src/display/drawing-text.h b/src/display/drawing-text.h index d557cad77..084c79392 100644 --- a/src/display/drawing-text.h +++ b/src/display/drawing-text.h @@ -30,8 +30,9 @@ public: void setGlyph(font_instance *font, int glyph, Geom::Affine const &trans); void setStyle(SPStyle *style, SPStyle *context_style = nullptr) override; // Not to be used + Geom::IntRect getPickBox() const { return _pick_bbox; }; -protected: + protected: unsigned _updateItem(Geom::IntRect const &area, UpdateContext const &ctx, unsigned flags, unsigned reset) override; DrawingItem *_pickItem(Geom::Point const &p, double delta, unsigned flags) override; |
