Skip to content

Commit

Permalink
QDisasmView: gradient under the hint lines
Browse files Browse the repository at this point in the history
  • Loading branch information
nzeemin committed Jan 4, 2024
1 parent 53b6556 commit cb8c356
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions emulator/qdisasmview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,22 +402,24 @@ int QDisasmView::drawDisassemble(QPainter &painter, CProcessor *pProc, quint16 c
int cyLine = fontmetrics.lineSpacing();
m_cxDisasmBreakpointZone = cxChar * 2;
m_cyDisasmLine = cyLine;
int xHint = 52 * cxChar;
QColor colorBackground = palette().color(QPalette::Base);
QColor colorText = palette().color(QPalette::Text);
QColor colorPrev = Common_GetColorShifted(palette(), COLOR_PREVIOUS);
QColor colorChanged = Common_GetColorShifted(palette(), COLOR_VALUECHANGED);
QColor colorValue = Common_GetColorShifted(palette(), COLOR_VALUE);
QColor colorValueRom = Common_GetColorShifted(palette(), COLOR_VALUEROM);
QColor colorSubtitle = Common_GetColorShifted(palette(), COLOR_SUBTITLE);
QColor colorJump = Common_GetColorShifted(palette(), COLOR_JUMP);
QColor colorCurrent = palette().color(QPalette::Window);

quint16 proccurrent = pProc->GetPC();

// Draw current line background
if (m_SubtitleItems.isEmpty()) //NOTE: Subtitles can move lines down
{
int yCurrent = (proccurrent - (current - 5)) * cyLine + fontmetrics.descent();
QColor colorCurrent = palette().color(QPalette::Window);
painter.fillRect(0, yCurrent, this->width(), cyLine, colorCurrent);
painter.fillRect(0, yCurrent, xHint, cyLine, colorCurrent);
}

int y = cyLine;
Expand Down Expand Up @@ -514,11 +516,17 @@ int QDisasmView::drawDisassemble(QPainter &painter, CProcessor *pProc, quint16 c

if (address == proccurrent && *m_strDisasmHint != 0) // For current instruction, draw "Instruction Hints"
{
int cyHint = cyLine * (*m_strDisasmHint2 == 0 ? 1 : 2);
QLinearGradient gradient(xHint, 0, xHint + 24 * cxChar, 0);
gradient.setColorAt(0, colorCurrent);
gradient.setColorAt(1, colorBackground);
painter.fillRect(xHint, y - cyLine + fontmetrics.descent(), 24 * cxChar, cyHint, gradient);

QColor hintcolor = Common_GetColorShifted(palette(), isjump ? COLOR_JUMPHINT : COLOR_HINT);
painter.setPen(hintcolor);
painter.drawText(52 * cxChar, y, m_strDisasmHint);
painter.drawText(xHint, y, m_strDisasmHint);
if (*m_strDisasmHint2 != 0)
painter.drawText(52 * cxChar, y + cyLine, m_strDisasmHint2);
painter.drawText(xHint, y + cyLine, m_strDisasmHint2);
painter.setPen(colorText);
}
}
Expand Down

0 comments on commit cb8c356

Please sign in to comment.