| 415 | |
| 416 | |
| 417 | void PortWidget::onDragStart(const DragStartEvent& e) { |
| 418 | if (e.button != GLFW_MOUSE_BUTTON_LEFT) |
| 419 | return; |
| 420 | |
| 421 | DEFER({ |
| 422 | // Reset overrides |
| 423 | internal->overrideCws.clear(); |
| 424 | internal->overrideCloneCw = NULL; |
| 425 | internal->overrideCreateCable = false; |
| 426 | }); |
| 427 | |
| 428 | // Create ComplexAction |
| 429 | if (internal->history) { |
| 430 | delete internal->history; |
| 431 | internal->history = NULL; |
| 432 | } |
| 433 | internal->history = new history::ComplexAction; |
| 434 | internal->history->name = string::translate("PortWidget.history.moveCable"); |
| 435 | |
| 436 | std::vector<CableWidget*> cws; |
| 437 | int mods = APP->window->getMods(); |
| 438 | if (internal->overrideCreateCable || (mods & RACK_MOD_MASK) == RACK_MOD_CTRL) { |
| 439 | // Create cable with Ctrl+drag or PortCreateCableItem |
| 440 | // Keep cable NULL. Will be created below |
| 441 | } |
| 442 | else if (internal->overrideCloneCw || (mods & RACK_MOD_MASK) == (RACK_MOD_CTRL | GLFW_MOD_SHIFT)) { |
| 443 | // Clone top cable with Ctrl+shift+drag or PortCloneCableItem |
| 444 | CableWidget* cloneCw = internal->overrideCloneCw; |
| 445 | if (!cloneCw) |
| 446 | cloneCw = APP->scene->rack->getTopCable(this); |
| 447 | |
| 448 | if (cloneCw) { |
| 449 | CableWidget* cw = new CableWidget; |
| 450 | cw->color = cloneCw->color; |
| 451 | if (type == engine::Port::OUTPUT) |
| 452 | cw->inputPort = cloneCw->inputPort; |
| 453 | else |
| 454 | cw->outputPort = cloneCw->outputPort; |
| 455 | internal->draggedType = type; |
| 456 | APP->scene->rack->addCable(cw); |
| 457 | cws.push_back(cw); |
| 458 | } |
| 459 | } |
| 460 | else { |
| 461 | // Grab cable on top of stack |
| 462 | cws = internal->overrideCws; |
| 463 | if (cws.empty()) { |
| 464 | CableWidget* cw = APP->scene->rack->getTopCable(this); |
| 465 | if (cw) |
| 466 | cws.push_back(cw); |
| 467 | } |
| 468 | |
| 469 | for (CableWidget* cw : cws) { |
| 470 | // history::CableRemove |
| 471 | history::CableRemove* h = new history::CableRemove; |
| 472 | h->setCable(cw); |
| 473 | internal->history->push(h); |
| 474 |
nothing calls this directly
no test coverage detected