MCPcopy Create free account
hub / github.com/CalcProgrammer1/OpenRGB / mouseReleaseEvent

Method mouseReleaseEvent

qt/DeviceView.cpp:631–688  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

629}
630
631void DeviceView::mouseReleaseEvent(QMouseEvent* event)
632{
633 if(per_led)
634 {
635 selectionRect = selectionRect.normalized();
636 mouseDown = false;
637
638 /*-----------------------------------------------------*\
639 | Check if the user clicked a zone name & select it |
640 \*-----------------------------------------------------*/
641 if(!mouseMoved)
642 {
643 int size = width();
644 int offset_x = 0;
645
646 if(height() < size * matrix_h)
647 {
648 size = height() / matrix_h;
649 offset_x = (width() - size) / 2;
650 }
651
652 unsigned int segment_count = 0;
653
654 for(std::size_t zone_idx = 0; zone_idx < controller->zones.size(); zone_idx++)
655 {
656 int posx = zone_pos[zone_idx].matrix_x * size + offset_x + 12;
657 int posy = zone_pos[zone_idx].matrix_y * size;
658 int posw = zone_pos[zone_idx].matrix_w * size;
659 int posh = zone_pos[zone_idx].matrix_h * size;
660
661 QRect rect = {posx, posy, posw, posh};
662
663 if(rect.contains(event->pos()))
664 {
665 selectZone(zone_idx, ctrlDown);
666 }
667
668 for(std::size_t segment_idx = 0; segment_idx < controller->zones[zone_idx].segments.size(); segment_idx++)
669 {
670 posx = segment_pos[segment_count].matrix_x * size + offset_x + 12;
671 posy = segment_pos[segment_count].matrix_y * size;
672 posw = segment_pos[segment_count].matrix_w * size;
673 posh = segment_pos[segment_count].matrix_h * size;
674
675 segment_count++;
676
677 rect = {posx, posy, posw, posh};
678
679 if(rect.contains(event->pos()))
680 {
681 selectSegment(zone_idx, segment_idx, ctrlDown);
682 }
683 }
684 }
685 }
686 update();
687 }
688}

Callers

nothing calls this directly

Calls 3

containsMethod · 0.80
updateFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected