diff --git a/src/insets/InsetCaption.cpp b/src/insets/InsetCaption.cpp index f97fadef60..981ffa814f 100644 --- a/src/insets/InsetCaption.cpp +++ b/src/insets/InsetCaption.cpp @@ -82,7 +82,8 @@ void InsetCaption::cursorPos(BufferView const & bv, CursorSlice const & sl, bool boundary, int & x, int & y) const { InsetText::cursorPos(bv, sl, boundary, x, y); - x += labelwidth_; + if (!rtl_) + x += labelwidth_; } @@ -133,6 +134,8 @@ void InsetCaption::drawBackground(PainterInfo & pi, int x, int y) const TextMetrics & tm = pi.base.bv->textMetrics(&text()); int const h = tm.height() + topOffset(pi.base.bv) + bottomOffset(pi.base.bv); int const yy = y - topOffset(pi.base.bv) - tm.ascent(); + if (rtl_) + x+= + dimension(*pi.base.bv).wid - labelwidth_; pi.pain.fillRectangle(x, yy, labelwidth_, h, pi.backgroundColor(this)); } @@ -147,6 +150,7 @@ void InsetCaption::draw(PainterInfo & pi, int x, int y) const // Answer: the text inset (in buffer_funcs.cpp: setCaption). + rtl_ = !pi.ltr_pos; FontInfo tmpfont = pi.base.font; pi.base.font = pi.base.bv->buffer().params().getFont().fontInfo(); pi.base.font.setColor(pi.textColor(pi.base.font.color()).baseColor); @@ -154,9 +158,15 @@ void InsetCaption::draw(PainterInfo & pi, int x, int y) const pi.base.font.setStrikeout(FONT_ON); else if (isChanged() && lyxrc.ct_additions_underlined) pi.base.font.setUnderbar(FONT_ON); - int const xx = x + leftOffset(pi.base.bv); - pi.pain.text(xx, y, full_label_, pi.base.font); - InsetText::draw(pi, x + labelwidth_, y); + int const lo = leftOffset(pi.base.bv); + if (rtl_) { + InsetText::draw(pi, x, y); + pi.pain.text(x + dimension(*pi.base.bv).wid - labelwidth_ + lo, + y, full_label_, pi.base.font); + } else { + pi.pain.text(x + lo, y, full_label_, pi.base.font); + InsetText::draw(pi, x + labelwidth_, y); + } pi.base.font = tmpfont; } diff --git a/src/insets/InsetCaption.h b/src/insets/InsetCaption.h index c5a7d086c7..ed6dbbb50b 100644 --- a/src/insets/InsetCaption.h +++ b/src/insets/InsetCaption.h @@ -96,6 +96,8 @@ private: /// mutable int labelwidth_ = 0; /// + mutable bool rtl_ = false; + /// std::string floattype_; /// bool is_subfloat_ = false;