Volume slider changes #357

Closed
shohallan wants to merge 4 commits from patch-1 into main
Showing only changes of commit f2ed595cda - Show all commits

View file

@ -64,7 +64,15 @@ static void *kVolumeSliderContext = &kVolumeSliderContext;
double volume;
volume = linearToLogarithmic(value, MAX_VOLUME);
NSString *text = [NSString stringWithFormat:@"%0.lf%%", volume];
// If volume becomes less than 1%, display two decimal digits of precision (e.g. 0.34%).
if(volume < 1)
NSString *text = [NSString stringWithFormat:@"%0.2lf%%", volume];
// Else if volume becomes less than 10%, display one decimal digit of precision (e.g. 3.4%).
else if(volume < 10)
NSString *text = [NSString stringWithFormat:@"%0.1lf%%", volume];
// Else display no decimal digits.
else
NSString *text = [NSString stringWithFormat:@"%0.lf%%", volume];
[textView setString:text];
}