]> git.sesse.net Git - vlc/blob - modules/gui/macosx/intf.h
macosx: Use a toolbar to display controls. (Doesn't look like a toolbar though)
[vlc] / modules / gui / macosx / intf.h
1 /*****************************************************************************
2  * intf.h: MacOS X interface module
3  *****************************************************************************
4  * Copyright (C) 2002-2008 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
8  *          Christophe Massiot <massiot@via.ecp.fr>
9  *          Derk-Jan Hartman <hartman at videolan dot org>
10  *          Felix Paul Kühne <fkuehne at videolan dot org>
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25  *****************************************************************************/
26
27 #ifdef HAVE_CONFIG_H
28 #   include "config.h"
29 #endif
30
31 #include <vlc_common.h>
32 #include <vlc_interface.h>
33 #include <vlc_playlist.h>
34 #include <vlc_vout.h>
35 #include <vlc_aout.h>
36 #include <vlc_input.h>
37
38 #include <Cocoa/Cocoa.h>
39
40 /* this was introduced in Darwin 9. We need to declare it to prevent both
41  * compilation warnings and errors */
42 #ifndef NSInteger
43 #define NSInteger int
44 #endif
45
46 /*****************************************************************************
47  * Local prototypes.
48  *****************************************************************************/
49 unsigned int CocoaKeyToVLC( unichar i_key );
50
51 #define VLCIntf [[VLCMain sharedInstance] getIntf]
52
53 #define _NS(s) [[VLCMain sharedInstance] localizedString: _(s)]
54 /* Get an alternate version of the string.
55  * This string is stored as '1:string' but when displayed it only displays
56  * the translated string. the translation should be '1:translatedstring' though */
57 #define _ANS(s) [[[VLCMain sharedInstance] localizedString: _(s)] substringFromIndex:2]
58
59 #define MACOS_VERSION [[[NSDictionary dictionaryWithContentsOfFile: \
60             @"/System/Library/CoreServices/SystemVersion.plist"] \
61             objectForKey: @"ProductVersion"] floatValue]
62
63 /*****************************************************************************
64  * intf_sys_t: description and status of the interface
65  *****************************************************************************/
66 struct intf_sys_t
67 {
68     NSAutoreleasePool * o_pool;
69
70     /* special actions */
71     bool b_mute;
72     int i_play_status;
73
74     /* interface update */
75     bool b_intf_update;
76     bool b_playlist_update;
77     bool b_playmode_update;
78     bool b_current_title_update;
79     bool b_fullscreen_update;
80     bool b_volume_update;
81     bool b_intf_show;
82
83     /* menus handlers */
84     bool b_input_update;
85     bool b_aout_update;
86     bool b_vout_update;
87
88     /* The messages window */
89     msg_subscription_t * p_sub;
90 };
91
92 /*****************************************************************************
93  * VLCMain interface
94  *****************************************************************************/
95 @class AppleRemote;
96 @class VLCInformation;
97 @class VLControllerWindow;
98 @class VLCEmbeddedWindow;
99 @class VLCControls;
100 @class VLCPlaylist;
101 @interface VLCMain : NSObject
102 {
103     intf_thread_t *p_intf;      /* The main intf object */
104     id o_prefs;                 /* VLCPrefs       */
105     id o_sprefs;                /* VLCSimplePrefs */
106     id o_about;                 /* VLAboutBox     */
107     id o_open;                  /* VLCOpen        */
108     id o_wizard;                /* VLCWizard      */
109     id o_extended;              /* VLCExtended    */
110     id o_bookmarks;             /* VLCBookmarks   */
111     id o_embedded_list;         /* VLCEmbeddedList*/
112     id o_interaction_list;      /* VLCInteractionList*/
113     VLCInformation * o_info;                  /* VLCInformation */
114 #ifdef UPDATE_CHECK
115     id o_update;                /* VLCUpdate      */
116 #endif
117     id o_eyetv;                 /* VLCEyeTVController */
118     BOOL nib_main_loaded;       /* main nibfile */
119     BOOL nib_open_loaded;       /* open nibfile */
120     BOOL nib_about_loaded;      /* about nibfile */
121     BOOL nib_wizard_loaded;     /* wizard nibfile */
122     BOOL nib_extended_loaded;   /* extended nibfile */
123     BOOL nib_bookmarks_loaded;  /* bookmarks nibfile */
124     BOOL nib_prefs_loaded;      /* preferences nibfile */
125     BOOL nib_update_loaded;     /* update nibfile */
126     BOOL nib_info_loaded;       /* information panel nibfile */
127
128     IBOutlet VLControllerWindow * o_window;       /* main window    */
129     IBOutlet NSView * o_playlist_view;/* playlist view  */
130     IBOutlet id o_scrollfield;  /* info field     */
131     IBOutlet NSTextField * o_timefield;    /* time field     */
132     IBOutlet NSSlider * o_timeslider;   /* time slider    */
133     IBOutlet VLCEmbeddedWindow * o_embedded_window; /* Embedded Vout Window */
134     float f_slider;             /* slider value   */
135     float f_slider_old;         /* old slider val */
136     IBOutlet NSSlider * o_volumeslider; /* volume slider  */
137
138     IBOutlet NSView * toolbarMediaControl;   /* view with the controls */
139
140     IBOutlet NSProgressIndicator * o_main_pgbar;   /* playlist window progress bar */
141     IBOutlet NSButton * o_btn_prev;     /* btn previous   */
142     IBOutlet NSButton * o_btn_rewind;   /* btn rewind     */
143     IBOutlet NSButton * o_btn_play;     /* btn play       */
144     IBOutlet NSButton * o_btn_stop;     /* btn stop       */
145     IBOutlet NSButton * o_btn_ff;       /* btn fast forward     */
146     IBOutlet NSButton * o_btn_next;     /* btn next       */
147     IBOutlet NSButton * o_btn_fullscreen;/* btn fullscreen (embedded vout window) */
148     IBOutlet NSButton * o_btn_playlist; /* btn playlist   */
149     IBOutlet NSButton * o_btn_equalizer; /* eq btn */
150
151     NSImage * o_img_play;       /* btn play img   */
152     NSImage * o_img_pause;      /* btn pause img  */
153     NSImage * o_img_play_pressed;       /* btn play img   */
154     NSImage * o_img_pause_pressed;      /* btn pause img  */
155
156     IBOutlet VLCControls * o_controls;     /* VLCControls    */
157     IBOutlet VLCPlaylist * o_playlist;     /* VLCPlaylist    */
158
159     IBOutlet id o_messages;     /* messages tv    */
160     IBOutlet id o_msgs_panel;   /* messages panel */
161     NSMutableArray * o_msg_arr; /* messages array */
162     NSLock * o_msg_lock;        /* messages lock  */
163     IBOutlet NSButton * o_msgs_btn_crashlog;    /* messages open crashlog */
164
165     /* main menu */
166
167     IBOutlet NSMenuItem * o_mi_about;
168     IBOutlet NSMenuItem * o_mi_prefs;
169     IBOutlet NSMenuItem * o_mi_sprefs;
170     IBOutlet NSMenuItem * o_mi_checkForUpdate;
171     IBOutlet NSMenuItem * o_mi_add_intf;
172     IBOutlet NSMenu * o_mu_add_intf;
173     IBOutlet NSMenuItem * o_mi_services;
174     IBOutlet NSMenuItem * o_mi_hide;
175     IBOutlet NSMenuItem * o_mi_hide_others;
176     IBOutlet NSMenuItem * o_mi_show_all;
177     IBOutlet NSMenuItem * o_mi_quit;
178
179     IBOutlet NSMenu * o_mu_file;
180     IBOutlet NSMenuItem * o_mi_open_file;
181     IBOutlet NSMenuItem * o_mi_open_generic;
182     IBOutlet NSMenuItem * o_mi_open_disc;
183     IBOutlet NSMenuItem * o_mi_open_net;
184     IBOutlet NSMenuItem * o_mi_open_capture;
185     IBOutlet NSMenuItem * o_mi_open_recent;
186     IBOutlet NSMenuItem * o_mi_open_recent_cm;
187     IBOutlet NSMenuItem * o_mi_open_wizard;
188
189     IBOutlet NSMenu * o_mu_edit;
190     IBOutlet NSMenuItem * o_mi_cut;
191     IBOutlet NSMenuItem * o_mi_copy;
192     IBOutlet NSMenuItem * o_mi_paste;
193     IBOutlet NSMenuItem * o_mi_clear;
194     IBOutlet NSMenuItem * o_mi_select_all;
195
196     IBOutlet NSMenu * o_mu_controls;
197     IBOutlet NSMenuItem * o_mi_play;
198     IBOutlet NSMenuItem * o_mi_stop;
199     IBOutlet NSMenuItem * o_mi_faster;
200     IBOutlet NSMenuItem * o_mi_slower;
201     IBOutlet NSMenuItem * o_mi_previous;
202     IBOutlet NSMenuItem * o_mi_next;
203     IBOutlet NSMenuItem * o_mi_random;
204     IBOutlet NSMenuItem * o_mi_repeat;
205     IBOutlet NSMenuItem * o_mi_loop;
206     IBOutlet NSMenuItem * o_mi_fwd;
207     IBOutlet NSMenuItem * o_mi_bwd;
208     IBOutlet NSMenuItem * o_mi_fwd1m;
209     IBOutlet NSMenuItem * o_mi_bwd1m;
210     IBOutlet NSMenuItem * o_mi_fwd5m;
211     IBOutlet NSMenuItem * o_mi_bwd5m;
212     IBOutlet NSMenuItem * o_mi_program;
213     IBOutlet NSMenuItem * o_mu_program;
214     IBOutlet NSMenuItem * o_mi_title;
215     IBOutlet NSMenu * o_mu_title;
216     IBOutlet NSMenuItem * o_mi_chapter;
217     IBOutlet NSMenu * o_mu_chapter;
218
219     IBOutlet NSMenu * o_mu_audio;
220     IBOutlet NSMenuItem * o_mi_vol_up;
221     IBOutlet NSMenuItem * o_mi_vol_down;
222     IBOutlet NSMenuItem * o_mi_mute;
223     IBOutlet NSMenuItem * o_mi_audiotrack;
224     IBOutlet NSMenu * o_mu_audiotrack;
225     IBOutlet NSMenuItem * o_mi_channels;
226     IBOutlet NSMenu * o_mu_channels;
227     IBOutlet NSMenuItem * o_mi_device;
228     IBOutlet NSMenu * o_mu_device;
229     IBOutlet NSMenuItem * o_mi_visual;
230     IBOutlet NSMenu * o_mu_visual;
231
232     IBOutlet NSMenu * o_mu_video;
233     IBOutlet NSMenuItem * o_mi_half_window;
234     IBOutlet NSMenuItem * o_mi_normal_window;
235     IBOutlet NSMenuItem * o_mi_double_window;
236     IBOutlet NSMenuItem * o_mi_fittoscreen;
237     IBOutlet NSMenuItem * o_mi_fullscreen;
238     IBOutlet NSMenuItem * o_mi_floatontop;
239     IBOutlet NSMenuItem * o_mi_snapshot;
240     IBOutlet NSMenuItem * o_mi_videotrack;
241     IBOutlet NSMenu * o_mu_videotrack;
242     IBOutlet NSMenuItem * o_mi_screen;
243     IBOutlet NSMenu * o_mu_screen;
244     IBOutlet NSMenuItem * o_mi_aspect_ratio;
245     IBOutlet NSMenu * o_mu_aspect_ratio;
246     IBOutlet NSMenuItem * o_mi_crop;
247     IBOutlet NSMenu * o_mu_crop;
248     IBOutlet NSMenuItem * o_mi_subtitle;
249     IBOutlet NSMenu * o_mu_subtitle;
250     IBOutlet NSMenuItem * o_mi_deinterlace;
251     IBOutlet NSMenu * o_mu_deinterlace;
252     IBOutlet NSMenuItem * o_mi_ffmpeg_pp;
253     IBOutlet NSMenuItem * o_mu_ffmpeg_pp;
254
255     IBOutlet NSMenu * o_mu_window;
256     IBOutlet NSMenuItem * o_mi_minimize;
257     IBOutlet NSMenuItem * o_mi_close_window;
258     IBOutlet NSMenuItem * o_mi_controller;
259     IBOutlet NSMenuItem * o_mi_equalizer;
260     IBOutlet NSMenuItem * o_mi_extended;
261     IBOutlet NSMenuItem * o_mi_bookmarks;
262     IBOutlet NSMenuItem * o_mi_playlist;
263     IBOutlet NSMenuItem * o_mi_info;
264     IBOutlet NSMenuItem * o_mi_messages;
265     IBOutlet NSMenuItem * o_mi_bring_atf;
266
267     IBOutlet NSMenu * o_mu_help;
268     IBOutlet NSMenuItem * o_mi_help;
269     IBOutlet NSMenuItem * o_mi_readme;
270     IBOutlet NSMenuItem * o_mi_documentation;
271     IBOutlet NSMenuItem * o_mi_license;
272     IBOutlet NSMenuItem * o_mi_website;
273     IBOutlet NSMenuItem * o_mi_donation;
274     IBOutlet NSMenuItem * o_mi_forum;
275     IBOutlet NSMenuItem * o_mi_errorsAndWarnings;
276
277     /* dock menu */
278     IBOutlet NSMenuItem * o_dmi_play;
279     IBOutlet NSMenuItem * o_dmi_stop;
280     IBOutlet NSMenuItem * o_dmi_next;
281     IBOutlet NSMenuItem * o_dmi_previous;
282     IBOutlet NSMenuItem * o_dmi_mute;
283
284     /* vout menu */
285     IBOutlet NSMenu * o_vout_menu;
286     IBOutlet NSMenuItem * o_vmi_play;
287     IBOutlet NSMenuItem * o_vmi_stop;
288     IBOutlet NSMenuItem * o_vmi_prev;
289     IBOutlet NSMenuItem * o_vmi_next;
290     IBOutlet NSMenuItem * o_vmi_volup;
291     IBOutlet NSMenuItem * o_vmi_voldown;
292     IBOutlet NSMenuItem * o_vmi_mute;
293     IBOutlet NSMenuItem * o_vmi_fullscreen;
294     IBOutlet NSMenuItem * o_vmi_snapshot;
295
296     bool b_small_window;
297
298     bool b_restore_size;
299     NSRect o_restore_rect;
300
301     mtime_t i_end_scroll;
302
303     NSSize o_size_with_playlist;
304
305     int     i_lastShownVolume;
306
307     /* the manage thread */
308     pthread_t manage_thread;
309
310     /* The timer that update the interface */
311     NSTimer * interfaceTimer;
312
313     AppleRemote * o_remote;
314     BOOL b_remote_button_hold; /* true as long as the user holds the left,right,plus or minus on the remote control */
315 }
316
317 + (VLCMain *)sharedInstance;
318
319 - (intf_thread_t *)getIntf;
320 - (void)setIntf:(intf_thread_t *)p_mainintf;
321
322 - (void)controlTintChanged;
323
324 - (id)getControls;
325 - (id)getSimplePreferences;
326 - (id)getPreferences;
327 - (id)getPlaylist;
328 - (id)getInfo;
329 - (id)getWizard;
330 - (id)getBookmarks;
331 - (id)getEmbeddedList;
332 - (id)getInteractionList;
333 - (id)getMainIntfPgbar;
334 - (id)getControllerWindow;
335 - (id)getVoutMenu;
336 - (id)getEyeTVController;
337 - (void)applicationWillTerminate:(NSNotification *)notification;
338 - (NSString *)localizedString:(const char *)psz;
339 - (char *)delocalizeString:(NSString *)psz;
340 - (NSString *)wrapString: (NSString *)o_in_string toWidth: (int)i_width;
341 - (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event;
342
343 - (void)initStrings;
344
345 - (void)manage;
346 - (void)manageIntf:(NSTimer *)o_timer;
347 - (void)setupMenus;
348 - (void)refreshVoutDeviceMenu:(NSNotification *)o_notification;
349 - (void)setScrollField:(NSString *)o_string stopAfter:(int )timeout;
350 - (void)resetScrollField;
351
352 - (void)updateMessageArray;
353 - (void)playStatusUpdated:(int) i_status;
354 - (void)setSubmenusEnabled:(BOOL)b_enabled;
355 - (void)manageVolumeSlider;
356 - (IBAction)timesliderUpdate:(id)sender;
357
358 - (IBAction)clearRecentItems:(id)sender;
359 - (void)openRecentItem:(id)sender;
360
361 - (IBAction)intfOpenFile:(id)sender;
362 - (IBAction)intfOpenFileGeneric:(id)sender;
363 - (IBAction)intfOpenDisc:(id)sender;
364 - (IBAction)intfOpenNet:(id)sender;
365 - (IBAction)intfOpenCapture:(id)sender;
366
367 - (IBAction)showWizard:(id)sender;
368 - (IBAction)showExtended:(id)sender;
369 - (IBAction)showBookmarks:(id)sender;
370
371 - (IBAction)viewAbout:(id)sender;
372 - (IBAction)showLicense:(id)sender;
373 - (IBAction)viewPreferences:(id)sender;
374 - (IBAction)checkForUpdate:(id)sender;
375 - (IBAction)viewHelp:(id)sender;
376 - (IBAction)openReadMe:(id)sender;
377 - (IBAction)openDocumentation:(id)sender;
378 - (IBAction)openWebsite:(id)sender;
379 - (IBAction)openForum:(id)sender;
380 - (IBAction)openDonate:(id)sender;
381 - (IBAction)openCrashLog:(id)sender;
382 - (IBAction)viewErrorsAndWarnings:(id)sender;
383 - (IBAction)showMessagesPanel:(id)sender;
384 - (IBAction)showInformationPanel:(id)sender;
385
386 - (IBAction)togglePlaylist:(id)sender;
387 - (void)updateTogglePlaylistState;
388
389 - (void)windowDidBecomeKey:(NSNotification *)o_notification;
390
391 @end
392
393 @interface VLCMain (Internal)
394 - (void)handlePortMessage:(NSPortMessage *)o_msg;
395 @end