| 75 | } |
| 76 | |
| 77 | void ClientGateLevelView::paintEvent(QPaintEvent*) |
| 78 | { |
| 79 | QPainter p(this); |
| 80 | p.setRenderHint(QPainter::Antialiasing, true); |
| 81 | |
| 82 | const QRectF full = rect(); |
| 83 | p.fillRect(full, kBgColor()); |
| 84 | |
| 85 | // Plot region: inset the left gutter for dB labels and the right |
| 86 | // strip for the peak bar. |
| 87 | const QRectF plot(full.left() + kGutterPx, full.top() + 4, |
| 88 | full.width() - kGutterPx - kPeakBarPx - 4, |
| 89 | full.height() - 8); |
| 90 | |
| 91 | // Frame the plot. |
| 92 | p.setPen(QPen(kFrameColor(), 1.0)); |
| 93 | p.drawRect(plot); |
| 94 | |
| 95 | // Horizontal grid + labels. |
| 96 | QFont f = p.font(); |
| 97 | f.setPixelSize(9); |
| 98 | p.setFont(f); |
| 99 | for (float db : kTicks) { |
| 100 | const float y = dbToY(db); |
| 101 | p.setPen(QPen(kGridColor(), 1.0)); |
| 102 | p.drawLine(QPointF(plot.left(), y), QPointF(plot.right(), y)); |
| 103 | p.setPen(kAxisLabel()); |
| 104 | QString s = (db > 0.0f ? "+" : "") + QString::number(static_cast<int>(db)); |
| 105 | p.drawText(QPointF(full.left() + 2.0f, y + 3.0f), s); |
| 106 | } |
| 107 | |
| 108 | // History plot — newest sample at the right edge, older scrolling |
| 109 | // left. Draw order (bottom to top visually so later strokes |
| 110 | // paint over earlier ones cleanly): |
| 111 | // 1. Audible band — from plot.bottom up to (input + grDb), |
| 112 | // filled amber. Represents the portion of the signal that |
| 113 | // actually makes it through the gate. |
| 114 | // 2. Gated band — from (input + grDb) up to input level, |
| 115 | // filled dark gray. Represents the gain being "taken away" |
| 116 | // from the input. |
| 117 | // 3. Input top-edge outline in bright white so the original |
| 118 | // signal envelope stays legible on top of the fills. |
| 119 | p.save(); |
| 120 | p.setClipRect(plot); |
| 121 | |
| 122 | const float colW = plot.width() / float(kHistoryCount); |
| 123 | |
| 124 | // ── Audible band (amber) ─────────────────────────────────── |
| 125 | QPainterPath audiblePath; |
| 126 | for (int i = 0; i < kHistoryCount; ++i) { |
| 127 | const int idx = (m_writeIdx + i) % kHistoryCount; |
| 128 | const Sample& s = m_history[idx]; |
| 129 | const float x = plot.right() - (kHistoryCount - 1 - i) * colW; |
| 130 | // When gate is fully open, grDb = 0 → yGr = yIn; the amber |
| 131 | // band touches the input outline. When the gate closes, |
| 132 | // grDb is negative and yGr sits lower → amber band shrinks, |
| 133 | // revealing the gray gated band above it. |
| 134 | const float yGr = dbToY(s.inputDb + s.grDb); |
nothing calls this directly
no test coverage detected