Fix arrow offset when scrolling with arrows or zooming in. (#1677)

This commit is contained in:
karliss 2019-07-20 16:10:49 +03:00 committed by GitHub
parent cbdc4b70e1
commit 239fde50be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -379,18 +379,21 @@ void DisassemblyWidget::zoomIn()
{ {
mDisasTextEdit->zoomIn(); mDisasTextEdit->zoomIn();
updateMaxLines(); updateMaxLines();
leftPanel->update();
} }
void DisassemblyWidget::zoomOut() void DisassemblyWidget::zoomOut()
{ {
mDisasTextEdit->zoomOut(); mDisasTextEdit->zoomOut();
updateMaxLines(); updateMaxLines();
leftPanel->update();
} }
void DisassemblyWidget::zoomReset() void DisassemblyWidget::zoomReset()
{ {
setupFonts(); setupFonts();
updateMaxLines(); updateMaxLines();
leftPanel->update();
} }
void DisassemblyWidget::highlightCurrentLine() void DisassemblyWidget::highlightCurrentLine()
@ -746,6 +749,12 @@ void DisassemblyScrollArea::resetScrollBars()
verticalScrollBar()->blockSignals(false); verticalScrollBar()->blockSignals(false);
} }
qreal DisassemblyTextEdit::textOffset() const
{
return (blockBoundingGeometry(document()->begin()).topLeft() +
contentOffset()).y();
}
bool DisassemblyTextEdit::viewportEvent(QEvent *event) bool DisassemblyTextEdit::viewportEvent(QEvent *event)
{ {
switch (event->type()) { switch (event->type()) {
@ -826,7 +835,7 @@ void DisassemblyLeftPanel::paintEvent(QPaintEvent *event)
constexpr int arrowWidth = 5; constexpr int arrowWidth = 5;
int rightOffset = size().rwidth(); int rightOffset = size().rwidth();
auto tEdit = qobject_cast<DisassemblyTextEdit*>(disas->getTextWidget()); auto tEdit = qobject_cast<DisassemblyTextEdit*>(disas->getTextWidget());
int topOffset = int(tEdit->document()->documentMargin() + tEdit->contentsMargins().top()); int topOffset = int(tEdit->contentsMargins().top() + tEdit->textOffset());
int lineHeight = disas->getFontMetrics().height(); int lineHeight = disas->getFontMetrics().height();
QColor arrowColorDown = ConfigColor("flow"); QColor arrowColorDown = ConfigColor("flow");
QColor arrowColorUp = ConfigColor("cflow"); QColor arrowColorUp = ConfigColor("cflow");

View File

@ -125,6 +125,7 @@ public:
this->lockScroll = lock; this->lockScroll = lock;
} }
qreal textOffset() const;
protected: protected:
bool viewportEvent(QEvent *event) override; bool viewportEvent(QEvent *event) override;
void scrollContentsBy(int dx, int dy) override; void scrollContentsBy(int dx, int dy) override;