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

Method GetDropTarget

Source/PatchCable.cpp:511–557  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

509}
510
511IClickable* PatchCable::GetDropTarget()
512{
513 if (mDragging)
514 {
515 PatchCablePos cable = GetPatchCablePos();
516 IClickable* potentialTarget = TheSynth->GetRootContainer()->GetModuleAt(cable.end.x, cable.end.y);
517 if (potentialTarget && (GetConnectionType() == kConnectionType_Pulse || GetConnectionType() == kConnectionType_Modulator || GetConnectionType() == kConnectionType_ValueSetter || GetConnectionType() == kConnectionType_Grid || GetConnectionType() == kConnectionType_UIControl))
518 {
519 IClickable* potentialUIControl = nullptr;
520
521 const auto& uicontrols = (static_cast<IDrawableModule*>(potentialTarget))->GetUIControls();
522 for (auto uicontrol : uicontrols)
523 {
524 if (uicontrol->IsShowing() == false || !IsValidTarget(uicontrol))
525 continue;
526
527 ofRectangle rect = uicontrol->GetRect();
528 if (rect.contains(cable.end.x, cable.end.y))
529 {
530 potentialUIControl = uicontrol;
531 break;
532 }
533 }
534
535 const auto& grids = (static_cast<IDrawableModule*>(potentialTarget))->GetUIGrids();
536 for (auto grid : grids)
537 {
538 if (grid->IsShowing() == false || !IsValidTarget(grid))
539 continue;
540
541 ofRectangle rect = grid->GetRect();
542 if (rect.contains(cable.end.x, cable.end.y))
543 {
544 potentialUIControl = grid;
545 break;
546 }
547 }
548
549 if (potentialUIControl != nullptr)
550 potentialTarget = potentialUIControl;
551 }
552 if (mOwner->IsValidTarget(potentialTarget))
553 return potentialTarget;
554 }
555
556 return nullptr;
557}
558
559bool PatchCable::TestClick(float x, float y, bool right, bool testOnly /* = false */)
560{

Callers 1

DrawMethod · 0.80

Calls 8

GetModuleAtMethod · 0.80
GetRootContainerMethod · 0.80
GetUIControlsMethod · 0.80
IsShowingMethod · 0.80
containsMethod · 0.80
GetUIGridsMethod · 0.80
GetRectMethod · 0.45
IsValidTargetMethod · 0.45

Tested by

no test coverage detected