| 231 | } |
| 232 | |
| 233 | void ModuleWidget::draw(const DrawArgs& args) { |
| 234 | nvgScissor(args.vg, RECT_ARGS(args.clipBox)); |
| 235 | |
| 236 | if (module && module->isBypassed()) { |
| 237 | nvgAlpha(args.vg, 0.33); |
| 238 | } |
| 239 | |
| 240 | Widget::draw(args); |
| 241 | |
| 242 | // Meter |
| 243 | if (module && settings::cpuMeter) { |
| 244 | float sampleRate = APP->engine->getSampleRate(); |
| 245 | const float* meterBuffer = module->meterBuffer(); |
| 246 | int meterLength = module->meterLength(); |
| 247 | int meterIndex = module->meterIndex(); |
| 248 | |
| 249 | // // Text background |
| 250 | // nvgBeginPath(args.vg); |
| 251 | // nvgRect(args.vg, 0.0, box.size.y - infoHeight, box.size.x, infoHeight); |
| 252 | // nvgFillColor(args.vg, nvgRGBAf(0, 0, 0, 0.75)); |
| 253 | // nvgFill(args.vg); |
| 254 | |
| 255 | // Draw time plot |
| 256 | const float plotHeight = box.size.y - BND_WIDGET_HEIGHT; |
| 257 | nvgBeginPath(args.vg); |
| 258 | nvgMoveTo(args.vg, 0.0, plotHeight); |
| 259 | math::Vec p1; |
| 260 | for (int i = 0; i < meterLength; i++) { |
| 261 | int index = math::eucMod(meterIndex + i + 1, meterLength); |
| 262 | float meter = math::clamp(meterBuffer[index] * sampleRate, 0.f, 1.f); |
| 263 | meter = std::max(0.f, meter); |
| 264 | math::Vec p; |
| 265 | p.x = (float) i / (meterLength - 1) * box.size.x; |
| 266 | p.y = (1.f - meter) * plotHeight; |
| 267 | if (i == 0) { |
| 268 | nvgLineTo(args.vg, VEC_ARGS(p)); |
| 269 | } |
| 270 | else { |
| 271 | math::Vec p2 = p; |
| 272 | p2.x -= 0.5f / (meterLength - 1) * box.size.x; |
| 273 | nvgBezierTo(args.vg, VEC_ARGS(p1), VEC_ARGS(p2), VEC_ARGS(p)); |
| 274 | } |
| 275 | p1 = p; |
| 276 | p1.x += 0.5f / (meterLength - 1) * box.size.x; |
| 277 | } |
| 278 | nvgLineTo(args.vg, box.size.x, plotHeight); |
| 279 | nvgClosePath(args.vg); |
| 280 | NVGcolor color = componentlibrary::SCHEME_ORANGE; |
| 281 | nvgFillColor(args.vg, color::alpha(color, 0.75)); |
| 282 | nvgFill(args.vg); |
| 283 | nvgStrokeWidth(args.vg, 2.0); |
| 284 | nvgStrokeColor(args.vg, color); |
| 285 | nvgStroke(args.vg); |
| 286 | |
| 287 | // Text background |
| 288 | bndMenuBackground(args.vg, 0.0, plotHeight, box.size.x, BND_WIDGET_HEIGHT, BND_CORNER_ALL); |
| 289 | |
| 290 | // Text |
nothing calls this directly
no test coverage detected