MCPcopy Create free account
hub / github.com/BespokeSynth/BespokeSynth / Render

Method Render

Source/PatchCableSource.cpp:257–360  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

255}
256
257void PatchCableSource::Render()
258{
259 if (!Enabled() || mOwner->IsDeleted())
260 return;
261
262 ofPushStyle();
263
264 float cableX = mX;
265 float cableY = mY;
266 if (mOwner->GetOwningContainer() != nullptr)
267 {
268 cableX -= mOwner->GetOwningContainer()->GetOwnerPosition().x;
269 cableY -= mOwner->GetOwningContainer()->GetOwnerPosition().y;
270 }
271
272 for (int i = 0; i < (int)mPatchCables.size() || i == 0; ++i)
273 {
274 if (i < (int)mPatchCables.size() && mPatchCables[i] != nullptr)
275 {
276 mPatchCables[i]->SetSourceIndex(i);
277
278 if (mParentMinimized)
279 {
280 IDrawableModule* owningModule = mPatchCables[i]->GetOwningModule();
281 IClickable* target = mPatchCables[i]->GetTarget();
282 if (owningModule != nullptr && target != nullptr)
283 {
284 ModuleContainer* owningModuleContainer = owningModule->GetOwningContainer();
285 ModuleContainer* targetContainer = target->GetModuleParent()->GetOwningContainer();
286 if (owningModuleContainer == targetContainer)
287 continue; //this is an internally-patched cable in a minimized module
288 }
289 }
290 }
291
292 if (mDrawPass == DrawPass::kCables && (mPatchCableDrawMode != kPatchCableDrawMode_CablesOnHoverOnly || mHoverIndex != -1))
293 {
294 if (i < (int)mPatchCables.size() && mPatchCables[i] != nullptr)
295 mPatchCables[i]->Draw();
296 }
297
298 if (mDrawPass == DrawPass::kSource && (mPatchCableDrawMode != kPatchCableDrawMode_SourceOnHoverOnly || mHoverIndex != -1))
299 {
300 ofSetLineWidth(0);
301 ofColor color = GetColor();
302 float radius = kPatchCableSourceRadius;
303 IDrawableModule* moveModule = TheSynth->GetMoveModule();
304 if (GetKeyModifiers() == kModifier_Shift && moveModule != nullptr)
305 {
306 if (mLastSeenAutopatchableModule != moveModule)
307 {
308 FindValidTargets();
309 mLastSeenAutopatchableModule = moveModule;
310 }
311 if ((IsValidTarget(moveModule) && GetTarget() != moveModule) || (GetOwner() == moveModule && GetTarget() == nullptr))
312 {
313 //highlight autopatchable cable sources
314 float lerp = ofMap(sin(gTime / 600 * PI * 2), -1, 1, 0, 1);

Callers

nothing calls this directly

Calls 15

ofPushStyleFunction · 0.85
ofSetLineWidthFunction · 0.85
GetKeyModifiersFunction · 0.85
ofMapFunction · 0.85
ofLerpFunction · 0.85
ofSetColorFunction · 0.85
ofFillFunction · 0.85
ofCircleFunction · 0.85
ofLineFunction · 0.85
ofNoFillFunction · 0.85
ofPopStyleFunction · 0.85
IsDeletedMethod · 0.80

Tested by

no test coverage detected