MCPcopy Create free account
hub / github.com/aethersdr/AetherSDR / paintEvent

Method paintEvent

src/gui/ClientEqOutputFader.cpp:191–287  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

189}
190
191void ClientEqOutputFader::paintEvent(QPaintEvent*)
192{
193 QPainter p(this);
194 p.setRenderHint(QPainter::Antialiasing, false);
195 p.setRenderHint(QPainter::TextAntialiasing, true);
196
197 // The strip lives between the OUT label at the top and the value
198 // label at the bottom — paintEvent receives the full widget rect and
199 // we carve out a fixed vertical band in the middle.
200 const int topLabelH = 16;
201 const int botLabelH = 14;
202 const int stripTop = topLabelH + kStripTopPad;
203 const int stripBot = height() - botLabelH - kStripBottomPad;
204 m_stripTop = stripTop;
205 m_stripH = std::max(1, stripBot - stripTop);
206
207 const int barLeft = kLabelColW + kGap + kHandleOverhang;
208 const QRect barR(barLeft, stripTop, kBarW, m_stripH);
209
210 // Background for the bar — dark inset.
211 p.fillRect(barR, QColor("#06111c"));
212
213 // Level fill — gradient bottom green → top red, clipped to the level
214 // height derived from the smoothed peak.
215 const float peakNorm = std::clamp(
216 (m_smoothedPeak - kMeterMinDb) / (kMeterMaxDb - kMeterMinDb),
217 0.0f, 1.0f);
218 const int fillH = static_cast<int>(peakNorm * m_stripH);
219 if (fillH > 0) {
220 const QRect fill(barR.x(), barR.y() + m_stripH - fillH,
221 kBarW, fillH);
222 QLinearGradient grad(0, barR.y() + m_stripH, 0, barR.y());
223 grad.setColorAt(0.0, QColor("#2f9e6a")); // green bottom
224 grad.setColorAt(0.55, QColor("#6cc56a")); // lime
225 grad.setColorAt(0.80, QColor("#e8b94c")); // amber
226 grad.setColorAt(0.95, QColor("#e8553c")); // red top
227 grad.setColorAt(1.0, QColor("#f2362a"));
228 p.fillRect(fill, grad);
229 }
230
231 // Bar outline.
232 p.setPen(QPen(QColor("#243a4e"), 1));
233 p.setBrush(Qt::NoBrush);
234 p.drawRect(barR.adjusted(0, 0, -1, -1));
235
236 // dB scale labels + tick marks on the left side.
237 QFont f = p.font();
238 f.setPixelSize(8);
239 p.setFont(f);
240 const QFontMetrics fm(f);
241 const int textRight = kLabelColW - 2;
242
243 struct Tick { float db; const char* label; };
244 static constexpr Tick kTicks[] = {
245 { 0.0f, "0" },
246 { -6.0f, "-6" },
247 { -12.0f, "-12" },
248 { -20.0f, "-20" },

Callers

nothing calls this directly

Calls 3

fontMethod · 0.80
drawTextMethod · 0.80
linearToDbFunction · 0.70

Tested by

no test coverage detected