| 545 | } |
| 546 | |
| 547 | int CUi::DoDraggableButtonLogic(const void *pId, int Checked, const CUIRect *pRect, bool *pClicked, bool *pAbrupted) |
| 548 | { |
| 549 | // logic |
| 550 | int ReturnValue = 0; |
| 551 | const bool Inside = MouseHovered(pRect); |
| 552 | |
| 553 | if(pClicked != nullptr) |
| 554 | *pClicked = false; |
| 555 | if(pAbrupted != nullptr) |
| 556 | *pAbrupted = false; |
| 557 | |
| 558 | if(CheckActiveItem(pId)) |
| 559 | { |
| 560 | dbg_assert(m_ActiveDraggableButtonLogicButton >= 0, "m_ActiveDraggableButtonLogicButton invalid"); |
| 561 | if(m_ActiveDraggableButtonLogicButton == 0) |
| 562 | { |
| 563 | if(Checked >= 0) |
| 564 | ReturnValue = 1 + m_ActiveDraggableButtonLogicButton; |
| 565 | if(!MouseButton(m_ActiveDraggableButtonLogicButton)) |
| 566 | { |
| 567 | if(pClicked != nullptr) |
| 568 | *pClicked = true; |
| 569 | SetActiveItem(nullptr); |
| 570 | m_ActiveDraggableButtonLogicButton = -1; |
| 571 | } |
| 572 | if(MouseButton(1)) |
| 573 | { |
| 574 | if(pAbrupted != nullptr) |
| 575 | *pAbrupted = true; |
| 576 | SetActiveItem(nullptr); |
| 577 | m_ActiveDraggableButtonLogicButton = -1; |
| 578 | } |
| 579 | } |
| 580 | else if(!MouseButton(m_ActiveDraggableButtonLogicButton)) |
| 581 | { |
| 582 | if(Inside && Checked >= 0) |
| 583 | ReturnValue = 1 + m_ActiveDraggableButtonLogicButton; |
| 584 | if(pClicked != nullptr) |
| 585 | *pClicked = true; |
| 586 | SetActiveItem(nullptr); |
| 587 | m_ActiveDraggableButtonLogicButton = -1; |
| 588 | } |
| 589 | } |
| 590 | else if(HotItem() == pId) |
| 591 | { |
| 592 | for(int i = 0; i < 3; ++i) |
| 593 | { |
| 594 | if(MouseButton(i)) |
| 595 | { |
| 596 | SetActiveItem(pId); |
| 597 | m_ActiveDraggableButtonLogicButton = i; |
| 598 | } |
| 599 | } |
| 600 | } |
| 601 | |
| 602 | if(Inside && !MouseButton(0) && !MouseButton(1) && !MouseButton(2)) |
| 603 | SetHotItem(pId); |
| 604 |
no outgoing calls
no test coverage detected