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 _Wind(bigtime_t howMuch, int64 frames); 125 126 void _UpdatePlaylistItemFile(); 127 void _UpdateAttributesMenu(const BNode& node); 128 void _SetRating(int32 rating); 129 130 void _UpdateControlsEnabledStatus(); 131 void _UpdatePlaylistMenu(); 132 void _AddPlaylistItem(PlaylistItem* item, 133 int32 index); 134 void _RemovePlaylistItem(int32 index); 135 void _MarkPlaylistItem(int32 index); 136 void _MarkItem(BMenu* menu, uint32 command, 137 bool mark); 138 139 void _AdoptGlobalSettings(); 140 141 private: 142 bigtime_t fCreationTime; 143 144 BMenuBar* fMenuBar; 145 BView* fBackground; 146 VideoView* fVideoView; 147 ControllerView* fControls; 148 InfoWin* fInfoWin; 149 PlaylistWindow* fPlaylistWindow; 150 151 BMenu* fFileMenu; 152 BMenu* fPlaylistMenu; 153 BMenu* fAudioMenu; 154 BMenu* fVideoMenu; 155 BMenu* fVideoAspectMenu; 156 BMenu* fAudioTrackMenu; 157 BMenu* fVideoTrackMenu; 158 BMenu* fSubTitleTrackMenu; 159 BMenuItem* fNoInterfaceMenuItem; 160 BMenu* fAttributesMenu; 161 BMenu* fRatingMenu; 162 163 bool fHasFile; 164 bool fHasVideo; 165 bool fHasAudio; 166 167 Playlist* fPlaylist; 168 PlaylistObserver* fPlaylistObserver; 169 Controller* fController; 170 ControllerObserver* fControllerObserver; 171 172 bool fIsFullscreen; 173 bool fAlwaysOnTop; 174 bool fNoInterface; 175 bool fShowsFullscreenControls; 176 177 int fSourceWidth; 178 int fSourceHeight; 179 int fWidthAspect; 180 int fHeightAspect; 181 int fMenuBarWidth; 182 int fMenuBarHeight; 183 int fControlsHeight; 184 int fControlsWidth; 185 int fNoVideoWidth; 186 BRect fSavedFrame; 187 BRect fNoVideoFrame; 188 189 bool fMouseDownTracking; 190 BPoint fMouseDownMousePos; 191 BPoint fMouseDownWindowPos; 192 BPoint fLastMousePos; 193 bigtime_t fLastMouseMovedTime; 194 float fMouseMoveDist; 195 196 ListenerAdapter fGlobalSettingsListener; 197 bool fCloseWhenDonePlayingMovie; 198 bool fCloseWhenDonePlayingSound; 199 bool fLoopMovies; 200 bool fLoopSounds; 201 bool fScaleFullscreenControls; 202 bigtime_t fInitialSeekPosition; 203 bool fAllowWinding; 204 205 static int sNoVideoWidth; 206 }; 207 208 #endif // __MAIN_WIN_H 209