Skip to content

Commit 9a0c70c

Browse files
When moving to items that have more than one take, only report number of non-empty takes for clarity. (#1301)
Also, separate the number of the take from its name using a comma for easier intelligibility.
1 parent 7dc7230 commit 9a0c70c

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

src/reaper_osara.cpp

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,19 @@ TimeFormat getPrimaryOrSecondaryTimeFormatForCommand() {
885885
return TF_RULER;
886886
}
887887

888+
int countNonEmptyTakes(MediaItem* item) {
889+
if (!item)
890+
return 0;
891+
int totalTakes = CountTakes(item);
892+
int nonEmptyTakes = 0;
893+
for (int t = 0; t < totalTakes; ++t) {
894+
if (GetTake(item, t)) {
895+
nonEmptyTakes++;
896+
}
897+
}
898+
return nonEmptyTakes;
899+
}
900+
888901
// End of utility/helper functions
889902

890903
// Functions exported from SWS
@@ -1671,7 +1684,7 @@ void postSwitchToTake(int command) {
16711684
return;
16721685
}
16731686
ostringstream s;
1674-
s << (int)(size_t)GetSetMediaItemTakeInfo(take, "IP_TAKENUMBER", nullptr) + 1 << " "
1687+
s << (int)(size_t)GetSetMediaItemTakeInfo(take, "IP_TAKENUMBER", nullptr) + 1 << ", "
16751688
<< GetTakeName(take);
16761689
addTakeFxNames(take, s);
16771690
outputMessage(s);
@@ -3713,11 +3726,11 @@ void moveToItem(int direction, bool clearSelection=true, bool select=true) {
37133726
if (take) {
37143727
s << " " << GetTakeName(take);
37153728
}
3716-
int takeCount = CountTakes(item);
3717-
if (takeCount > 1) {
3718-
// Translators: Used when navigating items to indicate the number of
3719-
// takes. {} will be replaced with the number; e.g. "2 takes".
3720-
s << " " << format(translate("{} takes"), takeCount);
3729+
int nonEmptyTakes = countNonEmptyTakes(item);
3730+
if (nonEmptyTakes > 1) {
3731+
// Translators: Used when navigating items to indicate the number of takes, only if there is more than 1 take.
3732+
// {} will be replaced with the number of takes; e.g. "2 takes".
3733+
s << " " << format(translate("{} takes"), nonEmptyTakes);
37213734
}
37223735
s << " " << formatCursorPosition();
37233736
addTakeFxNames(take, s);
@@ -4870,11 +4883,11 @@ void cmdReportNumberOfTakesInItem(Command* command) {
48704883
MediaItem* item = getItemWithFocus();
48714884
if (!item)
48724885
return;
4873-
int takeCount = CountTakes(item);
4886+
int nonEmptyTakes = countNonEmptyTakes(item);
48744887
// Translators: Reports the number of takes contained within the last touched item.
48754888
// {} will be replaced with the number; e.g. "1 take", or "2 takes".
4876-
outputMessage(format(translate_plural("{} take", "{} takes", takeCount),
4877-
takeCount));
4889+
outputMessage(format(translate_plural("{} take", "{} takes", nonEmptyTakes),
4890+
nonEmptyTakes));
48784891
}
48794892

48804893
void cmdReportItemLength(Command* command) {

0 commit comments

Comments
 (0)