]> git.sesse.net Git - vlc/blob - modules/gui/macosx/intf.h
macosx: added basic 'vout window nsobject' capabilities with a test window
[vlc] / modules / gui / macosx / intf.h
1 /*****************************************************************************
2  * intf.h: MacOS X interface module
3  *****************************************************************************
4  * Copyright (C) 2002-2011 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 #import "SPMediaKeyTap.h"                   /* for the media key support */
40
41 /*****************************************************************************
42  * Local prototypes.
43  *****************************************************************************/
44 unsigned int CocoaKeyToVLC( unichar i_key );
45
46 #define VLCIntf [[VLCMain sharedInstance] intf]
47
48 #define _NS(s) [[VLCMain sharedInstance] localizedString: _(s)]
49 /* Get an alternate version of the string.
50  * This string is stored as '1:string' but when displayed it only displays
51  * the translated string. the translation should be '1:translatedstring' though */
52 #define _ANS(s) [[[VLCMain sharedInstance] localizedString: _(s)] substringFromIndex:2]
53
54 #define MACOS_VERSION [[[NSDictionary dictionaryWithContentsOfFile: \
55             @"/System/Library/CoreServices/SystemVersion.plist"] \
56             objectForKey: @"ProductVersion"] floatValue]
57
58
59 // You need to release those objects after use
60 input_thread_t *getInput(void);
61 vout_thread_t *getVout(void);
62 aout_instance_t *getAout(void);
63
64 /*****************************************************************************
65  * intf_sys_t: description and status of the interface
66  *****************************************************************************/
67 struct intf_sys_t
68 {
69     /* special actions */
70     bool b_mute;
71     int i_play_status;
72
73     /* interface update */
74     bool b_intf_update;
75     bool b_playlist_update;
76     bool b_playmode_update;
77     bool b_current_title_update;
78     bool b_fullscreen_update;
79     bool b_volume_update;
80     bool b_intf_show;
81
82     /* menus handlers */
83     bool b_input_update;
84     bool b_aout_update;
85     bool b_vout_update;
86
87     /* The messages window */
88     msg_subscription_t * p_sub;
89 };
90
91 /*****************************************************************************
92  * VLCMain interface
93  *****************************************************************************/
94 @class AppleRemote;
95 @class VLCInformation;
96 @class VLCControllerWindow;
97 @class VLCEmbeddedWindow;
98 @class VLCControls;
99 @class VLCPlaylist;
100 @interface VLCMain : NSObject
101 {
102     intf_thread_t *p_intf;      /* The main intf object */
103     id o_mainmenu;              /* VLCMainMenu */
104     id o_prefs;                 /* VLCPrefs       */
105     id o_sprefs;                /* VLCSimplePrefs */
106     id o_open;                  /* VLCOpen        */
107     id o_wizard;                /* VLCWizard      */
108     id o_embedded_list;         /* VLCEmbeddedList*/
109     id o_coredialogs;           /* VLCCoreDialogProvider */
110     VLCInformation * o_info;    /* VLCInformation */
111     id o_eyetv;                 /* VLCEyeTVController */
112     id o_bookmarks;             /* VLCBookmarks */
113     id o_coreinteraction;       /* VLCCoreInteraction */
114     BOOL nib_main_loaded;       /* main nibfile */
115     BOOL nib_open_loaded;       /* open nibfile */
116     BOOL nib_about_loaded;      /* about nibfile */
117     BOOL nib_wizard_loaded;     /* wizard nibfile */
118     BOOL nib_prefs_loaded;      /* preferences nibfile */
119     BOOL nib_info_loaded;       /* information panel nibfile */
120     BOOL nib_coredialogs_loaded; /* CoreDialogs nibfile */
121     BOOL nib_bookmarks_loaded;   /* Bookmarks nibfile */
122
123     IBOutlet VLCControllerWindow * o_window;                     /* main window */
124     IBOutlet id o_scrollfield;                                  /* info field */
125     IBOutlet NSTextField * o_timefield;                         /* time field */
126     IBOutlet NSSlider * o_timeslider;                                 /* time slider */
127     BOOL b_time_remaining;                                      /* show remaining time or playtime ? */
128     IBOutlet VLCEmbeddedWindow * o_embedded_window;             /* Embedded Vout Window */
129     float f_slider;                                             /* slider value */
130     float f_slider_old;                                         /* old slider val */
131     IBOutlet NSSlider * o_volumeslider;                         /* volume slider */
132
133     IBOutlet NSProgressIndicator * o_main_pgbar;   /* playlist window progress bar */
134     IBOutlet NSButton * o_btn_prev;     /* btn previous   */
135     IBOutlet NSButton * o_btn_rewind;   /* btn rewind     */
136     IBOutlet NSButton * o_btn_play;     /* btn play       */
137     IBOutlet NSButton * o_btn_stop;     /* btn stop       */
138     IBOutlet NSButton * o_btn_ff;       /* btn fast forward     */
139     IBOutlet NSButton * o_btn_next;     /* btn next       */
140     IBOutlet NSButton * o_btn_fullscreen;/* btn fullscreen (embedded vout window) */
141     IBOutlet NSButton * o_btn_playlist; /* btn playlist   */
142     IBOutlet NSButton * o_btn_audioEffects; /* AudioEffects btn */
143
144     NSImage * o_img_play;       /* btn play img   */
145     NSImage * o_img_pause;      /* btn pause img  */
146     NSImage * o_img_play_pressed;       /* btn play img   */
147     NSImage * o_img_pause_pressed;      /* btn pause img  */
148
149     IBOutlet VLCControls * o_controls;     /* VLCControls    */
150     IBOutlet VLCPlaylist * o_playlist;     /* VLCPlaylist    */
151
152     IBOutlet NSTextView * o_messages;           /* messages tv    */
153     IBOutlet NSWindow * o_msgs_panel;           /* messages panel */
154     NSMutableArray * o_msg_arr;                 /* messages array */
155     NSLock * o_msg_lock;                        /* messages lock */
156     BOOL b_msg_arr_changed;                     /* did the array change? */
157     IBOutlet NSButton * o_msgs_crashlog_btn;    /* messages open crashlog */
158     IBOutlet NSButton * o_msgs_save_btn;        /* save the log as rtf */
159
160     /* CrashReporter panel */
161     IBOutlet NSButton * o_crashrep_dontSend_btn;
162     IBOutlet NSButton * o_crashrep_send_btn;
163     IBOutlet NSTextView * o_crashrep_fld;
164     IBOutlet NSTextField * o_crashrep_title_txt;
165     IBOutlet NSTextField * o_crashrep_desc_txt;
166     IBOutlet NSWindow * o_crashrep_win;
167     IBOutlet NSButton * o_crashrep_includeEmail_ckb;
168     IBOutlet NSTextField * o_crashrep_includeEmail_txt;
169
170     mtime_t i_end_scroll;
171
172     int     i_lastShownVolume;
173
174     input_state_e cachedInputState;
175
176     /* the manage thread */
177     pthread_t manage_thread;
178
179     /* The timer that update the interface */
180     NSTimer * interfaceTimer;
181
182     NSURLConnection * crashLogURLConnection;
183
184     AppleRemote * o_remote;
185     BOOL b_remote_button_hold; /* true as long as the user holds the left,right,plus or minus on the remote control */
186
187     /* media key support */
188     BOOL b_mediaKeySupport;
189     BOOL b_mediakeyJustJumped;
190     SPMediaKeyTap * o_mediaKeyController;
191
192     NSArray *o_usedHotkeys;
193 }
194
195 + (VLCMain *)sharedInstance;
196
197 - (intf_thread_t *)intf;
198 - (void)setIntf:(intf_thread_t *)p_mainintf;
199
200 - (id)mainMenu;
201 - (id)controls;
202 - (id)bookmarks;
203 - (id)open;
204 - (id)simplePreferences;
205 - (id)preferences;
206 - (id)playlist;
207 - (BOOL)isPlaylistCollapsed;
208 - (id)info;
209 - (id)wizard;
210 - (id)embeddedList;
211 - (id)getVideoViewAtPositionX: (int *)pi_x Y: (int *)pi_y withWidth: (unsigned int*)pi_width andHeight: (unsigned int*)pi_height;
212 - (id)coreDialogProvider;
213 - (id)mainIntfPgbar;
214 - (id)controllerWindow;
215 - (id)eyeTVController;
216 - (id)appleRemoteController;
217 - (void)applicationWillTerminate:(NSNotification *)notification;
218 - (NSString *)localizedString:(const char *)psz;
219 - (char *)delocalizeString:(NSString *)psz;
220 - (NSString *)wrapString: (NSString *)o_in_string toWidth: (int)i_width;
221 - (BOOL)hasDefinedShortcutKey:(NSEvent *)o_event;
222 - (NSString *)VLCKeyToString:(NSString *)theString;
223 - (unsigned int)VLCModifiersToCocoa:(NSString *)theString;
224 - (void)updateCurrentlyUsedHotkeys;
225
226 - (void)initStrings;
227 - (BOOL)application:(NSApplication *)o_app openFile:(NSString *)o_filename;
228
229 - (void)manage;
230 - (void)manageIntf:(NSTimer *)o_timer;
231
232 - (void)setScrollField:(NSString *)o_string stopAfter:(int )timeout;
233 - (void)resetScrollField;
234
235 - (void)updateMessageDisplay;
236 - (void)playStatusUpdated:(int) i_status;
237 - (void)manageVolumeSlider;
238 - (IBAction)timesliderUpdate:(id)sender;
239 - (IBAction)timeFieldWasClicked:(id)sender;
240 - (IBAction)showController:(id)sender;
241
242 - (IBAction)crashReporterAction:(id)sender;
243 - (IBAction)openCrashLog:(id)sender;
244 - (IBAction)saveDebugLog:(id)sender;
245 - (IBAction)showMessagesPanel:(id)sender;
246
247 - (IBAction)togglePlaylist:(id)sender;
248 - (void)updateTogglePlaylistState;
249
250 - (void)windowDidBecomeKey:(NSNotification *)o_notification;
251
252 - (void)mediaKeyTap:(SPMediaKeyTap*)keyTap receivedMediaKeyEvent:(NSEvent*)event;
253 @end
254
255 @interface VLCMain (Internal)
256 - (void)handlePortMessage:(NSPortMessage *)o_msg;
257 - (void)resetMediaKeyJump;
258 - (void)coreChangedMediaKeySupportSetting: (NSNotification *)o_notification;
259 @end
260
261 /*****************************************************************************
262  * VLCApplication interface
263  *****************************************************************************/
264
265 @interface VLCApplication : NSApplication
266 {
267 }
268 @end