[Haiku-commits] r31324 - haiku/trunk/src/apps/mediaplayer

stippi at mail.berlios.de stippi at mail.berlios.de
Tue Jun 30 14:47:43 CEST 2009


Author: stippi
Date: 2009-06-30 14:47:41 +0200 (Tue, 30 Jun 2009)
New Revision: 31324
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31324&view=rev

Modified:
   haiku/trunk/src/apps/mediaplayer/MainWin.cpp
   haiku/trunk/src/apps/mediaplayer/MainWin.h
Log:
Unified the "no menu, border, controls" settings to a single "no interface"
setting and made them available in the context menu again. During my testing,
I couldn't find any weird behavior, only the window dragging should still be
a problem on slower computers when multiple mouse messages piled up.


Modified: haiku/trunk/src/apps/mediaplayer/MainWin.cpp
===================================================================
--- haiku/trunk/src/apps/mediaplayer/MainWin.cpp	2009-06-30 12:41:02 UTC (rev 31323)
+++ haiku/trunk/src/apps/mediaplayer/MainWin.cpp	2009-06-30 12:47:41 UTC (rev 31324)
@@ -68,12 +68,9 @@
 	M_FILE_QUIT,
 	M_VIEW_SIZE,
 	M_TOGGLE_FULLSCREEN,
-	M_TOGGLE_NO_BORDER,
-	M_TOGGLE_NO_MENU,
-	M_TOGGLE_NO_CONTROLS,
-	M_TOGGLE_NO_BORDER_NO_MENU_NO_CONTROLS,
-	M_TOGGLE_ALWAYS_ON_TOP,
 	M_TOGGLE_KEEP_ASPECT_RATIO,
+	M_TOGGLE_ALWAYS_ON_TOP,
+	M_TOGGLE_NO_INTERFACE,
 	M_VOLUME_UP,
 	M_VOLUME_DOWN,
 	M_SKIP_NEXT,
@@ -116,9 +113,7 @@
 	  fIsFullscreen(false),
 	  fKeepAspectRatio(true),
 	  fAlwaysOnTop(false),
-	  fNoMenu(false),
-	  fNoBorder(false),
-	  fNoControls(false),
+	  fNoInterface(false),
 	  fSourceWidth(-1),
 	  fSourceHeight(-1),
 	  fWidthScale(1.0),
@@ -241,8 +236,8 @@
 		debugger("size wrong\n");
 	}
 
-	bool noMenu = fNoMenu || fIsFullscreen;
-	bool noControls = fNoControls || fIsFullscreen;
+	bool noMenu = fNoInterface || fIsFullscreen;
+	bool noControls = fNoInterface || fIsFullscreen;
 
 //	printf("FrameResized enter: newWidth %.0f, newHeight %.0f\n",
 //		newWidth, newHeight);
