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 151 bool fHasFile; 152 bool fHasVideo; 153 bool fHasAudio; 154 155 Playlist* fPlaylist; 156 PlaylistObserver* fPlaylistObserver; 157 Controller* fController; 158 ControllerObserver* fControllerObserver; 159 160 bool fIsFullscreen; 161 bool fAlwaysOnTop; 162 bool fNoInterface; 163 bool fShowsFullscreenControls; 164 165 int fSourceWidth; 166 int fSourceHeight; 167 int fWidthAspect; 168 int fHeightAspect; 169 int fMenuBarWidth; 170 int fMenuBarHeight; 171 int fControlsHeight; 172 int fControlsWidth; 173 int fNoVideoWidth; 174 BRect fSavedFrame; 175 BRect fNoVideoFrame; 176 177 bool fMouseDownTracking; 178 BPoint fMouseDownMousePos; 179 BPoint fMouseDownWindowPos; 180 BPoint fLastMousePos; 181 bigtime_t fLastMouseMovedTime; 182 float fMouseMoveDist; 183 184 ListenerAdapter fGlobalSettingsListener; 185 bool fCloseWhenDonePlayingMovie; 186 bool fCloseWhenDonePlayingSound; 187 bool fLoopMovies; 188 bool fLoopSounds; 189 bool fScaleFullscreenControls; 190 bigtime_t fInitialSeekPosition; 191 bool fAllowWinding; 192 193 static int sNoVideoWidth; 194 }; 195 196 #endif // __MAIN_WIN_H 197