xref: /haiku/src/apps/mediaplayer/MainWin.h (revision ddac407426cd3b3d0b4589d7a161b300b3539a2a)
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 #include <Window.h>
25 #include <Menu.h>
26 #include <Button.h>
27 #include <Slider.h>
28 
29 #include "Controller.h"
30 #include "ControllerView.h"
31 #include "InfoWin.h"
32 #include "ListenerAdapter.h"
33 #include "Playlist.h"
34 #include "PlaylistItem.h"
35 #include "VideoView.h"
36 
37 class ControllerObserver;
38 class PlaylistObserver;
39 class PlaylistWindow;
40 
41 class MainWin : public BWindow {
42 public:
43 								MainWin();
44 	virtual						~MainWin();
45 
46 	virtual	void				FrameResized(float newWidth, float newHeight);
47 	virtual	void				Zoom(BPoint rectPosition, float rectWidth,
48 									float rectHeight);
49 	virtual	void				DispatchMessage(BMessage* message,
50 									BHandler* handler);
51 	virtual	void				MessageReceived(BMessage* message);
52 	virtual	void				WindowActivated(bool active);
53 	virtual	bool				QuitRequested();
54 
55 			void				OpenPlaylistItem(const PlaylistItemRef& item);
56 
57 			void				ShowFileInfo();
58 			void				ShowPlaylistWindow();
59 			void				ShowSettingsWindow();
60 
61 			void				VideoFormatChange(int width, int height,
62 									float widthToHeightRatio);
63 
64 private:
65 			void				_RefsReceived(BMessage* message);
66 
67 			void				_SetupWindow();
68 			void				_CreateMenu();
69 			void				_SetupVideoAspectItems(BMenu* menu);
70 			void				_SetupTrackMenus(BMenu* audioTrackMenu,
71 									BMenu* videoTrackMenu);
72 
73 			void				_GetMinimumWindowSize(int& width,
74 										int& height) const;
75 			void				_SetWindowSizeLimits();
76 			void				_ResizeWindow(int percent);
77 			void				_ResizeVideoView(int x, int y, int width,
78 									int height);
79 
80 			void				_MouseDown(BMessage* message,
81 									BView* originalHandler);
82 			void				_MouseMoved(BMessage* message,
83 									BView* originalHandler);
84 			void				_MouseUp(BMessage* message);
85 			void				_ShowContextMenu(const BPoint& screenPoint);
86 			status_t			_KeyDown(BMessage* message);
87 
88 			void				_ToggleFullscreen();
89 			void				_ToggleKeepAspectRatio();
90 			void				_ToggleAlwaysOnTop();
91 			void				_ToggleNoInterface();
92 
93 			void				_UpdateControlsEnabledStatus();
94 			void				_UpdatePlaylistMenu();
95 			void				_AddPlaylistItem(PlaylistItem* item,
96 									int32 index);
97 			void				_RemovePlaylistItem(int32 index);
98 			void				_MarkPlaylistItem(int32 index);
99 			void				_MarkItem(BMenu* menu, uint32 command,
100 									bool mark);
101 
102 			void				_AdoptGlobalSettings();
103 
104 			BMenuBar*			fMenuBar;
105 			BView*				fBackground;
106 			VideoView*			fVideoView;
107 			ControllerView*		fControls;
108 			InfoWin*			fInfoWin;
109 			PlaylistWindow*		fPlaylistWindow;
110 
111 			BMenu*				fFileMenu;
112 			BMenu*				fAudioMenu;
113 			BMenu*				fVideoMenu;
114 			BMenu*				fVideoAspectMenu;
115 			BMenu*				fAudioTrackMenu;
116 			BMenu*				fVideoTrackMenu;
117 			BMenu*				fSettingsMenu;
118 			BMenuItem*			fNoInterfaceMenuItem;
119 			BMenu*				fPlaylistMenu;
120 
121 			bool				fHasFile;
122 			bool				fHasVideo;
123 			bool				fHasAudio;
124 
125 			Playlist*			fPlaylist;
126 			PlaylistObserver*	fPlaylistObserver;
127 			Controller*			fController;
128 			ControllerObserver*	fControllerObserver;
129 			volatile bool		fIsFullscreen;
130 			volatile bool		fKeepAspectRatio;
131 			volatile bool		fAlwaysOnTop;
132 			volatile bool		fNoInterface;
133 			int					fSourceWidth;
134 			int					fSourceHeight;
135 			float				fWidthScale;
136 			float				fHeightScale;
137 			int					fMenuBarWidth;
138 			int					fMenuBarHeight;
139 			int					fControlsHeight;
140 			int					fControlsWidth;
141 			BRect				fSavedFrame;
142 			bool				fMouseDownTracking;
143 			BPoint				fMouseDownMousePos;
144 			BPoint				fMouseDownWindowPos;
145 
146 			ListenerAdapter		fGlobalSettingsListener;
147 			bool				fCloseWhenDonePlayingMovie;
148 			bool				fCloseWhenDonePlayingSound;
149 };
150 
151 #endif // __MAIN_WIN_H
152