@@ -260,7 +255,7 @@
 		if (!fMenuBar->IsHidden())
 			fMenuBar->Hide();
 	} else {
-//		fMenuBar->MoveTo(0, y);
+		fMenuBar->MoveTo(0, y);
 		fMenuBar->ResizeTo(newWidth, fMenuBarHeight - 1);
 		if (fMenuBar->IsHidden())
 			fMenuBar->Show();
@@ -268,9 +263,7 @@
 	}
 
 	if (maxVideoHeight == 0) {
-		bool hidden = fVideoView->IsHidden();
-//		printf("  video view hidden: %d\n", hidden);
-		if (!hidden)
+		if (!fVideoView->IsHidden())
 			fVideoView->Hide();
 	} else {
 		_ResizeVideoView(0, y, maxVideoWidth, maxVideoHeight);
@@ -534,30 +527,18 @@
 			_ToggleFullscreen();
 			break;
 
-		case M_TOGGLE_NO_MENU:
-			_ToggleNoMenu();
+		case M_TOGGLE_KEEP_ASPECT_RATIO:
+			_ToggleKeepAspectRatio();
 			break;
 
-		case M_TOGGLE_NO_CONTROLS:
-			_ToggleNoControls();
-			break;
-
-		case M_TOGGLE_NO_BORDER:
-			_ToggleNoBorder();
-			break;
-
 		case M_TOGGLE_ALWAYS_ON_TOP:
 			_ToggleAlwaysOnTop();
 			break;
 
-		case M_TOGGLE_KEEP_ASPECT_RATIO:
-			_ToggleKeepAspectRatio();
+		case M_TOGGLE_NO_INTERFACE:
+			_ToggleNoInterface();
 			break;
 
-		case M_TOGGLE_NO_BORDER_NO_MENU_NO_CONTROLS:
-			_ToggleNoBorderNoMenu();
-			break;
-
 		case M_VIEW_SIZE:
 		{
 			int32 size;
@@ -952,12 +933,9 @@
 	item->SetMarked(fKeepAspectRatio);
 	fVideoMenu->AddItem(item);
 
-	fSettingsMenu->AddItem(new BMenuItem("No Menu",
-		new BMessage(M_TOGGLE_NO_MENU), 'M'));
-	fSettingsMenu->AddItem(new BMenuItem("No Border",
-		new BMessage(M_TOGGLE_NO_BORDER), 'B'));
-	fSettingsMenu->AddItem(new BMenuItem("No Controls",
-		new BMessage(M_TOGGLE_NO_CONTROLS), 'C'));
+	fNoInterfaceMenuItem = new BMenuItem("No Interface",
+		new BMessage(M_TOGGLE_NO_INTERFACE), 'B');
+	fSettingsMenu->AddItem(fNoInterfaceMenuItem);
 	fSettingsMenu->AddItem(new BMenuItem("Always on Top",
 		new BMessage(M_TOGGLE_ALWAYS_ON_TOP), 'T'));
 	fSettingsMenu->AddSeparatorItem();
@@ -1028,14 +1006,24 @@
 
 
 void
-MainWin::_SetWindowSizeLimits()
+MainWin::_GetMinimumWindowSize(int& width, int& height) const
 {
-	int minWidth = fNoControls  ? MIN_WIDTH : fControlsWidth;
-	if (!fNoMenu)
-		minWidth = max_c(minWidth, fMenuBarWidth);
-	int minHeight = (fNoMenu ? 0 : fMenuBarHeight)
-		+ (fNoControls ? 0 : fControlsHeight);
+	width = MIN_WIDTH;
+	height = 0;
+	if (!fNoInterface) {
+		width = max_c(width, fMenuBarWidth);
+		width = max_c(width, fControlsWidth);
+		height = fMenuBarHeight + fControlsHeight;
+	}
+}
 
+
+void
+MainWin::_SetWindowSizeLimits()
+{
+	int minWidth;
+	int minHeight;
+	_GetMinimumWindowSize(minWidth, minHeight);
 	SetSizeLimits(minWidth - 1, 32000, minHeight - 1, fHasVideo ?
 		32000 : minHeight - 1);
 }
@@ -1052,13 +1040,13 @@
 	videoHeight = (videoHeight * percent) / 100;
 
 	// Calculate and set the initial window size
-	int width = max_c(fControlsWidth, videoWidth);
-	int height = (fNoControls ? 0 : fControlsHeight) + videoHeight;
-	if (!fNoMenu) {
-		width = max_c(width, fMenuBarWidth);
-		height += fMenuBarHeight;
-	}
-	_SetWindowSizeLimits();
+	int width;
+	int height;
+	_GetMinimumWindowSize(width, height);
+
+	width = max_c(width, videoWidth);
+	height = height + videoHeight;
+//	_SetWindowSizeLimits();
 	ResizeTo(width - 1, height - 1);
 }
 
@@ -1130,7 +1118,7 @@
 		BRect r(screen_where.x - 1, screen_where.y - 1, screen_where.x + 1,
 			screen_where.y + 1);
 		if (r.Contains(fMouseDownMousePos)) {
-			PostMessage(M_TOGGLE_NO_BORDER_NO_MENU_NO_CONTROLS);
+			PostMessage(M_TOGGLE_NO_INTERFACE);
 			return;
 		}
 	}
@@ -1233,6 +1221,11 @@
 	item->SetMarked(fKeepAspectRatio);
 	item->SetEnabled(fHasVideo);
 
