commit 32edb65985a8e63340c0421d76c00956bf846fd2
Author: Jean-Marc Lasgouttes <[email protected]>
Date: Sun Oct 25 23:58:58 2015 +0100
Avoid showing vertical scroll mark when not necessary
Now the mark if only shown when editable text is outside of the row.
Fixes bug #9807.
diff --git a/src/Row.cpp b/src/Row.cpp
index e3e8a34..5bdcbe0 100644
--- a/src/Row.cpp
+++ b/src/Row.cpp
@@ -259,6 +259,35 @@ ostream & operator<<(ostream & os, Row const & row)
}
+int Row::left_x() const
+{
+ double x = left_margin;
+ const_iterator const end = elements_.end();
+ const_iterator cit = elements_.begin();
+ while (cit != end && cit->isVirtual()) {
+ x += cit->full_width();
+ ++cit;
+ }
+ return int(x + 0.5);
+}
+
+
+int Row::right_x() const
+{
+ double x = dim_.wid;
+ const_iterator const begin = elements_.begin();
+ const_iterator cit = elements_.end();
+ while (cit != begin) {
+ --cit;
+ if (cit->isVirtual())
+ x -= cit->full_width();
+ else
+ break;
+ }
+ return int(x + 0.5);
+}
+
+
int Row::countSeparators() const
{
int n = 0;
diff --git a/src/Row.h b/src/Row.h
index a51e3ce..e03e4c9 100644
--- a/src/Row.h
+++ b/src/Row.h
@@ -170,6 +170,11 @@ public:
///
int descent() const { return dim_.des; }
+ /// The offset of the left-most cursor position on the row
+ int left_x() const;
+ /// The offset of the right-most cursor position on the row
+ int right_x() const;
+
// Return the number of separators in the row
int countSeparators() const;
// Set the extra spacing for every separator in STRING elements
diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp
index 15ecafe..73bd4f8 100644
--- a/src/TextMetrics.cpp
+++ b/src/TextMetrics.cpp
@@ -1956,8 +1956,8 @@ void TextMetrics::drawParagraph(PainterInfo & pi,
pit_type const pit, int const
rp.paintLast();
if (i == 0 && is_rtl)
rp.paintFirst();
- rp.paintTooLargeMarks(row_x < 0,
- row_x + row.width() > bv_->workWidth());
+ rp.paintTooLargeMarks(row_x < row.left_x(),
+ row_x + row.right_x() > bv_->workWidth());
y += row.descent();
// Restore full_repaint status.