| 138 | } |
| 139 | |
| 140 | void RackWidget::draw(const DrawArgs& args) { |
| 141 | float b = settings::rackBrightness; |
| 142 | |
| 143 | // Draw rack rails and modules |
| 144 | Widget::draw(args); |
| 145 | |
| 146 | // Draw translucent dark rectangle |
| 147 | if (b < 1.f) { |
| 148 | // Get zoom level |
| 149 | float t[6]; |
| 150 | nvgCurrentTransform(args.vg, t); |
| 151 | float zoom = t[3]; |
| 152 | // Draw mouse spotlight |
| 153 | nvgBeginPath(args.vg); |
| 154 | nvgRect(args.vg, 0.0, 0.0, VEC_ARGS(box.size)); |
| 155 | nvgFillPaint(args.vg, nvgRadialGradient(args.vg, |
| 156 | VEC_ARGS(internal->mousePos), 0.0, |
| 157 | settings::spotlightRadius / zoom, |
| 158 | nvgRGBAf(0, 0, 0, 1.f - b - settings::spotlightBrightness), |
| 159 | nvgRGBAf(0, 0, 0, 1.f - b))); |
| 160 | nvgFill(args.vg); |
| 161 | } |
| 162 | |
| 163 | // Draw lights and halos |
| 164 | Widget::drawLayer(args, 1); |
| 165 | |
| 166 | // Tint all draws after this point |
| 167 | nvgGlobalTint(args.vg, nvgRGBAf(b, b, b, 1)); |
| 168 | |
| 169 | // Draw plugs |
| 170 | Widget::drawLayer(args, 2); |
| 171 | |
| 172 | // Draw cables |
| 173 | Widget::drawLayer(args, 3); |
| 174 | |
| 175 | // Draw selection rectangle |
| 176 | if (internal->selecting) { |
| 177 | nvgBeginPath(args.vg); |
| 178 | math::Rect selectionBox = math::Rect::fromCorners(internal->selectionStart, internal->selectionEnd); |
| 179 | nvgRect(args.vg, RECT_ARGS(selectionBox)); |
| 180 | nvgFillColor(args.vg, nvgRGBAf(1, 0, 0, 0.25)); |
| 181 | nvgFill(args.vg); |
| 182 | nvgStrokeWidth(args.vg, 2.0); |
| 183 | nvgStrokeColor(args.vg, nvgRGBAf(1, 0, 0, 0.5)); |
| 184 | nvgStroke(args.vg); |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | void RackWidget::onHover(const HoverEvent& e) { |
| 189 | // Set before calling children's onHover() |
nothing calls this directly
no outgoing calls
no test coverage detected