xref: /haiku/src/apps/mediaplayer/MainWin.h (revision 3be9edf8da228afd9fec0390f408c964766122aa)
1 /*
2  * MainWin.h - Media Player for the Haiku Operating System
3  *
4  * Copyright (C) 2006 Marcus Overhagen <marcus@overhagen.de>
5  * Copyright (C) 2007-2009 Stephan Aßmus <superstippi@gmx.de> (MIT ok)
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * version 2 as published by the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19  *
20  */
21 #ifndef __MAIN_WIN_H
22 #define __MAIN_WIN_H
23 
24 
25 #include <Window.h>
26 #include <Menu.h>
27 #include <Button.h>
28 #include <Slider.h>
29 
30 #include "Controller.h"
31 #include "ControllerView.h"
32 #include "InfoWin.h"
33 #include "ListenerAdapter.h"
34 #include "Playlist.h"
35 #include "PlaylistItem.h"
36 #include "VideoView.h"
37 
38 
39 class ControllerObserver;
40 class PlaylistObserver;
41 class PlaylistWindow;
42 
43 
44 class MainWin : public BWindow {
45 public:
46 								MainWin(bool isFirstWindow,
47 									BMessage* message = NULL);
48 	virtual						~MainWin();
49 
50 	virtual	void				FrameResized(float newWidth, float newHeight);
51 	virtual	void				Zoom(BPoint rectPosition, float rectWidth,
52 									float rectHeight);
53 	virtual	void				DispatchMessage(BMessage* message,
54 									BHandler* handler);
55 	virtual	void				MessageReceived(BMessage* message);
56 	virtual	void				WindowActivated(bool active);
57 	virtual	bool				QuitRequested();
58 	virtual	void				MenusBeginning();
59 
60 			void				OpenPlaylist(const BMessage* playlistArchive);
61 			void				OpenPlaylistItem(const PlaylistItemRef& item);
62 
63 			void				ShowFileInfo();
64 			void				ShowPlaylistWindow();
65 			void				ShowSettingsWindow();
66 
67 			void				VideoAspectChange(int forcedWidth,
68 									int forcedHeight, float widthScale);
69 			void				VideoAspectChange(float widthScale);
70 			void				VideoAspectChange(int widthAspect,
71 									int heightAspect);
72 			void				VideoFormatChange(int width, int height,
73 									int widthAspect, int heightAspect);
74 
75 private:
76 			void				_RefsReceived(BMessage* message);
77 			void				_PlaylistItemOpened(
78 									const PlaylistItemRef& item,
79 									status_t result);
80 
81 			void				_SetupWindow();
82 			void				_CreateMenu();
83 			void				_SetupVideoAspectItems(BMenu* menu);
84 			void				_SetupTrackMenus(BMenu* audioTrackMenu,
85 									BMenu* videoTrackMenu);
86 
87 			void				_GetMinimumWindowSize(int& width,
88 										int& height) const;
89 			void				_SetWindowSizeLimits();
90 			void				_GetUnscaledVideoSize(int& videoWidth,
91 									int& videoHeight) const;
92 			int					_CurrentVideoSizeInPercent() const;
93 			void				_ResizeWindow(int percent,
94 									bool useNoVideoWidth = false,
95 									bool stayOnScreen = false);
96 			void				_ResizeVideoView(int x, int y, int width,
97 									int height);
98 
99 			void				_MouseDown(BMessage* message,
100 									BView* originalHandler);
101 			void				_MouseMoved(BMessage* message,
102 									BView* originalHandler);
103 			void				_MouseUp(BMessage* message);
104 			void				_ShowContextMenu(const BPoint& screenPoint);
105 			bool				_KeyDown(BMessage* message);
106 
107 			void				_ToggleFullscreen();
108 			void				_ToggleAlwaysOnTop();
109 			void				_ToggleNoInterface();
110 			void				_ShowIfNeeded();
111 
112 			void				_SetFileAttributes();
113 			void				_UpdateControlsEnabledStatus();
114 			void				_UpdatePlaylistMenu();
115 			void				_AddPlaylistItem(PlaylistItem* item,
116 									int32 index);
117 			void				_RemovePlaylistItem(int32 index);
118 			void				_MarkPlaylistItem(int32 index);
119 			void				_MarkItem(BMenu* menu, uint32 command,
120 									bool mark);
121 
122 			void				_AdoptGlobalSettings();
123 
124 			bigtime_t			fCreationTime;
125 
126 			BMenuBar*			fMenuBar;
127 			BView*				fBackground;
128 			VideoView*			fVideoView;
129 			ControllerView*		fControls;
130 			InfoWin*			fInfoWin;
131 			PlaylistWindow*		fPlaylistWindow;
132 
133 			BMenu*				fFileMenu;
134 			BMenu*				fAudioMenu;
135 			BMenu*				fVideoMenu;
136 			BMenu*				fVideoAspectMenu;
137 			BMenu*				fAudioTrackMenu;
138 			BMenu*				fVideoTrackMenu;
139 			BMenu*				fSettingsMenu;
140 			BMenuItem*			fNoInterfaceMenuItem;
141 			BMenu*				fPlaylistMenu;
142 
143 			bool				fHasFile;
144 			bool				fHasVideo;
145 			bool				fHasAudio;
146 
147 			Playlist*			fPlaylist;
148 			PlaylistObserver*	fPlaylistObserver;
149 			Controller*			fController;
150 			ControllerObserver*	fControllerObserver;
151 	volatile bool				fIsFullscreen;
152 	volatile bool				fAlwaysOnTop;
153 	volatile bool				fNoInterface;
154 			int					fSourceWidth;
155 			int					fSourceHeight;
156 			int					fWidthAspect;
157 			int					fHeightAspect;
158 			int					fMenuBarWidth;
159 			int					fMenuBarHeight;
160 			int					fControlsHeight;
161 			int					fControlsWidth;
162 			int					fNoVideoWidth;
163 			BRect				fSavedFrame;
164 			BRect				fNoVideoFrame;
165 			bool				fMouseDownTracking;
166 			BPoint				fMouseDownMousePos;
167 			BPoint				fMouseDownWindowPos;
168 
169 			ListenerAdapter		fGlobalSettingsListener;
170 			bool				fCloseWhenDonePlayingMovie;
171 			bool				fCloseWhenDonePlayingSound;
172 			bigtime_t			fInitialSeekPosition;
173 
174 	static	int					sNoVideoWidth;
175 };
176 
177 #endif // __MAIN_WIN_H
178