| 180 | } |
| 181 | |
| 182 | void IDrawableModule::DrawFrame(float w, float h, bool drawModule, float& titleBarHeight, float& highlight) |
| 183 | { |
| 184 | if (mPinned) |
| 185 | ForcePosition(); |
| 186 | titleBarHeight = mTitleBarHeight; |
| 187 | if (!HasTitleBar()) |
| 188 | titleBarHeight = 0; |
| 189 | |
| 190 | ofTranslate(mX, mY, 0); |
| 191 | |
| 192 | ofColor color = GetColor(mModuleCategory); |
| 193 | |
| 194 | highlight = 0; |
| 195 | |
| 196 | if (IsEnabled()) |
| 197 | { |
| 198 | IAudioSource* audioSource = dynamic_cast<IAudioSource*>(this); |
| 199 | if (audioSource) |
| 200 | { |
| 201 | RollingBuffer* vizBuff = audioSource->GetVizBuffer(); |
| 202 | int numSamples = std::min(500, vizBuff->Size()); |
| 203 | float sample; |
| 204 | float mag = 0; |
| 205 | for (int ch = 0; ch < vizBuff->NumChannels(); ++ch) |
| 206 | { |
| 207 | for (int i = 0; i < numSamples; ++i) |
| 208 | { |
| 209 | sample = vizBuff->GetSample(i, ch); |
| 210 | mag += sample * sample; |
| 211 | } |
| 212 | } |
| 213 | mag /= numSamples * vizBuff->NumChannels(); |
| 214 | mag = sqrtf(mag); |
| 215 | mag = sqrtf(mag); |
| 216 | mag *= 3; |
| 217 | mag = ofClamp(mag, 0, 1); |
| 218 | |
| 219 | if (UserPrefs.draw_module_highlights.Get()) |
| 220 | highlight = mag * .15f; |
| 221 | } |
| 222 | |
| 223 | if (GetPatchCableSource() != nullptr) |
| 224 | { |
| 225 | float elapsed = float(gTime - GetPatchCableSource()->GetHistory().GetLastOnEventTime()) / NOTE_HISTORY_LENGTH; |
| 226 | if (UserPrefs.draw_module_highlights.Get()) |
| 227 | highlight = MAX(highlight, .15f * ofClamp(1 - elapsed, 0, 1)); |
| 228 | } |
| 229 | } |
| 230 | |
| 231 | const bool kUseDropshadow = false; |
| 232 | if (kUseDropshadow && GetParent() == nullptr && GetModuleCategory() != kModuleCategory_Other) |
| 233 | { |
| 234 | const float shadowSize = 20; |
| 235 | float shadowStrength = .2f + highlight; |
| 236 | NVGpaint shadowPaint = nvgBoxGradient(gNanoVG, -shadowSize / 2, -titleBarHeight - shadowSize / 2, w + shadowSize, h + titleBarHeight + shadowSize, gCornerRoundness * shadowSize * .5f, shadowSize, nvgRGBA(color.r * shadowStrength, color.g * shadowStrength, color.b * shadowStrength, 128), nvgRGBA(0, 0, 0, 0)); |
| 237 | nvgBeginPath(gNanoVG); |
| 238 | nvgRect(gNanoVG, -shadowSize, -shadowSize - titleBarHeight, w + shadowSize * 2, h + titleBarHeight + shadowSize * 2); |
| 239 | nvgFillPaint(gNanoVG, shadowPaint); |
no test coverage detected