Here we go!
| 390 | |
| 391 | // Here we go! |
| 392 | void DisassemblyView::paintEvent(QPaintEvent* event) |
| 393 | { |
| 394 | QPainter painter(this); |
| 395 | |
| 396 | const u32 w = painter.device()->width() - 1; |
| 397 | const u32 h = painter.device()->height() - 1; |
| 398 | |
| 399 | // Get the current font size |
| 400 | const QFontMetrics fm = painter.fontMetrics(); |
| 401 | |
| 402 | // Get the row height |
| 403 | m_rowHeight = fm.height() + 2; |
| 404 | |
| 405 | // Find the amount of visible disassembly rows. Minus 1 to not count column title row. |
| 406 | m_visibleRows = h / m_rowHeight - 1; |
| 407 | |
| 408 | m_disassemblyManager.analyze(m_visibleStart, m_disassemblyManager.getNthNextAddress(m_visibleStart, m_visibleRows) - m_visibleStart); |
| 409 | |
| 410 | const u32 curPC = cpu().getPC(); // Get the PC here, because it'll change when we are drawing and make it seem like there are two PCs |
| 411 | |
| 412 | // Format and draw title line on first row |
| 413 | const QString titleLineString = GetDisassemblyTitleLine(); |
| 414 | const QColor titleLineColor = GetDisassemblyTitleLineColor(); |
| 415 | painter.fillRect(0, 0 * m_rowHeight, w, m_rowHeight, titleLineColor); |
| 416 | painter.drawText(2, 0 * m_rowHeight, w, m_rowHeight, Qt::AlignLeft, titleLineString); |
| 417 | |
| 418 | // Prepare to draw the disassembly rows |
| 419 | bool inSelectionBlock = false; |
| 420 | bool alternate = m_visibleStart % 8; |
| 421 | |
| 422 | // Draw visible disassembly rows |
| 423 | for (u32 i = 0; i < m_visibleRows + 1; i++) |
| 424 | { |
| 425 | // Address of instruction being displayed on row |
| 426 | const u32 rowAddress = (i * 4) + m_visibleStart; |
| 427 | |
| 428 | // Row will be drawn at row index+1 to offset past title row |
| 429 | const u32 rowIndex = (i + 1) * m_rowHeight; |
| 430 | |
| 431 | // Row backgrounds |
| 432 | if (inSelectionBlock || (m_selectedAddressStart <= rowAddress && rowAddress <= m_selectedAddressEnd)) |
| 433 | { |
| 434 | painter.fillRect(0, rowIndex, w, m_rowHeight, this->palette().highlight()); |
| 435 | inSelectionBlock = m_selectedAddressEnd != rowAddress; |
| 436 | } |
| 437 | else |
| 438 | { |
| 439 | painter.fillRect(0, rowIndex, w, m_rowHeight, alternate ? this->palette().base() : this->palette().alternateBase()); |
| 440 | } |
| 441 | |
| 442 | // Row text |
| 443 | painter.setPen(GetAddressFunctionColor(rowAddress)); |
| 444 | QString lineString = DisassemblyStringFromAddress(rowAddress, painter.font(), curPC, rowAddress == m_selectedAddressStart); |
| 445 | |
| 446 | painter.drawText(2, rowIndex, w, m_rowHeight, Qt::AlignLeft, lineString); |
| 447 | |
| 448 | // Breakpoint marker |
| 449 | bool enabled; |
nothing calls this directly
no test coverage detected