| 723 | } |
| 724 | |
| 725 | void AgentAssignment::eventOccured(Event *e) |
| 726 | { |
| 727 | Form::eventOccured(e); |
| 728 | |
| 729 | switch (e->type()) |
| 730 | { |
| 731 | case EVENT_FORM_INTERACTION: |
| 732 | if (e->forms().EventFlag == FormEventType::MouseUp) |
| 733 | { |
| 734 | if (isDragged && (e->forms().RaisedBy == sourceRaisedBy || |
| 735 | e->forms().RaisedBy->Name == "FORM_AGENT_ASSIGNMENT")) |
| 736 | { |
| 737 | // miss click |
| 738 | isDragged = false; |
| 739 | draggedList->setVisible(false); |
| 740 | } |
| 741 | } |
| 742 | break; |
| 743 | |
| 744 | case EVENT_MOUSE_DOWN: |
| 745 | positionX = e->mouse().X; |
| 746 | positionY = e->mouse().Y; |
| 747 | break; |
| 748 | |
| 749 | case EVENT_MOUSE_MOVE: |
| 750 | // if dragged - change location of dragged list |
| 751 | if (isDragged) |
| 752 | { |
| 753 | int distance = (positionX - e->mouse().X) * (positionX - e->mouse().X) + |
| 754 | (positionY - e->mouse().Y) * (positionY - e->mouse().Y); |
| 755 | if (distance > insensibility) |
| 756 | { |
| 757 | draggedList->Location.x = e->mouse().X - this->resolvedLocation.x; |
| 758 | draggedList->Location.y = e->mouse().Y - this->resolvedLocation.y; |
| 759 | if (!draggedList->isVisible()) |
| 760 | { |
| 761 | // time to make the list |
| 762 | draggedList->clear(); |
| 763 | draggedList->setVisible(true); |
| 764 | for (auto &a : sourceRaisedBy->getSelectedItems()) |
| 765 | { |
| 766 | a->copyTo(draggedList)->setData(a->getData<Agent>()); |
| 767 | } |
| 768 | } |
| 769 | } |
| 770 | } |
| 771 | break; |
| 772 | default: |
| 773 | // All other events ignored |
| 774 | break; |
| 775 | } |
| 776 | } |
| 777 | |
| 778 | void AgentAssignment::update() { Form::update(); } |
| 779 | } // namespace OpenApoc |
no test coverage detected