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 * 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 void GetQuitMessage(BMessage* message); 76 77 virtual BHandler* ResolveSpecifier(BMessage* message, int32 index, 78 BMessage* specifier, int32 what, 79 const char* property); 80 virtual status_t GetSupportedSuites(BMessage* data); 81 82 private: 83 void _RefsReceived(BMessage* message); 84 void _PlaylistItemOpened( 85 const PlaylistItemRef& item, 86 status_t result); 87 88 void _SetupWindow(); 89 void _CreateMenu(); 90 void _SetupVideoAspectItems(BMenu* menu); 91 void _SetupTrackMenus(BMenu* audioTrackMenu, 92 BMenu* videoTrackMenu, 93 BMenu* subTitleTrackMenu); 94 void _UpdateAudioChannelCount(int32 audioTrackIndex); 95 96 void _GetMinimumWindowSize(int& width, 97 int& height) const; 98 void _SetWindowSizeLimits(); 99 void _GetUnscaledVideoSize(int& videoWidth, 100 int& videoHeight) const; 101 int _CurrentVideoSizeInPercent() const; 102 void _ZoomVideoView(int percentDiff); 103 void _ResizeWindow(int percent, 104 bool useNoVideoWidth = false, 105 bool stayOnScreen = false); 106 void _ResizeVideoView(int x, int y, int width, 107 int height); 108 109 void _MouseDown(BMessage* message, 110 BView* originalHandler); 111 void _MouseMoved(BMessage* message, 112 BView* originalHandler); 113 void _MouseUp(BMessage* message); 114 void _ShowContextMenu(const BPoint& screenPoint); 115 bool _KeyDown(BMessage* message); 116 117 void _ToggleFullscreen(); 118 void _ToggleAlwaysOnTop(); 119 void _ToggleNoInterface(); 120 void _ShowIfNeeded(); 121 void _ShowFullscreenControls(bool show, 122 bool animate = true); 123 124 void _UpdatePlaylistItemFile(); 125 void _UpdateAttributesMenu(const BNode& node); 126 void _SetRating(int32 rating); 127 128 void _UpdateControlsEnabledStatus(); 129 void _UpdatePlaylistMenu(); 130 void _AddPlaylistItem(PlaylistItem* item, 131 int32 index); 132 void _RemovePlaylistItem(int32 index); 133 void _MarkPlaylistItem(int32 index); 134 void _MarkItem(BMenu* menu, uint32 command, 135 bool mark); 136 137 void _AdoptGlobalSettings(); 138 139 private: 140 bigtime_t fCreationTime; 141 142 BMenuBar* fMenuBar; 143 BView* fBackground; 144 VideoView* fVideoView; 145 ControllerView* fControls; 146 InfoWin* fInfoWin; 147 PlaylistWindow* fPlaylistWindow; 148 149 BMenu* fFileMenu; 150 BMenu* fPlaylistMenu; 151 BMenu* fAudioMenu; 152 BMenu* fVideoMenu; 153 BMenu* fVideoAspectMenu; 154 BMenu* fAudioTrackMenu; 155 BMenu* fVideoTrackMenu; 156 BMenu* fSubTitleTrackMenu; 157 BMenuItem* fNoInterfaceMenuItem; 158 BMenu* fAttributesMenu; 159 BMenu* fRatingMenu; 160 161 bool fHasFile; 162 bool fHasVideo; 163 bool fHasAudio; 164 165 Playlist* fPlaylist; 166 PlaylistObserver* fPlaylistObserver; 167 Controller* fController; 168 ControllerObserver* fControllerObserver; 169 170 bool fIsFullscreen; 171 bool fAlwaysOnTop; 172 bool fNoInterface; 173 bool fShowsFullscreenControls; 174 175 int fSourceWidth; 176 int fSourceHeight; 177 int fWidthAspect; 178 int fHeightAspect; 179 int fMenuBarWidth; 180 int fMenuBarHeight; 181 int fControlsHeight; 182 int fControlsWidth; 183 int fNoVideoWidth; 184 BRect fSavedFrame; 185 BRect fNoVideoFrame; 186 187 bool fMouseDownTracking; 188 BPoint fMouseDownMousePos; 189 BPoint fMouseDownWindowPos; 190 BPoint fLastMousePos; 191 bigtime_t fLastMouseMovedTime; 192 float fMouseMoveDist; 193 194 ListenerAdapter fGlobalSettingsListener; 195 bool fCloseWhenDonePlayingMovie; 196 bool fCloseWhenDonePlayingSound; 197 bool fLoopMovies; 198 bool fLoopSounds; 199 bool fScaleFullscreenControls; 200 bigtime_t fInitialSeekPosition; 201 bool fAllowWinding; 202 203 static int sNoVideoWidth; 204 }; 205 206 #endif // __MAIN_WIN_H 207