[haiku-commits] r38599 - haiku/trunk/src/apps/mediaplayer

  • From: superstippi@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 10 Sep 2010 14:04:57 +0200 (CEST)

Author: stippi
Date: 2010-09-10 14:04:57 +0200 (Fri, 10 Sep 2010)
New Revision: 38599
Changeset: http://dev.haiku-os.org/changeset/38599
Ticket: http://dev.haiku-os.org/ticket/2495

Modified:
   haiku/trunk/src/apps/mediaplayer/MainWin.cpp
   haiku/trunk/src/apps/mediaplayer/MainWin.h
Log:
 * _CurrentVideoSizeInPercent() returned wrong values,
   but it didn't result in wrong behavior before.
Implemented more keyboard actions from ticket #2495:
 * +/- zoom the video now (by +/- 10% of current scale).
 * ZXCVB (raw keys hardcoded, i.e. the keys along the bottom
   of the keyboard) act as playback buttons: skip previous (Z),
   play (X), pause (C), stop (V), skip next (B).
 * Renamed "No interface" menu item to "Hide interface" and
   changed the shortcut to Cmd-H. This item is only available
   with video streams, though.
 * 'M' will mute/unmute the audio.


Modified: haiku/trunk/src/apps/mediaplayer/MainWin.cpp
===================================================================
--- haiku/trunk/src/apps/mediaplayer/MainWin.cpp        2010-09-10 11:15:28 UTC 
(rev 38598)
+++ haiku/trunk/src/apps/mediaplayer/MainWin.cpp        2010-09-10 12:04:57 UTC 
(rev 38599)
@@ -1403,8 +1403,8 @@
 
        fFileMenu->AddSeparatorItem();
 
-       fNoInterfaceMenuItem = new BMenuItem("No interface",
-               new BMessage(M_TOGGLE_NO_INTERFACE), 'B');
+       fNoInterfaceMenuItem = new BMenuItem("Hide interface",
+               new BMessage(M_TOGGLE_NO_INTERFACE), 'H');
        fFileMenu->AddItem(fNoInterfaceMenuItem);
        fFileMenu->AddItem(new BMenuItem("Always on top",
                new BMessage(M_TOGGLE_ALWAYS_ON_TOP), 'A'));
@@ -1632,8 +1632,8 @@
        int viewWidth = fVideoView->Bounds().IntegerWidth() + 1;
        int viewHeight = fVideoView->Bounds().IntegerHeight() + 1;
 
-       int widthPercent = videoWidth * 100 / viewWidth;
-       int heightPercent = videoHeight * 100 / viewHeight;
+       int widthPercent = viewWidth * 100 / videoWidth;
+       int heightPercent = viewHeight * 100 / videoHeight;
 
        if (widthPercent > heightPercent)
                return widthPercent;
@@ -1642,6 +1642,27 @@
 
 
 void
+MainWin::_ZoomVideoView(int percentDiff)
+{
+       if (!fHasVideo)
+               return;
+
+       int percent = _CurrentVideoSizeInPercent();
+       int newSize = percent * (100 + percentDiff) / 100;
+
+       if (newSize < 25)
+               newSize = 25;
+       if (newSize > 400)
+               newSize = 400;
+       if (newSize != percent) {
+               BMessage message(M_VIEW_SIZE);
+               message.AddInt32("size", newSize);
+               PostMessage(&message);
+       }
+}
+
+
+void
 MainWin::_ResizeWindow(int percent, bool useNoVideoWidth, bool stayOnScreen)
 {
        // Get required window size
@@ -1723,9 +1744,6 @@
 void
 MainWin::_ResizeVideoView(int x, int y, int width, int height)
 {
-       printf("_ResizeVideoView: %d,%d, width %d, height %d\n", x, y,
-               width, height);
-
        // Keep aspect ratio, place video view inside
        // the background area (may create black bars).
        int videoWidth;
@@ -1928,8 +1946,6 @@
 bool
 MainWin::_KeyDown(BMessage* msg)
 {
-       // TODO: use the shortcut mechanism instead!
-
        uint32 key = msg->FindInt32("key");
        uint32 rawChar = msg->FindInt32("raw_char");
        uint32 modifier = msg->FindInt32("modifiers");
@@ -1947,6 +1963,10 @@
                        fController->TogglePlaying();
                        return true;
 
+               case 'm':
+                       fController->ToggleMute();
+                       return true;
+
                case B_ESCAPE:
                        if (!fIsFullscreen)
                                break;
@@ -2017,6 +2037,20 @@
                        PostMessage(M_SKIP_PREV);
                        return true;
 
+               case '+':
+                       if ((modifier & B_COMMAND_KEY) == 0) {
+                               _ZoomVideoView(10);
+                               return true;
+                       }
+                       break;
+
+               case '-':
+                       if ((modifier & B_COMMAND_KEY) == 0) {
+                               _ZoomVideoView(-10);
+                               return true;
+                       }
+                       break;
+
                case B_DELETE:
                case 'd':                       // d for delete
                case 't':                       // t for Trash
@@ -2034,14 +2068,14 @@
        switch (key) {
                case 0x3a:              // numeric keypad +
                        if ((modifier & B_COMMAND_KEY) == 0) {
-                               PostMessage(M_VOLUME_UP);
+                               _ZoomVideoView(10);
                                return true;
                        }
                        break;
 
                case 0x25:              // numeric keypad -
                        if ((modifier & B_COMMAND_KEY) == 0) {
-                               PostMessage(M_VOLUME_DOWN);
+                               _ZoomVideoView(-10);
                                return true;
                        }
                        break;
@@ -2063,6 +2097,24 @@
                case 0x48:                      // numeric keypad left arrow
                        PostMessage(M_SKIP_PREV);
                        return true;
+
+               // Playback controls along the bottom of the keyboard:
+               // Z X C V B  for US International
+               case 0x4c:
+                       PostMessage(M_SKIP_PREV);
+                       return true;
+               case 0x4d:
+                       fController->Play();
+                       return true;
+               case 0x4e:
+                       fController->Pause();
+                       return true;
+               case 0x4f:
+                       fController->Stop();
+                       return true;
+               case 0x50:
+                       PostMessage(M_SKIP_NEXT);
+                       return true;
        }
 
        return false;

Modified: haiku/trunk/src/apps/mediaplayer/MainWin.h
===================================================================
--- haiku/trunk/src/apps/mediaplayer/MainWin.h  2010-09-10 11:15:28 UTC (rev 
38598)
+++ haiku/trunk/src/apps/mediaplayer/MainWin.h  2010-09-10 12:04:57 UTC (rev 
38599)
@@ -98,6 +98,7 @@
                        void                            
_GetUnscaledVideoSize(int& videoWidth,
                                                                        int& 
videoHeight) const;
                        int                                     
_CurrentVideoSizeInPercent() const;
+                       void                            _ZoomVideoView(int 
percentDiff);
                        void                            _ResizeWindow(int 
percent,
                                                                        bool 
useNoVideoWidth = false,
                                                                        bool 
stayOnScreen = false);


Other related posts:

  • » [haiku-commits] r38599 - haiku/trunk/src/apps/mediaplayer - superstippi