|
boredzo@2402
|
1 |
//
|
|
boredzo@2402
|
2 |
// GrowlMusicVideoWindowController.m
|
|
boredzo@2402
|
3 |
// Display Plugins
|
|
boredzo@2402
|
4 |
//
|
|
boredzo@2402
|
5 |
// Created by Jorge Salvador Caffarena on 09/09/04.
|
|
boredzo@2402
|
6 |
// Copyright 2004 Jorge Salvador Caffarena. All rights reserved.
|
|
boredzo@2402
|
7 |
//
|
|
boredzo@2402
|
8 |
|
|
boredzo@2402
|
9 |
#import "GrowlMusicVideoWindowController.h"
|
|
rudy@3282
|
10 |
#import "GrowlFadingWindowTransition.h"
|
|
boredzo@2402
|
11 |
#import "GrowlMusicVideoWindowView.h"
|
|
boredzo@2402
|
12 |
#import "GrowlMusicVideoPrefs.h"
|
|
boredzo@2402
|
13 |
#import "NSWindow+Transforms.h"
|
|
rudy@2824
|
14 |
#import "GrowlSlidingWindowTransition.h"
|
|
rudy@2830
|
15 |
#import "GrowlWipeWindowTransition.h"
|
|
rudy@2905
|
16 |
#include "CFDictionaryAdditions.h"
|
|
ingmarstein@2941
|
17 |
#import "GrowlApplicationNotification.h"
|
|
boredzo@2402
|
18 |
|
|
boredzo@2402
|
19 |
@implementation GrowlMusicVideoWindowController
|
|
boredzo@2402
|
20 |
|
|
rudy@2814
|
21 |
- (id) init {
|
|
rudy@2814
|
22 |
int sizePref = MUSICVIDEO_SIZE_NORMAL;
|
|
rudy@2814
|
23 |
|
|
evands@3859
|
24 |
screenNumber = 0U;
|
|
evands@3859
|
25 |
READ_GROWL_PREF_INT(MUSICVIDEO_SCREEN_PREF, GrowlMusicVideoPrefDomain, &screenNumber);
|
|
evands@3954
|
26 |
NSArray *screens = [NSScreen screens];
|
|
ingmarstein@3958
|
27 |
unsigned screensCount = [screens count];
|
|
evands@3954
|
28 |
if (screensCount) {
|
|
evands@3954
|
29 |
[self setScreen:((screensCount >= (screenNumber + 1)) ? [screens objectAtIndex:screenNumber] : [screens objectAtIndex:0])];
|
|
evands@3954
|
30 |
}
|
|
evands@3859
|
31 |
|
|
rudy@2814
|
32 |
NSRect sizeRect;
|
|
rudy@2814
|
33 |
NSRect screen = [[self screen] frame];
|
|
rudy@2814
|
34 |
READ_GROWL_PREF_INT(MUSICVIDEO_SIZE_PREF, GrowlMusicVideoPrefDomain, &sizePref);
|
|
rudy@2814
|
35 |
sizeRect.origin = screen.origin;
|
|
rudy@2814
|
36 |
sizeRect.size.width = screen.size.width;
|
|
rudy@2814
|
37 |
if (sizePref == MUSICVIDEO_SIZE_HUGE)
|
|
rudy@2814
|
38 |
sizeRect.size.height = 192.0f;
|
|
rudy@2814
|
39 |
else
|
|
rudy@2814
|
40 |
sizeRect.size.height = 96.0f;
|
|
rudy@2814
|
41 |
frameHeight = sizeRect.size.height;
|
|
rudy@2814
|
42 |
|
|
rudy@2814
|
43 |
READ_GROWL_PREF_INT(MUSICVIDEO_SIZE_PREF, GrowlMusicVideoPrefDomain, &sizePref);
|
|
rudy@2814
|
44 |
NSPanel *panel = [[NSPanel alloc] initWithContentRect:sizeRect
|
|
rudy@2814
|
45 |
styleMask:NSBorderlessWindowMask
|
|
rudy@2814
|
46 |
backing:NSBackingStoreBuffered
|
|
rudy@3005
|
47 |
defer:YES];
|
|
rudy@2814
|
48 |
NSRect panelFrame = [panel frame];
|
|
rudy@2814
|
49 |
[panel setBecomesKeyOnlyIfNeeded:YES];
|
|
rudy@2814
|
50 |
[panel setHidesOnDeactivate:NO];
|
|
rudy@2814
|
51 |
[panel setBackgroundColor:[NSColor clearColor]];
|
|
rudy@2814
|
52 |
[panel setLevel:NSStatusWindowLevel];
|
|
rudy@2814
|
53 |
[panel setIgnoresMouseEvents:YES];
|
|
rudy@2814
|
54 |
[panel setSticky:YES];
|
|
rudy@2814
|
55 |
[panel setOpaque:NO];
|
|
rudy@2814
|
56 |
[panel setHasShadow:NO];
|
|
rudy@2814
|
57 |
[panel setCanHide:NO];
|
|
rudy@2814
|
58 |
[panel setOneShot:YES];
|
|
rudy@2814
|
59 |
[panel useOptimizedDrawing:YES];
|
|
rudy@2814
|
60 |
[panel setDelegate:self];
|
|
rudy@2814
|
61 |
|
|
rudy@2824
|
62 |
GrowlMusicVideoWindowView *view = [[GrowlMusicVideoWindowView alloc] initWithFrame:panelFrame];
|
|
rudy@2814
|
63 |
|
|
rudy@2814
|
64 |
[view setTarget:self];
|
|
rudy@2814
|
65 |
[view setAction:@selector(notificationClicked:)]; // Not used for now
|
|
rudy@2814
|
66 |
|
|
rudy@2814
|
67 |
[panel setContentView:view]; // retains subview
|
|
rudy@2824
|
68 |
[view release];
|
|
rudy@2824
|
69 |
|
|
evands@3859
|
70 |
[panel setFrameTopLeftPoint:screen.origin];
|
|
ingmarstein@2943
|
71 |
|
|
rudy@2824
|
72 |
// call super so everything else is set up...
|
|
ingmarstein@2943
|
73 |
if ((self = [super initWithWindow:panel])) {
|
|
evands@3830
|
74 |
CFNumberRef prefsDuration = NULL;
|
|
evands@3830
|
75 |
READ_GROWL_PREF_VALUE(MUSICVIDEO_DURATION_PREF, GrowlMusicVideoPrefDomain, CFNumberRef, &prefsDuration);
|
|
evands@3830
|
76 |
[self setDisplayDuration:(prefsDuration ?
|
|
evands@3830
|
77 |
[(NSNumber *)prefsDuration doubleValue] :
|
|
rudy@3832
|
78 |
GrowlMusicVideoDurationPrefDefault)];
|
|
boredzo@4135
|
79 |
if (prefsDuration) CFRelease(prefsDuration);
|
|
evands@3830
|
80 |
|
|
evands@3830
|
81 |
//The default duration for transitions is far too long for the music video effect.
|
|
evands@3830
|
82 |
[self setTransitionDuration:0.3];
|
|
evands@3859
|
83 |
|
|
evands@3554
|
84 |
MusicVideoEffectType effect = MUSICVIDEO_EFFECT_SLIDE;
|
|
ingmarstein@2943
|
85 |
READ_GROWL_PREF_INT(MUSICVIDEO_EFFECT_PREF, GrowlMusicVideoPrefDomain, &effect);
|
|
evands@3554
|
86 |
switch (effect)
|
|
evands@3554
|
87 |
{
|
|
evands@3554
|
88 |
case MUSICVIDEO_EFFECT_SLIDE:
|
|
evands@3554
|
89 |
{
|
|
evands@3554
|
90 |
//slider effect
|
|
evands@3554
|
91 |
GrowlSlidingWindowTransition *slider = [[GrowlSlidingWindowTransition alloc] initWithWindow:panel];
|
|
evands@3859
|
92 |
[slider setFromOrigin:NSMakePoint(NSMinX(screen),NSMinY(screen)-frameHeight) toOrigin:NSMakePoint(NSMinX(screen),NSMinY(screen))];
|
|
evands@3554
|
93 |
[self setStartPercentage:0 endPercentage:100 forTransition:slider];
|
|
evands@3554
|
94 |
[slider setAutoReverses:YES];
|
|
evands@3554
|
95 |
[self addTransition:slider];
|
|
evands@3554
|
96 |
[slider release];
|
|
evands@3554
|
97 |
break;
|
|
evands@3554
|
98 |
}
|
|
evands@3554
|
99 |
case MUSICVIDEO_EFFECT_FADING:
|
|
evands@3554
|
100 |
{
|
|
evands@3554
|
101 |
GrowlFadingWindowTransition *fader = [[GrowlFadingWindowTransition alloc] initWithWindow:panel];
|
|
evands@3554
|
102 |
[self addTransition:fader];
|
|
evands@3554
|
103 |
[self setStartPercentage:0 endPercentage:100 forTransition:fader];
|
|
evands@3554
|
104 |
[fader setAutoReverses:YES];
|
|
evands@3554
|
105 |
[fader release];
|
|
evands@3554
|
106 |
|
|
evands@3554
|
107 |
// I am adding in a sliding transition from screen,screen to screen,screen to make sure the window is properly positioned during the animation - swr
|
|
evands@3554
|
108 |
GrowlSlidingWindowTransition *slider = [[GrowlSlidingWindowTransition alloc] initWithWindow:panel];
|
|
rudy@3282
|
109 |
[slider setFromOrigin:NSMakePoint(NSMinX(screen),NSMinY(screen)) toOrigin:NSMakePoint(NSMinX(screen),NSMinY(screen))];
|
|
rudy@3282
|
110 |
[self setStartPercentage:0 endPercentage:100 forTransition:slider];
|
|
rudy@3282
|
111 |
[slider setAutoReverses:YES];
|
|
rudy@3282
|
112 |
[self addTransition:slider];
|
|
rudy@3282
|
113 |
[slider release];
|
|
evands@3554
|
114 |
break;
|
|
evands@3554
|
115 |
}
|
|
evands@3554
|
116 |
case MUSICVIDEO_EFFECT_WIPE:
|
|
evands@3554
|
117 |
{
|
|
evands@3640
|
118 |
NSLog(@"Wipe not implemented");
|
|
evands@3554
|
119 |
//wipe effect
|
|
evands@3554
|
120 |
//[panel setFrameOrigin:NSMakePoint( 0, 0)];
|
|
evands@3554
|
121 |
//GrowlWipeWindowTransition *wiper = [[GrowlWipeWindowTransition alloc] initWithWindow:panel];
|
|
evands@3554
|
122 |
// save for scale effect [wiper setFromOrigin:NSMakePoint(0,0) toOrigin:NSMakePoint(NSMaxX(screen), frameHeight)];
|
|
evands@3554
|
123 |
//[wiper setFromOrigin:NSMakePoint(NSMaxX(screen), 0) toOrigin:NSMakePoint(NSMaxX(screen), frameHeight)];
|
|
evands@3554
|
124 |
//[self setStartPercentage:0 endPercentage:100 forTransition:wiper];
|
|
evands@3554
|
125 |
//[wiper setAutoReverses:YES];
|
|
evands@3554
|
126 |
//[self addTransition:wiper];
|
|
evands@3554
|
127 |
//[wiper release];
|
|
evands@3554
|
128 |
break;
|
|
evands@3554
|
129 |
}
|
|
ingmarstein@2943
|
130 |
}
|
|
rudy@2830
|
131 |
}
|
|
evands@3543
|
132 |
|
|
evands@3543
|
133 |
[panel release];
|
|
evands@3554
|
134 |
|
|
rudy@2824
|
135 |
return self;
|
|
rudy@2824
|
136 |
|
|
rudy@2814
|
137 |
}
|
|
rudy@2814
|
138 |
|
|
rudy@2814
|
139 |
- (void) setNotification: (GrowlApplicationNotification *) theNotification {
|
|
rudy@2814
|
140 |
[super setNotification:theNotification];
|
|
rudy@2814
|
141 |
if (!theNotification)
|
|
rudy@2814
|
142 |
return;
|
|
ingmarstein@2943
|
143 |
|
|
rudy@2814
|
144 |
NSDictionary *noteDict = [notification dictionaryRepresentation];
|
|
rudy@2814
|
145 |
NSString *title = [notification title];
|
|
evands@2922
|
146 |
NSString *text = [notification notificationDescription];
|
|
rudy@2814
|
147 |
NSImage *icon = getObjectForKey(noteDict, GROWL_NOTIFICATION_ICON);
|
|
ingmarstein@2941
|
148 |
int prio = getIntegerForKey(noteDict, GROWL_NOTIFICATION_PRIORITY);
|
|
ingmarstein@2943
|
149 |
|
|
rudy@2814
|
150 |
NSPanel *panel = (NSPanel *)[self window];
|
|
rudy@2824
|
151 |
GrowlMusicVideoWindowView *view = [panel contentView];
|
|
ingmarstein@2941
|
152 |
[view setPriority:prio];
|
|
bgannin@3404
|
153 |
[view setTitle:title];
|
|
bgannin@3404
|
154 |
[view setText:text];
|
|
rudy@2814
|
155 |
[view setIcon:icon];
|
|
rudy@2814
|
156 |
}
|
|
rudy@2814
|
157 |
|
|
boredzo@2402
|
158 |
@end
|