| 647 | } |
| 648 | |
| 649 | auto LabelStruct::RegionRelation( |
| 650 | double reg_t0, double reg_t1, const LabelTrack * WXUNUSED(parent)) const |
| 651 | -> TimeRelations |
| 652 | { |
| 653 | bool retainLabels = false; |
| 654 | |
| 655 | wxASSERT(reg_t0 <= reg_t1); |
| 656 | gPrefs->Read(wxT("/GUI/RetainLabels"), &retainLabels); |
| 657 | |
| 658 | if(retainLabels) { |
| 659 | |
| 660 | // Desired behavior for edge cases: The length of the selection is smaller |
| 661 | // than the length of the label if the selection is within the label or |
| 662 | // matching exactly a (region) label. |
| 663 | |
| 664 | if (reg_t0 < getT0() && reg_t1 > getT1()) |
| 665 | return SURROUNDS_LABEL; |
| 666 | else if (reg_t1 < getT0()) |
| 667 | return BEFORE_LABEL; |
| 668 | else if (reg_t0 > getT1()) |
| 669 | return AFTER_LABEL; |
| 670 | |
| 671 | else if (reg_t0 >= getT0() && reg_t0 <= getT1() && |
| 672 | reg_t1 >= getT0() && reg_t1 <= getT1()) |
| 673 | return WITHIN_LABEL; |
| 674 | |
| 675 | else if (reg_t0 >= getT0() && reg_t0 <= getT1()) |
| 676 | return BEGINS_IN_LABEL; |
| 677 | else |
| 678 | return ENDS_IN_LABEL; |
| 679 | |
| 680 | } else { |
| 681 | |
| 682 | // AWD: Desired behavior for edge cases: point labels bordered by the |
| 683 | // selection are included within it. Region labels are included in the |
| 684 | // selection to the extent that the selection covers them; specifically, |
| 685 | // they're not included at all if the selection borders them, and they're |
| 686 | // fully included if the selection covers them fully, even if it just |
| 687 | // borders their endpoints. This is just one of many possible schemes. |
| 688 | |
| 689 | // The first test catches bordered point-labels and selected-through |
| 690 | // region-labels; move it to third and selection edges become inclusive |
| 691 | // WRT point-labels. |
| 692 | if (reg_t0 <= getT0() && reg_t1 >= getT1()) |
| 693 | return SURROUNDS_LABEL; |
| 694 | else if (reg_t1 <= getT0()) |
| 695 | return BEFORE_LABEL; |
| 696 | else if (reg_t0 >= getT1()) |
| 697 | return AFTER_LABEL; |
| 698 | |
| 699 | // At this point, all point labels should have returned. |
| 700 | |
| 701 | else if (reg_t0 > getT0() && reg_t0 < getT1() && |
| 702 | reg_t1 > getT0() && reg_t1 < getT1()) |
| 703 | return WITHIN_LABEL; |
| 704 | |
| 705 | // Knowing that none of the other relations match simplifies remaining |
| 706 | // tests |
no test coverage detected