+	menu->AddItem(item = new BMenuItem("No Interface",
+		new BMessage(M_TOGGLE_NO_INTERFACE), 'B'));
+	item->SetMarked(fNoInterface);
+	item->SetEnabled(fHasVideo);
+
 	menu->AddSeparatorItem();
 
 	// Add track selector menus
@@ -1403,24 +1396,6 @@
 
 
 void
-MainWin::_ToggleNoBorderNoMenu()
-{
-	if (!fNoMenu && !fNoBorder && !fNoControls) {
-		PostMessage(M_TOGGLE_NO_MENU);
-		PostMessage(M_TOGGLE_NO_BORDER);
-		PostMessage(M_TOGGLE_NO_CONTROLS);
-	} else {
-		if (!fNoMenu)
-			PostMessage(M_TOGGLE_NO_MENU);
-		if (!fNoBorder)
-			PostMessage(M_TOGGLE_NO_BORDER);
-		if (!fNoControls)
-			PostMessage(M_TOGGLE_NO_CONTROLS);
-	}
-}
-
-
-void
 MainWin::_ToggleFullscreen()
 {
 	printf("_ToggleFullscreen enter\n");
@@ -1464,88 +1439,57 @@
 }
 
 void
-MainWin::_ToggleNoControls()
+MainWin::_ToggleKeepAspectRatio()
 {
-	printf("_ToggleNoControls enter\n");
+	fKeepAspectRatio = !fKeepAspectRatio;
+	FrameResized(Bounds().Width(), Bounds().Height());
 
-	if (fIsFullscreen) {
-		// fullscreen is always without menu
-		printf("_ToggleNoControls leave, doing nothing, we are fullscreen\n");
-		return;
-	}
+	_MarkItem(fVideoMenu, M_TOGGLE_KEEP_ASPECT_RATIO, fKeepAspectRatio);
+}
 
-	fNoControls = !fNoControls;
-	_SetWindowSizeLimits();
 
-	if (fNoControls) {
-		ResizeBy(0, - fControlsHeight);
-	} else {
-		ResizeBy(0, fControlsHeight);
-	}
+void
+MainWin::_ToggleAlwaysOnTop()
+{
+	fAlwaysOnTop = !fAlwaysOnTop;
+	SetFeel(fAlwaysOnTop ? B_FLOATING_ALL_WINDOW_FEEL : B_NORMAL_WINDOW_FEEL);
 
-	_MarkItem(fSettingsMenu, M_TOGGLE_NO_CONTROLS, fNoControls);
-
-	printf("_ToggleNoControls leave\n");
+	_MarkItem(fSettingsMenu, M_TOGGLE_ALWAYS_ON_TOP, fAlwaysOnTop);
 }
 
+
 void
