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();
updateMaxLines();
leftPanel->update();
}
void DisassemblyWidget::zoomOut()
{
mDisasTextEdit->zoomOut();
updateMaxLines();
leftPanel->update();
}
void DisassemblyWidget::zoomReset()
{
setupFonts();
updateMaxLines();
leftPanel->update();
}
void DisassemblyWidget::highlightCurrentLine()
@ -746,6 +749,12 @@ void DisassemblyScrollArea::resetScrollBars()
verticalScrollBar()->blockSignals(false);
}
qreal DisassemblyTextEdit::textOffset() const
{
return (blockBoundingGeometry(document()->begin()).topLeft() +
contentOffset()).y();
}
bool DisassemblyTextEdit::viewportEvent(QEvent *event)
{
switch (event->type()) {
@ -826,7 +835,7 @@ void DisassemblyLeftPanel::paintEvent(QPaintEvent *event)
constexpr int arrowWidth = 5;
int rightOffset = size().rwidth();
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();
QColor arrowColorDown = ConfigColor("flow");
QColor arrowColorUp = ConfigColor("cflow");

View File

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