source: trunk/Cocoa/Pester/Source/PSMovieAlertController.m @ 41

Last change on this file since 41 was 41, checked in by Nicholas Riley, 18 years ago

Popup triangle.tiff: Needed display component of NJRFSObjectSelector.
This one appears to use transparency unlike the one I prepared for
Process Exhibits, so it should be preferred.

NSMovie-NJRExtensions: Added -isStatic to identify whether the movie
contains dynamic components. If the movie is static, it most likely
contains only an image and shouldn't be 'played' as such, otherwise
the duration will be so short that the image won't be useful.

NJRFSObjectSelector: Fixed -drawRect: to draw the drag feedback
rectangle inside the bounds of the control, not inside whatever dirty
rectangle is passed to the method (often they are the same, but not
always). Only draw the popup arrow if the control is enabled.
Properly draw the popup arrow with transparency. Display the 'make
alias' cursor as additional drag feedback.

PSMovieAlertController: Only repeat movie and auto-close after movie
finished if it contains time-based media, otherwise just display the
movie (an image) until the window is closed or alarms are cancelled.

NSImage-NJRExtensions: Include code to actually scale icons from
F-Script Anywhere, otherwise the menu ends up with 32x32 (or
potentially larger) icons if smaller variations are not provided.
There's some more code in FSA that chooses which representation to
select; this code may still not be properly handling representations,
but it works better now. A good test case is the icon for Tex-Edit
Plus documents.

NJRQTMediaPopUpButton: Added notification for movie change (needed to
update interface). Changed -_validatePreview to
-_validateWithPreview: - preview is now optional. This will be needed
when I add archiving support for the selected item; we'll need to
validate it before updating the interface, but we don't want sounds to
play. Added some #pragma mark lines to separate methods by
functionality. Call -validateWithPreview: NO in awakeFromNib (again,
this logic will become more sophisticated later). Commented some
debugging logic since I'm pretty happy with the code. Added
-canRepeat accessor and setters, notification support in the
validation method. Added drag feedback.

PSAlarmSetController: Notification support, -setSoundRepetitionCount:
to avoid flashing with repetition text field control as NSStepper is
adjusted

English.lproj/MainMenu.nib: Switched action method for the NSStepper
stuff discussed above.

AM /Users/nicholas/Documents/Development/Cocoa/Pester/Source/Popup triangle.tiff
M /Users/nicholas/Documents/Development/Cocoa/Pester/Source/NSMovie-NJRExtensions.m
M /Users/nicholas/Documents/Development/Cocoa/Pester/Source/NJRFSObjectSelector.m
M /Users/nicholas/Documents/Development/Cocoa/Pester/Source/PSMovieAlertController.m
M /Users/nicholas/Documents/Development/Cocoa/Pester/Source/NSImage-NJRExtensions.m
M /Users/nicholas/Documents/Development/Cocoa/Pester/Source/NJRQTMediaPopUpButton.h
M /Users/nicholas/Documents/Development/Cocoa/Pester/Source/NJRQTMediaPopUpButton.m
M /Users/nicholas/Documents/Development/Cocoa/Pester/Source/.DS_Store
M /Users/nicholas/Documents/Development/Cocoa/Pester/Source/English.lproj/MainMenu.nib/objects.nib
M /Users/nicholas/Documents/Development/Cocoa/Pester/Source/English.lproj/MainMenu.nib/info.nib
M /Users/nicholas/Documents/Development/Cocoa/Pester/Source/English.lproj/MainMenu.nib/classes.nib
M /Users/nicholas/Documents/Development/Cocoa/Pester/Source/Pester.pbproj/nicholas.pbxuser
M /Users/nicholas/Documents/Development/Cocoa/Pester/Source/Pester.pbproj/project.pbxproj
M /Users/nicholas/Documents/Development/Cocoa/Pester/Source/PSAlarmSetController.h
M /Users/nicholas/Documents/Development/Cocoa/Pester/Source/PSAlarmSetController.m
M /Users/nicholas/Documents/Development/Cocoa/Pester/Source/NSMovie-NJRExtensions.h

