Refactor the highlight scrollbar painting

Scale the highlight on the handle according to the number of lines
visible on screen. In case when document has huge amount of lines
and only couple of lines are visible on screen, this
generates a nice magnification effect.

Change-Id: I43d7cce859cbc14da77272685a6f8d2350b41bb7
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Jarek Kobus
2017-11-29 18:25:01 +01:00
parent a2df3594c1
commit 80beedfa49
3 changed files with 221 additions and 90 deletions

View File

@@ -71,11 +71,14 @@ public:
QAbstractScrollArea *scrollArea() const;
void setScrollArea(QAbstractScrollArea *scrollArea);
float visibleRange() const;
void setVisibleRange(float visibleRange);
double lineHeight() const;
void setLineHeight(double lineHeight);
float rangeOffset() const;
void setRangeOffset(float offset);
double visibleRange() const;
void setVisibleRange(double visibleRange);
double margin() const;
void setMargin(double margin);
QHash<Id, QVector<Highlight>> highlights() const;
void addHighlight(Highlight highlight);
@@ -85,8 +88,9 @@ public:
private:
QHash<Id, QVector<Highlight> > m_highlights;
float m_visibleRange = 0.0;
float m_rangeOffset = 0.0;
double m_lineHeight = 0.0;
double m_visibleRange = 0.0; // in pixels
double m_margin = 0.0; // in pixels
QAbstractScrollArea *m_scrollArea = nullptr;
QPointer<HighlightScrollBarOverlay> m_overlay;
};