| 388 | } |
| 389 | |
| 390 | ofVec2f PatchCableSource::GetCableStartDir(int index, ofVec2f dest) const |
| 391 | { |
| 392 | if (mHasOverrideCableDir) |
| 393 | { |
| 394 | return mOverrideCableDir; |
| 395 | } |
| 396 | else |
| 397 | { |
| 398 | enum class Direction |
| 399 | { |
| 400 | kUp, |
| 401 | kDown, |
| 402 | kLeft, |
| 403 | kRight, |
| 404 | kNone |
| 405 | }; |
| 406 | |
| 407 | Direction dir{ Direction::kNone }; |
| 408 | switch (mSide) |
| 409 | { |
| 410 | case Side::kBottom: dir = Direction::kDown; break; |
| 411 | case Side::kLeft: dir = Direction::kLeft; break; |
| 412 | case Side::kRight: dir = Direction::kRight; break; |
| 413 | case Side::kNone: dir = Direction::kNone; break; |
| 414 | } |
| 415 | |
| 416 | if (mHoverIndex != -1 && mPatchCables.size() > 0 && index < mPatchCables.size() - 1) //not the top of the cable stack |
| 417 | { |
| 418 | if (mSide == Side::kBottom) |
| 419 | { |
| 420 | if (dest.x < mX) |
| 421 | dir = Direction::kLeft; |
| 422 | else |
| 423 | dir = Direction::kRight; |
| 424 | } |
| 425 | else if (mSide == Side::kLeft || mSide == Side::kRight) |
| 426 | { |
| 427 | if (dest.y < mY) |
| 428 | dir = Direction::kUp; |
| 429 | else |
| 430 | dir = Direction::kDown; |
| 431 | } |
| 432 | } |
| 433 | |
| 434 | ofVec2f ret(0, 0); |
| 435 | switch (dir) |
| 436 | { |
| 437 | case Direction::kDown: |
| 438 | ret = ofVec2f(0, 1); |
| 439 | break; |
| 440 | case Direction::kRight: |
| 441 | ret = ofVec2f(1, 0); |
| 442 | break; |
| 443 | case Direction::kLeft: |
| 444 | ret = ofVec2f(-1, 0); |
| 445 | break; |
| 446 | case Direction::kUp: |
| 447 | ret = ofVec2f(0, -1); |
no test coverage detected