source: releases/Pester/1.1b4/Source/PSVolumeController.m@ 230

Last change on this file since 230 was 133, checked in by Nicholas Riley, 22 years ago

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 size: 2.5 KB
Line 
1//
2// PSVolumeController.m
3// Pester
4//
5// Created by Nicholas Riley on Tue Apr 08 2003.
6// Copyright (c) 2003 Nicholas Riley. All rights reserved.
7//
8
9#import "PSVolumeController.h"
10#import "NJRSoundManager.h"
11
12@implementation PSVolumeController
13
14+ (PSVolumeController *)controllerWithVolume:(float)volume delegate:(id)aDelegate;
15{
16 return [[self alloc] initWithVolume: volume delegate: aDelegate];
17}
18
19- (id)initWithVolume:(float)volume delegate:(id)aDelegate;
20{
21 if ( (self = [self initWithWindowNibName: @"Volume"]) != nil) {
22 [self window]; // connect outlets
23 NSWindow *window = [[NSWindow alloc] initWithContentRect: [contentView bounds] styleMask: NSBorderlessWindowMask | NSTexturedBackgroundWindowMask backing: NSBackingStoreBuffered defer: NO];
24
25 NSModalSession session = [NSApp beginModalSessionForWindow: window];
26 [window orderOut: self];
27
28 if ([NJRSoundManager volumeIsNotMutedOrInvalid: volume])
29 [volumeSlider setFloatValue: volume];
30
31 delegate = [aDelegate retain];
32
33 [window setContentView: contentView];
34 [window setOpaque: NO];
35 [window setBackgroundColor: [NSColor colorWithCalibratedWhite: 0.81f alpha: 0.9f]];
36 [window setHasShadow: YES];
37 [window setOneShot: YES];
38 [window setDelegate: self];
39 NSView *view = [aDelegate volumeControllerLaunchingView: self];
40 if (view != nil) {
41 NSRect rect = [view convertRect: [view bounds] toView: nil];
42 NSWindow *parentWindow = [view window];
43 rect.origin = [parentWindow convertBaseToScreen: rect.origin];
44 rect.origin.x -= [window frame].size.width - rect.size.width + 1;
45 [window setFrameTopLeftPoint: rect.origin];
46 NSRect visibleFrame = [[parentWindow screen] visibleFrame];
47 if (!NSContainsRect(visibleFrame, [window frame])) {
48 NSPoint viewTopLeft = { rect.origin.x, rect.origin.y + rect.size.height };
49 [window setFrameOrigin: viewTopLeft];
50 }
51 }
52 [window makeKeyAndOrderFront: self];
53
54 [volumeSlider mouseDown: [NSApp currentEvent]];
55 [NSApp runModalSession: session];
56 [NSApp endModalSession: session];
57 [window close];
58 [self autorelease];
59 // XXX make sure window and self are released
60 }
61 return self;
62}
63
64- (void)dealloc;
65{
66 [delegate release];
67 [super dealloc];
68}
69
70- (IBAction)volumeSet:(NSSlider *)sender;
71{
72 [delegate volumeController: self didSetVolume: [sender floatValue]];
73}
74
75@end
Note: See TracBrowser for help on using the repository browser.