Change the behaviour of point labels to behave like region labels.
Benjamin Drung
12 years ago
0 | Description: Change the behaviour of point labels to behave like region labels. | |
1 | Author: Benjamin Drung <bdrung@debian.org> | |
2 | Bug: http://bugzilla.audacityteam.org/show_bug.cgi?id=466 | |
3 | ||
4 | --- a/src/LabelTrack.cpp | |
5 | +++ b/src/LabelTrack.cpp | |
6 | @@ -1240,31 +1240,21 @@ | |
7 | { | |
8 | wxASSERT(reg_t0 <= reg_t1); | |
9 | ||
10 | - // AWD: Desired behavior for edge cases: point labels bordered by the | |
11 | - // selection are included within it. Region labels are included in the | |
12 | - // selection to the extent that the selection covers them; specifically, | |
13 | - // they're not included at all if the selection borders them, and they're | |
14 | - // fully included if the selection covers them fully, even if it just | |
15 | - // borders their endpoints. This is just one of many possible schemes. | |
16 | + // Desired behavior for edge cases: The length of the selection is smaller | |
17 | + // than the length of the label if the selection is within the label. | |
18 | + // Selections matching exactly a (region) label surround the label. | |
19 | ||
20 | - // The first test catches bordered point-labels and selected-through | |
21 | - // region-labels; move it to third and selection edges become inclusive WRT | |
22 | - // point-labels. | |
23 | - if (reg_t0 <= t && reg_t1 >= t1) | |
24 | + if ((reg_t0 < t && reg_t1 > t1) || (reg_t0 == t && reg_t1 == t1)) | |
25 | return SURROUNDS_LABEL; | |
26 | - else if (reg_t1 <= t) | |
27 | + else if (reg_t1 < t) | |
28 | return BEFORE_LABEL; | |
29 | - else if (reg_t0 >= t1) | |
30 | + else if (reg_t0 > t1) | |
31 | return AFTER_LABEL; | |
32 | ||
33 | - // At this point, all point labels should have returned. | |
34 | - | |
35 | - else if (reg_t0 > t && reg_t0 < t1 && reg_t1 > t && reg_t1 < t1) | |
36 | + else if (reg_t0 >= t && reg_t0 <= t1 && reg_t1 >= t && reg_t1 <= t1) | |
37 | return WITHIN_LABEL; | |
38 | ||
39 | - // Knowing that none of the other relations match simplifies remaining | |
40 | - // tests | |
41 | - else if (reg_t0 > t && reg_t0 < t1) | |
42 | + else if (reg_t0 >= t && reg_t0 <= t1) | |
43 | return BEGINS_IN_LABEL; | |
44 | else | |
45 | return ENDS_IN_LABEL; |