From c1a3d5711d488de9243da009ebc79d38724cdd7d Mon Sep 17 00:00:00 2001 From: Jabiertxof Date: Sun, 26 Apr 2020 13:27:29 +0200 Subject: [PATCH] On X11 with document units diferent to px text BBOX background of lower elements render scaled When changing from one text item to start another the text render background scaled to document units This happends on start creation a new text element. Is very often and you need to zoom to fix. I test for example with a red circle in document ant click and type, but also happends in text in a frame in SVG2 mode To fix this I check the click is not in the begin (new element created) of layout. I remove 99 % of the issues You need to do a supper fast click type lots of times to reproduce again --- src/object/sp-text.cpp | 6 ++++++ src/ui/tools/text-tool.cpp | 29 ++++++++++++++++------------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/object/sp-text.cpp b/src/object/sp-text.cpp index addcd520df..97d8a0ab1a 100644 --- a/src/object/sp-text.cpp +++ b/src/object/sp-text.cpp @@ -394,6 +394,9 @@ void SPText::snappoints(std::vector &p, Inkscape:: void SPText::hide_shape_inside() { SPText *text = dynamic_cast(this); + if (text && !text->has_shape_inside()) { + return; + } SPStyle *item_style = this->style; if (item_style && text && item_style->shape_inside.set) { SPCSSAttr *css_unset = sp_css_attr_from_style(item_style, SP_STYLE_FLAG_IFSET); @@ -409,6 +412,9 @@ void SPText::hide_shape_inside() void SPText::show_shape_inside() { SPText *text = dynamic_cast(this); + if (text && !text->has_shape_inside()) { + return; + } if (text && css) { this->changeCSS(css, "style"); } diff --git a/src/ui/tools/text-tool.cpp b/src/ui/tools/text-tool.cpp index 7b75b2b807..c2b72f9ac1 100644 --- a/src/ui/tools/text-tool.cpp +++ b/src/ui/tools/text-tool.cpp @@ -272,19 +272,22 @@ bool TextTool::item_handler(SPItem* item, GdkEvent* event) { if (SP_IS_TEXT(item_ungrouped) || SP_IS_FLOWTEXT(item_ungrouped)) { desktop->getSelection()->set(item_ungrouped); if (this->text) { - // find out click point in document coordinates - Geom::Point p = desktop->w2d(Geom::Point(event->button.x, event->button.y)); - // set the cursor closest to that point - if (event->button.state & GDK_SHIFT_MASK) { - this->text_sel_start = old_start; - this->text_sel_end = sp_te_get_position_by_coords(this->text, p); - } else { - this->text_sel_start = this->text_sel_end = sp_te_get_position_by_coords(this->text, p); + Inkscape::Text::Layout const *layout = te_get_layout(this->text); + if (layout && this->text_sel_start != layout->begin()) { + // find out click point in document coordinates + Geom::Point p = desktop->w2d(Geom::Point(event->button.x, event->button.y)); + // set the cursor closest to that point + if (event->button.state & GDK_SHIFT_MASK) { + this->text_sel_start = old_start; + this->text_sel_end = sp_te_get_position_by_coords(this->text, p); + } else { + this->text_sel_start = this->text_sel_end = sp_te_get_position_by_coords(this->text, p); + } + // update display + sp_text_context_update_cursor(this); + sp_text_context_update_text_selection(this); + this->dragging = 1; } - // update display - sp_text_context_update_cursor(this); - sp_text_context_update_text_selection(this); - this->dragging = 1; } ret = TRUE; } @@ -368,8 +371,8 @@ static void sp_text_context_setup_text(TextTool *tc) Inkscape::GC::release(rtext); text_item->transform = SP_ITEM(ec->desktop->currentLayer())->i2doc_affine().inverse(); + text_item->doWriteTransform(text_item->transform); text_item->updateRepr(); - text_item->doWriteTransform(text_item->transform, nullptr, true); DocumentUndo::done(ec->desktop->getDocument(), SP_VERB_CONTEXT_TEXT, _("Create text")); } -- GitLab