1 /*****************************************************************************
2 * intf_controller.c : MacOS X plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2001 VideoLAN
7 * Authors: Florian G. Pflug <fgp@phlo.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
25 I need to subclass NSQuickDrawView, and post a notification when its display
26 method is called. This is necessary because GetPortBound and similar functions
27 return the actual on-screen size of the QDPort, which isn't updated immidiately
28 after calling e.g. setFrame
31 #include <QuickTime/QuickTime.h>
32 #include <ApplicationServices/ApplicationServices.h>
33 #import "intf_controller.h"
34 #import "intf_vlc_wrapper.h"
36 @implementation Intf_Controller
37 //Initialization & Event-Management
38 - (void) awakeFromNib {
39 o_vlc = [Intf_VlcWrapper instance] ;
40 b_window_is_fullscreen = FALSE ;
41 [NSTimer scheduledTimerWithTimeInterval: 0.5
43 selector: @selector(manage:)
47 [o_vlc initWithDelegate:self] ;
50 - (void) manage:(NSTimer *)timer {
52 [NSApp terminate: self] ;
54 [o_currenttime setStringValue: [o_vlc getTimeAsString]] ;
55 [o_timeslider setFloatValue: [o_vlc getTimeAsFloat]] ;
58 - (void)applicationDidBecomeActive:(NSNotification*)aNotification {
59 if (b_window_is_fullscreen) {
60 [o_window orderFront:self] ;
65 - (void)applicationDidResignActive:(NSNotification*)aNotification {
66 if (b_window_is_fullscreen) {
68 [o_window orderOut:self] ;
75 //Functions attached to user interface
76 - (IBAction) pause:(id)sender {
80 - (IBAction) play:(id)sender {
84 - (IBAction) timeslider_update:(id)slider {
85 [o_vlc setTimeAsFloat: [o_timeslider floatValue]] ;
88 - (IBAction) speedslider_update:(id)slider {
89 [o_vlc setSpeed: (intf_speed_t) [slider intValue]] ;
92 - (IBAction) fullscreen_toggle:(id)sender {
93 [self requestQDPortFullscreen:!b_window_is_fullscreen] ;
99 //Callbacks - we are the delegate for the VlcWrapper
100 - (void) requestQDPortFullscreen:(bool)b_fullscreen {
102 VlcQuickDrawView *o_qdview ;
104 s_rect.origin.x = s_rect.origin.y = 0 ;
106 [self releaseQDPort] ;
107 o_window = [NSWindow alloc] ;
110 initWithContentRect: [[NSScreen mainScreen] frame]
111 styleMask: NSBorderlessWindowMask
112 backing: NSBackingStoreBuffered
113 defer:NO screen:[NSScreen mainScreen]
115 [o_window setLevel:CGShieldingWindowLevel()] ;
116 b_window_is_fullscreen = TRUE ;
119 s_rect.size = [o_vlc videoSize] ;
121 initWithContentRect: s_rect
122 styleMask: (NSTitledWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask)
123 backing: NSBackingStoreBuffered
124 defer:NO screen:[NSScreen mainScreen]
126 [o_window setAspectRatio:[o_vlc videoSize]] ;
128 [o_window setDelegate:self] ;
129 b_window_is_fullscreen = FALSE ;
131 o_qdview = [[VlcQuickDrawView alloc] init] ;
132 [o_qdview setPostsFrameChangedNotifications:YES] ;
133 [[NSNotificationCenter defaultCenter]
135 selector: @selector(sizeChangeQDPort)
136 name: VlcQuickDrawViewDidResize
139 [o_window setContentView:o_qdview] ;
140 [o_window orderFront:self] ;
141 [o_vlc setQDPort:[o_qdview qdPort]] ;
142 [o_menu_fullscreen setState:(b_window_is_fullscreen ? NSOnState : NSOffState)] ;
145 - (void) releaseQDPort {
146 [[NSNotificationCenter defaultCenter]
149 object: [o_window contentView]
151 [o_vlc setQDPort:nil] ;
158 - (void) resizeQDPortFullscreen:(bool)b_fullscreen {
159 if (b_window_is_fullscreen != b_fullscreen) {
160 [self requestQDPortFullscreen:b_fullscreen] ;
162 else if (!b_window_is_fullscreen && !b_fullscreen) {
163 [o_window setAspectRatio:[o_vlc videoSize]] ;
168 @implementation Intf_PlaylistDS
169 - (void ) awakeFromNib {
170 o_vlc = [Intf_VlcWrapper instance] ;
171 o_playlist = [[NSMutableArray arrayWithCapacity:10] retain] ;
174 - (void) readPlaylist {
175 static unsigned int i_length_old = 0;
178 if (i_length_old == [o_vlc getPlaylistLength])
181 [o_playlist removeAllObjects] ;
182 [o_vlc lockPlaylist] ;
183 for(i=0; i < [o_vlc getPlaylistLength]; i++)
184 [o_playlist addObject:[o_vlc getPlaylistItem:i]] ;
185 [o_vlc unlockPlaylist] ;
188 - (int) numberOfRowsInTableView:(NSTableView*)o_table {
189 [self readPlaylist] ;
190 return [o_playlist count] ;
193 - (id) tableView:(NSTableView*)o_table objectValueForTableColumn:(NSTableColumn*)o_column row:(int)i_row {
194 return [o_playlist objectAtIndex:i_row] ;
197 - (void)tableView:(NSTableView *)aTableView setObjectValue:anObject forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex {