xref: /haiku/src/apps/mediaplayer/MainWin.h (revision 15305513aedcfccb5b42dc51f2793de7ff4efd19)
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-2010 Stephan Aßmus <superstippi@gmx.de> (MIT ok)
6  *
7  * Released under the terms of the MIT license.
8  */
9 #ifndef __MAIN_WIN_H
10 #define __MAIN_WIN_H
11 
12 
13 #include <Window.h>
14 #include <Menu.h>
15 #include <Button.h>
16 #include <Slider.h>
17 
18 #include "Controller.h"
19 #include "ControllerView.h"
20 #include "InfoWin.h"
21 #include "ListenerAdapter.h"
22 #include "Playlist.h"
23 #include "PlaylistItem.h"
24 #include "VideoView.h"
25 
26 
27 class ControllerObserver;
28 class PlaylistObserver;
29 class PlaylistWindow;
30 
31 
32 class MainWin : public BWindow {
33 public:
34 								MainWin(bool isFirstWindow,
35 									BMessage* message = NULL);
36 	virtual						~MainWin();
37 
38 	virtual	void				FrameResized(float newWidth, float newHeight);
39 	virtual	void				Zoom(BPoint rectPosition, float rectWidth,
40 									float rectHeight);
41 	virtual	void				DispatchMessage(BMessage* message,
42 									BHandler* handler);
43 	virtual	void				MessageReceived(BMessage* message);
44 	virtual	void				WindowActivated(bool active);
45 	virtual	bool				QuitRequested();
46 	virtual	void				MenusBeginning();
47 
48 			void				OpenPlaylist(const BMessage* playlistArchive);
49 			void				OpenPlaylistItem(const PlaylistItemRef& item);
50 			void				Eject();
51 			void				ShowFileInfo();
52 			void				ShowPlaylistWindow();
53 			void				ShowSettingsWindow();
54 
55 			void				VideoAspectChange(int forcedWidth,
56 									int forcedHeight, float widthScale);
57 			void				VideoAspectChange(float widthScale);
58 			void				VideoAspectChange(int widthAspect,
59 									int heightAspect);
60 			void				VideoFormatChange(int width, int height,
61 									int widthAspect, int heightAspect);
62 
63 			void				GetQuitMessage(BMessage* message);
64 
65 	virtual	BHandler*			ResolveSpecifier(BMessage* message, int32 index,
66 									BMessage* specifier, int32 what,
67 									const char* property);
68 	virtual	status_t			GetSupportedSuites(BMessage* data);
69 
70 private:
71 			void				_RefsReceived(BMessage* message);
72 			void				_PlaylistItemOpened(
73 									const PlaylistItemRef& item,
74 									status_t result);
75 
76 			void				_SetupWindow();
77 			void				_CreateMenu();
78 			void				_SetupVideoAspectItems(BMenu* menu);
79 			void				_SetupTrackMenus(BMenu* audioTrackMenu,
80 									BMenu* videoTrackMenu,
81 									BMenu* subTitleTrackMenu);
82 			void				_UpdateAudioChannelCount(int32 audioTrackIndex);
83 
84 			void				_GetMinimumWindowSize(int& width,
85 										int& height) const;
86 			void				_SetWindowSizeLimits();
87 			void				_GetUnscaledVideoSize(int& videoWidth,
88 									int& videoHeight) const;
89 			int					_CurrentVideoSizeInPercent() const;
90 			void				_ZoomVideoView(int percentDiff);
91 			void				_ResizeWindow(int percent,
92 									bool useNoVideoWidth = false,
93 									bool stayOnScreen = false);
94 			void				_ResizeVideoView(int x, int y, int width,
95 									int height);
96 
97 			void				_MouseDown(BMessage* message,
98 									BView* originalHandler);
99 			void				_MouseMoved(BMessage* message,
100 									BView* originalHandler);
101 			void				_MouseUp(BMessage* message);
102 			void				_ShowContextMenu(const BPoint& screenPoint);
103 			bool				_KeyDown(BMessage* message);
104 
105 			void				_ToggleFullscreen();
106 			void				_ToggleAlwaysOnTop();
107 			void				_ToggleNoInterface();
108 			void				_ShowIfNeeded();
109 			void				_ShowFullscreenControls(bool show,
110 									bool animate = true);
111 
112 			void				_Wind(bigtime_t howMuch, int64 frames);
113 
114 			void				_UpdatePlaylistItemFile();
115 			void				_UpdateAttributesMenu(const BNode& node);
116 			void				_SetRating(int32 rating);
117 
118 			void				_UpdateControlsEnabledStatus();
119 			void				_UpdatePlaylistMenu();
120 			void				_AddPlaylistItem(PlaylistItem* item,
121 									int32 index);
122 			void				_RemovePlaylistItem(int32 index);
123 			void				_MarkPlaylistItem(int32 index);
124 			void				_MarkItem(BMenu* menu, uint32 command,
125 									bool mark);
126 
127 			void				_AdoptGlobalSettings();
128 
129 private:
130 			bigtime_t			fCreationTime;
131 
132 			BMenuBar*			fMenuBar;
133 			BView*				fBackground;
134 			VideoView*			fVideoView;
135 			ControllerView*		fControls;
136 			InfoWin*			fInfoWin;
137 			PlaylistWindow*		fPlaylistWindow;
138 
139 			BMenu*				fFileMenu;
140 			BMenu*				fPlaylistMenu;
141 			BMenu*				fAudioMenu;
142 			BMenu*				fVideoMenu;
143 			BMenu*				fVideoAspectMenu;
144 			BMenu*				fAudioTrackMenu;
145 			BMenu*				fVideoTrackMenu;
146 			BMenu*				fSubTitleTrackMenu;
147 			BMenuItem*			fNoInterfaceMenuItem;
148 			BMenu*				fAttributesMenu;
149 			BMenu*				fRatingMenu;
150 			BMenuItem*			fResetRatingItem;
151 
152 			bool				fHasFile;
153 			bool				fHasVideo;
154 			bool				fHasAudio;
155 
156 			Playlist*			fPlaylist;
157 			PlaylistObserver*	fPlaylistObserver;
158 			Controller*			fController;
159 			ControllerObserver*	fControllerObserver;
160 
161 			bool				fIsFullscreen;
162 			bool				fAlwaysOnTop;
163 			bool				fNoInterface;
164 			bool				fShowsFullscreenControls;
165 
166 			int					fSourceWidth;
167 			int					fSourceHeight;
168 			int					fWidthAspect;
169 			int					fHeightAspect;
170 			int					fMenuBarWidth;
171 			int					fMenuBarHeight;
172 			int					fControlsHeight;
173 			int					fControlsWidth;
174 			int					fNoVideoWidth;
175 			BRect				fSavedFrame;
176 			BRect				fNoVideoFrame;
177 
178 			bool				fMouseDownTracking;
179 			BPoint				fMouseDownMousePos;
180 			BPoint				fMouseDownWindowPos;
181 			BPoint				fLastMousePos;
182 			bigtime_t			fLastMouseMovedTime;
183 			float				fMouseMoveDist;
184 
185 			ListenerAdapter		fGlobalSettingsListener;
186 			bool				fCloseWhenDonePlayingMovie;
187 			bool				fCloseWhenDonePlayingSound;
188 			bool				fLoopMovies;
189 			bool				fLoopSounds;
190 			bool				fScaleFullscreenControls;
191 			bigtime_t			fInitialSeekPosition;
192 			bool				fAllowWinding;
193 
194 	static	int					sNoVideoWidth;
195 };
196 
197 #endif // __MAIN_WIN_H
198