-MainWin::_ToggleNoMenu()
+MainWin::_ToggleNoInterface()
 {
-	printf("_ToggleNoMenu enter\n");
+	printf("_ToggleNoInterface enter\n");
 
-	if (fIsFullscreen) {
-		// fullscreen is always without menu
-		printf("_ToggleNoMenu leave, doing nothing, we are fullscreen\n");
+	if (fIsFullscreen || !fHasVideo) {
+		// Fullscreen playback is always without interface and
+		// audio playback is always with interface. So we ignore these
+		// two states here.
+		printf("_ToggleNoControls leave, doing nothing, we are fullscreen\n");
 		return;
 	}
 
-	fNoMenu = !fNoMenu;
+	fNoInterface = !fNoInterface;
 	_SetWindowSizeLimits();
 
-	if (fNoMenu) {
+	if (fNoInterface) {
 		MoveBy(0, fMenuBarHeight);
-		ResizeBy(0, - fMenuBarHeight);
+		ResizeBy(0, -(fControlsHeight + fMenuBarHeight));
+		SetLook(B_BORDERED_WINDOW_LOOK);
 	} else {
-		MoveBy(0, - fMenuBarHeight);
-		ResizeBy(0, fMenuBarHeight);
+		MoveBy(0, -fMenuBarHeight);
+		ResizeBy(0, fControlsHeight + fMenuBarHeight);
+		SetLook(B_TITLED_WINDOW_LOOK);
 	}
 
-	_MarkItem(fSettingsMenu, M_TOGGLE_NO_MENU, fNoMenu);
+	_MarkItem(fSettingsMenu, M_TOGGLE_NO_INTERFACE, fNoInterface);
 
-	printf("_ToggleNoMenu leave\n");
+	printf("_ToggleNoInterface leave\n");
 }
 
 
-void
-MainWin::_ToggleNoBorder()
-{
-	fNoBorder = !fNoBorder;
-	SetLook(fNoBorder ? B_BORDERED_WINDOW_LOOK : B_TITLED_WINDOW_LOOK);
-
-	_MarkItem(fSettingsMenu, M_TOGGLE_NO_BORDER, fNoBorder);
-}
-
-
-void
-MainWin::_ToggleAlwaysOnTop()
-{
-	fAlwaysOnTop = !fAlwaysOnTop;
-	SetFeel(fAlwaysOnTop ? B_FLOATING_ALL_WINDOW_FEEL : B_NORMAL_WINDOW_FEEL);
-
-	_MarkItem(fSettingsMenu, M_TOGGLE_ALWAYS_ON_TOP, fAlwaysOnTop);
-}
-
-
-void
-MainWin::_ToggleKeepAspectRatio()
-{
-	fKeepAspectRatio = !fKeepAspectRatio;
-	FrameResized(Bounds().Width(), Bounds().Height());
-
-	_MarkItem(fVideoMenu, M_TOGGLE_KEEP_ASPECT_RATIO, fKeepAspectRatio);
-}
-
-
 // #pragma mark -
 
 
@@ -1569,6 +1513,8 @@
 		enabledButtons |= SKIP_FORWARD_ENABLED;
 
 	fControls->SetEnabled(enabledButtons);
+
+	fNoInterfaceMenuItem->SetEnabled(fHasVideo);
 }
 
 

Modified: haiku/trunk/src/apps/mediaplayer/MainWin.h
===================================================================
--- haiku/trunk/src/apps/mediaplayer/MainWin.h	2009-06-30 12:41:02 UTC (rev 31323)
+++ haiku/trunk/src/apps/mediaplayer/MainWin.h	2009-06-30 12:47:41 UTC (rev 31324)
@@ -69,6 +69,9 @@
 			void				_SetupVideoAspectItems(BMenu* menu);
 			void				_SetupTrackMenus(BMenu* audioTrackMenu,
 									BMenu* videoTrackMenu);
+
+			void				_GetMinimumWindowSize(int& width,
+										int& height) const;
 			void				_SetWindowSizeLimits();
 			void				_ResizeWindow(int percent);
 			void				_ResizeVideoView(int x, int y, int width,
@@ -85,10 +88,7 @@
 			void				_ToggleFullscreen();
 			void				_ToggleKeepAspectRatio();
 			void				_ToggleAlwaysOnTop();
-			void				_ToggleNoBorder();
-			void				_ToggleNoMenu();
-			void				_ToggleNoControls();
-			void				_ToggleNoBorderNoMenu();
+			void				_ToggleNoInterface();
 
 			void				_UpdateControlsEnabledStatus();
 			void				_UpdatePlaylistMenu();
@@ -115,6 +115,7 @@
 			BMenu*				fAudioTrackMenu;
 			BMenu*				fVideoTrackMenu;
 			BMenu*				fSettingsMenu;
+			BMenuItem*			fNoInterfaceMenuItem;
 			BMenu*				fPlaylistMenu;
 
 			bool				fHasFile;
@@ -128,9 +129,7 @@
 			volatile bool		fIsFullscreen;
 			volatile bool		fKeepAspectRatio;
 			volatile bool		fAlwaysOnTop;
-			volatile bool		fNoMenu;
-			volatile bool		fNoBorder;
-			volatile bool		fNoControls;
+			volatile bool		fNoInterface;
 			int					fSourceWidth;
 			int					fSourceHeight;
 			float				fWidthScale;




More information about the Haiku-commits mailing list