File size: 3.4 KB
Line 
1//
2//  PSMovieAlertController.m
3//  Pester
4//
5//  Created by Nicholas Riley on Sat Oct 26 2002.
6//  Copyright (c) 2002 Nicholas Riley. All rights reserved.
7//
8
9#import "PSAlarmAlertController.h"
10#import "PSMovieAlertController.h"
11#import "PSMovieAlert.h"
12#import "NSMovie-NJRExtensions.h"
13#import <QuickTime/Movies.h>
14
15@implementation PSMovieAlertController
16
17+ (PSMovieAlertController *)controllerWithAlarm:(PSAlarm *)alarm movieAlert:(PSMovieAlert *)alert;
18{
19    return [[self alloc] initWithAlarm: alarm movieAlert: alert];
20}
21
22- (void)play;
23{
24    NSTimeInterval delay;
25    if (repetitions == 0) return;
26    if (IsMovieDone((Movie)theMovie) || repetitionsRemaining == repetitions) {
27        if (repetitionsRemaining == 0) {
28            [self close];
29            return;
30        }
31        repetitionsRemaining--;
32        [movieView gotoBeginning: self];
33        [movieView start: self];
34    }
35    delay = (GetMovieDuration((Movie)theMovie) - GetMovieTime((Movie)theMovie, NULL)) / (double)GetMovieTimeScale((Movie)theMovie);
36    [self performSelector: @selector(play) withObject: nil afterDelay: delay inModes: [NSArray arrayWithObject: NSDefaultRunLoopMode]];
37}
38
39- (id)initWithAlarm:(PSAlarm *)alarm movieAlert:(PSMovieAlert *)alert;
40{
41    if ([self initWithWindowNibName: @"Movie alert"]) {
42        NSMovie *movie = [alert movie];
43        NSWindow *window = [self window]; // connect outlets
44        [movieView setMovie: movie];
45        theMovie = [movie QTMovie];
46        if ([alert hasVideo]) {
47            NSRect screenRect = [[window screen] visibleFrame];
48            float magnification = 1.0;
49            NSSize movieSize;
50            NSRect frame;
51            screenRect.size.height -= [window frame].size.height - [[window contentView] frame].size.height; // account for height of window frame
52            while (1) {
53                movieSize = [movieView sizeForMagnification: magnification];
54                movieSize.height -= 16; // controller is hidden, but its size is included (documented, ergh)
55                if (movieSize.width > screenRect.size.width || movieSize.height > screenRect.size.height)
56                    magnification /= 2;
57                else
58                    break;
59            }
60            [window setContentSize: movieSize];
61            [window center];
62            frame = [window frame];
63            frame.origin.y -= 250; // appear below notifier window
64            if (frame.origin.y < screenRect.origin.y) frame.origin.y = screenRect.origin.y;
65            [window setFrame: frame display: NO];
66            [window setTitle: [alarm message]];
67            [[self window] orderFrontRegardless];
68        }
69        [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(close) name: PSAlarmAlertStopNotification object: nil];
70        repetitions = [alert repetitions];
71        repetitionsRemaining = repetitions;
72        if (![movie isStatic]) [self play]; // if it's an image, don't close the window automatically
73    }
74    return self;
75}
76
77- (void)dealloc;
78{
79    [[NSNotificationCenter defaultCenter] removeObserver: self];
80    [super dealloc];
81}
82
83@end
84
85@implementation PSMovieAlertController (NSWindowNotifications)
86
87- (void)windowWillClose:(NSNotification *)notification;
88{
89    repetitions = 0;
90    [movieView stop: self];
91    [self release];
92    // note: there may still be a retained copy of this object until the runloop timer has let go of us at the end of the current movie playback cycle; donÕt worry about it.
93}
94
95@end
Note: See TracBrowser for help on using the repository browser.