Ignore:
Timestamp:
04/09/03 05:44:11 (19 years ago)
Author:
Nicholas Riley
Message:

VERSION: Updated for 1.1b4.

PSMovieAlertController.[hm]: Set output volume from alert; save and
restore output volume (bug 27).

PSBeepAlert.[hm]: Save and set volume, disabled pending a
synchronous equivalent to NSBeep().

NJRQTMediaPopUpButton.[hm]: Save movieHasAudio (does not include
beeps, pending the above fix, since they don't permit volume
adjustment). savedVolume indicates whether the volume has been saved
but not restored yet; outputVolume stores the set volume (eventually
incorporated into a PSMediaAlert).

PSMediaAlert.[hm]: Stores repetitions and volume information for audio
alerts. New superclass of PSBeepAlert and PSMovieAlert.

PSPreferencesController.m: Fixed bug where hot keys still appeared
even after they couldn't be set - last of bug 29. Add Command-comma
to the list of disallowed equivalents, as it's reserved for
Preferences now (still a bug - it'll show the entire set key
equivalent at the left side of the window when you press
command-comma; ah well.)

Volume [0123].png: Volume-indicating small icons from QuickTime 6.

NJRSoundManager.[hm]: Interface to volume saving, restoring, setting -
necessary because the QuickTime call to SetDefaultOutputVolume sets
the right channel volume only (bug 27).

PSVolumeController.h: Controller for volume popup window (bug 27).
Not your average NSWindowController, but it works. Keyboard control
of volume is still necessary; filed as bug 31.

PSAlarmSetController.[hm]: Added references to sound volume button and
showVolume: action. Added volume setting support (bug 27); mostly
similar interface to calendar, though we need direct calls to
NJRSoundManager to restore sound volume at times. Only enable sound
volume button if selected media file has audio component (and isn't the
system alert sound, which I discussed above). Take advantage of
PSMediaAlert to factor some code in _readAlerts:. Save and restore
volume as part of alerts.

Read Me.rtfd: Updated release notes; fixed some bizarre text
formatting problems; search/replace "* " bullet-space with "*\t"
bullet-tab to improve alignment in release notes.

PSMovieAlert.[hm]: Factored code into PSMediaAlert. Describe output
volume as percentage of maximum.

NJRHotKey.m: Fixed some odd spacing left over from Ecky's code.

PSApplication.m: Restore saved output volume on quit.

English.lproj/MainMenu.nib: Added volume button.

English.lproj/Volume.nib: Volume nib (bug 27).

PSCalendarController.m: Removed casts from a copy/paste error. Fixed
variable names in some code inherited from my TextExtras incremental
search modifications - it's not always a text field now.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cocoa/Pester/Source/PSAlarmSetController.m

    r103 r133  
    1212#import "PSPowerManager.h"
    1313#import "PSTimeDateEditor.h"
     14#import "PSVolumeController.h"
    1415#import "NJRDateFormatter.h"
    1516#import "NJRFSObjectSelector.h"
    1617#import "NJRIntervalField.h"
    1718#import "NJRQTMediaPopUpButton.h"
     19#import "NJRSoundManager.h"
    1820#import "NJRVoicePopUpButton.h"
    1921#import "NSString-NJRExtensions.h"
     
    6163- (void)_readAlerts:(PSAlerts *)alerts;
    6264- (BOOL)_setAlerts;
     65- (void)_setVolume:(float)volume withPreview:(BOOL)preview;
    6366- (void)_stopUpdateTimer;
    6467
     
    7477    [[self window] center];
    7578    [PSTimeDateEditor setUpTimeField: timeOfDay dateField: timeDate completions: timeDateCompletions];
     79    { // volume defaults, usually overridden by restored alert info
     80        float volume = 0.5;
     81        [NJRSoundManager getDefaultOutputVolume: &volume];
     82        [self _setVolume: volume withPreview: NO];
     83    }
    7684    [editAlert setIntValue: [defaults boolForKey: PSAlertsEditing]];
    7785    {
     
    231239{
    232240    return timeCalendarButton;
     241}
     242
     243#pragma mark volume
     244
     245- (IBAction)showVolume:(NSButton *)sender;
     246{
     247    [PSVolumeController controllerWithVolume: [sound outputVolume] delegate: self];
     248}
     249
     250#define VOLUME_IMAGE_INDEX(vol) (vol * 4) - 0.01
     251
     252- (void)_setVolume:(float)volume withPreview:(BOOL)preview;
     253{
     254    float outputVolume = [sound outputVolume];
     255    short volumeImageIndex = VOLUME_IMAGE_INDEX(volume);
     256
     257    if (outputVolume > 0 && volumeImageIndex == VOLUME_IMAGE_INDEX(outputVolume)) return;
     258    NSString *volumeImageName = [NSString stringWithFormat: @"Volume %ld", volumeImageIndex];
     259    [soundVolumeButton setImage: [NSImage imageNamed: volumeImageName]];
     260
     261    [sound setOutputVolume: volume withPreview: preview];
     262}
     263
     264- (void)volumeController:(PSVolumeController *)controller didSetVolume:(float)volume;
     265{
     266    [self _setVolume: volume withPreview: YES];
     267}
     268
     269- (NSView *)volumeControllerLaunchingView:(PSVolumeController *)controller;
     270{
     271    return soundVolumeButton;
    233272}
    234273
     
    299338    [sound setEnabled: playSoundSelected];
    300339    [soundRepetitions setEnabled: canRepeat];
     340    [soundVolumeButton setEnabled: canRepeat && [sound hasAudio]];
    301341    [soundRepetitionStepper setEnabled: canRepeat];
    302342    [soundRepetitionsLabel setTextColor: canRepeat ? [NSColor controlTextColor] : [NSColor disabledControlTextColor]];
     
    366406        } else if ([alert isKindOfClass: [PSNotifierAlert class]]) {
    367407            [displayMessage setIntValue: YES];
    368         } else if ([alert isKindOfClass: [PSBeepAlert class]]) {
    369             unsigned int repetitions = [(PSBeepAlert *)alert repetitions];
     408        } else if ([alert isKindOfClass: [PSMediaAlert class]]) {
     409            unsigned int repetitions = [(PSMediaAlert *)alert repetitions];
    370410            [playSound setIntValue: YES];
    371             [sound setAlias: nil];
    372411            [soundRepetitions setIntValue: repetitions];
    373412            [soundRepetitionStepper setIntValue: repetitions];
    374         } else if ([alert isKindOfClass: [PSMovieAlert class]]) {
    375             unsigned int repetitions = [(PSMovieAlert *)alert repetitions];
    376             [playSound setIntValue: YES];
    377             [sound setAlias: [(PSMovieAlert *)alert movieFileAlias]];
    378             [soundRepetitions setIntValue: repetitions];
    379             [soundRepetitionStepper setIntValue: repetitions];
     413            [self _setVolume: [(PSMediaAlert *)alert outputVolume] withPreview: NO];
     414            if ([alert isKindOfClass: [PSBeepAlert class]]) {
     415                [sound setAlias: nil];
     416            } else if ([alert isKindOfClass: [PSMovieAlert class]]) {
     417                [sound setAlias: [(PSMovieAlert *)alert movieFileAlias]];
     418            }
    380419        } else if ([alert isKindOfClass: [PSSpeechAlert class]]) {
    381420            [doSpeak setIntValue: YES];
     
    412451            BDAlias *soundAlias = [sound selectedAlias];
    413452            unsigned short numReps = [soundRepetitions intValue];
     453            PSMediaAlert *alert;
    414454            if (soundAlias == nil) // beep alert
    415                 [alerts addAlert: [PSBeepAlert alertWithRepetitions: numReps]];
     455                alert = [PSBeepAlert alertWithRepetitions: numReps];
    416456            else // movie alert
    417                 [alerts addAlert: [PSMovieAlert alertWithMovieFileAlias: soundAlias repetitions: numReps]];
     457                alert = [PSMovieAlert alertWithMovieFileAlias: soundAlias repetitions: numReps];
     458            [alerts addAlert: alert];
     459            [alert setOutputVolume: [sound outputVolume]];
    418460        }
    419461        // speech alert
Note: See TracChangeset for help on using the changeset viewer.