]> git.sesse.net Git - vlc/blobdiff - modules/gui/beos/MediaControlView.cpp
+ configure.ac: don't build OpenGL support on BeOS although it has gl.h
[vlc] / modules / gui / beos / MediaControlView.cpp
index 32aa9f749cf8db8ac16126acd0f7bd9a7950e76a..d580b311b36a4f75976664b0ce58e24924ca7712 100644 (file)
@@ -2,7 +2,7 @@
  * MediaControlView.cpp: beos interface
  *****************************************************************************
  * Copyright (C) 1999, 2000, 2001 VideoLAN
- * $Id: MediaControlView.cpp,v 1.14 2003/02/01 12:01:11 stippi Exp $
+ * $Id$
  *
  * Authors: Tony Castley <tony@castley.net>
  *          Stephan Aßmus <stippi@yellowbites.com>
 /* VLC headers */
 #include <vlc/vlc.h>
 #include <vlc/intf.h>
+#include <vlc/input.h>
+extern "C"
+{
+  #include <audio_output.h>
+}
 
 /* BeOS interface headers */
 #include "VlcWrapper.h"
@@ -61,7 +66,7 @@ const rgb_color kSeekRed = (rgb_color){ 255, 0, 0, 255 };
 const rgb_color kSeekRedLight = (rgb_color){ 255, 152, 152, 255 };
 const rgb_color kSeekRedShadow = (rgb_color){ 178, 0, 0, 255 };
 
-const char* kDisabledSeekMessage = "Drop files to play";
+#define DISABLED_SEEK_MESSAGE _("Drop files to play")
 
 enum
 {
@@ -76,8 +81,8 @@ MediaControlView::MediaControlView(BRect frame, intf_thread_t *p_interface)
        : BBox(frame, NULL, B_FOLLOW_NONE, B_WILL_DRAW | B_FRAME_EVENTS | B_PULSE_NEEDED,
                   B_PLAIN_BORDER),
       fScrubSem(B_ERROR),
-      fCurrentRate(DEFAULT_RATE),
-      fCurrentStatus(UNDEF_S),
+      fCurrentRate(INPUT_RATE_DEFAULT),
+      fCurrentStatus(-1),
       fBottomControlHeight(0.0),
       fIsEnabled( true )
 {
@@ -86,8 +91,8 @@ MediaControlView::MediaControlView(BRect frame, intf_thread_t *p_interface)
        BRect frame(0.0, 0.0, 10.0, 10.0);
        
     // Seek Slider
-    fSeekSlider = new SeekSlider(frame, "seek slider", this,
-                                 0, SEEKSLIDER_RANGE - 1);
+    fSeekSlider = new SeekSlider( frame, "seek slider", this,
+                                  0, SEEKSLIDER_RANGE );
     fSeekSlider->SetValue(0);
     fSeekSlider->ResizeToPreferred();
     AddChild( fSeekSlider );
@@ -172,7 +177,7 @@ MediaControlView::MediaControlView(BRect frame, intf_thread_t *p_interface)
                                                                                   kVolumeSliderBitmapHeight - 1.0),
                                                                         "volume slider", 1, AOUT_VOLUME_MAX,
                                                                         new BMessage(VOLUME_CHG));
-       fVolumeSlider->SetValue(AOUT_VOLUME_DEFAULT);
+       fVolumeSlider->SetValue( config_GetInt( p_intf, "volume" ) );
        AddChild( fVolumeSlider );
        
        // Position Info View
@@ -199,8 +204,18 @@ MediaControlView::AttachedToWindow()
        fVolumeSlider->SetTarget(Window());
 
        BRect r(_MinFrame());
-       if (BMenuBar* menuBar = Window()->KeyMenuBar())
-               r.bottom += menuBar->Bounds().Height();
+       if (BMenuBar* menuBar = Window()->KeyMenuBar()) {
+               float width, height;
+               menuBar->GetPreferredSize(&width, &height);
+//             r.bottom += menuBar->Bounds().Height();
+               r.bottom += height;
+               // see that our calculated minimal width is not smaller than what
+               // the menubar can be
+printf("preferred: width: %f, height: %f - width: %f\n", width, height, r.Width());
+               width -= r.Width();
+               if (width > 0.0)
+                       r.right += width;
+       }
 
        Window()->SetSizeLimits(r.Width(), r.Width() * 1.8, r.Height(), r.Height() * 1.3);
        if (!Window()->Bounds().Contains(r))
@@ -279,6 +294,10 @@ MediaControlView::Pulse()
        InterfaceWindow* window = dynamic_cast<InterfaceWindow*>(Window());
        if (window && window->IsStopped())
                        fPlayPause->SetStopped();
+
+    unsigned short i_volume;
+    aout_VolumeGet( p_intf, (audio_volume_t*)&i_volume );
+    fVolumeSlider->SetValue( i_volume );
 }
 
 // SetProgress
@@ -298,16 +317,11 @@ MediaControlView::SetStatus(int status, int rate)
     switch( status )
     {
         case PLAYING_S:
-        case FORWARD_S:
-        case BACKWARD_S:
-        case START_S:
             fPlayPause->SetPlaying();
             break;
         case PAUSE_S:
             fPlayPause->SetPaused();
             break;
-        case UNDEF_S:
-        case NOT_STARTED_S:
         default:
             fPlayPause->SetStopped();
             break;
@@ -315,7 +329,7 @@ MediaControlView::SetStatus(int status, int rate)
        if (rate != fCurrentRate)
        {
                fCurrentRate = rate;
-           if ( rate < DEFAULT_RATE )
+           if ( rate < INPUT_RATE_DEFAULT )
            {
                // TODO: ...
            }
@@ -695,7 +709,7 @@ SeekSlider::Draw(BRect updateRect)
                SetHighColor(darkShadow);
                SetLowColor(shadow);
                // stripes
-               float width = floorf(StringWidth(kDisabledSeekMessage));
+               float width = floorf(StringWidth(DISABLED_SEEK_MESSAGE));
                float textPos = r.left + r.Width() / 2.0 - width / 2.0;
                pattern stripes = {{ 0xc7, 0x8f, 0x1f, 0x3e, 0x7c, 0xf8, 0xf1, 0xe3 }};
                BRect stripesRect(r);
@@ -712,7 +726,7 @@ SeekSlider::Draw(BRect updateRect)
                SetLowColor(darkShadow);
                font_height fh;
                GetFontHeight(&fh);
-               DrawString(kDisabledSeekMessage, BPoint(textPos, r.top + ceilf(fh.ascent) - 1.0));
+               DrawString(DISABLED_SEEK_MESSAGE, BPoint(textPos, r.top + ceilf(fh.ascent) - 1.0));
        }
 }
 
@@ -763,7 +777,7 @@ SeekSlider::MouseUp(BPoint where)
 void
 SeekSlider::ResizeToPreferred()
 {
-       float width = 15.0 + StringWidth(kDisabledSeekMessage) + 15.0;
+       float width = 15.0 + StringWidth(DISABLED_SEEK_MESSAGE) + 15.0;
        ResizeTo(width, 17.0);
 }
 
@@ -1254,9 +1268,9 @@ PositionInfoView::Draw( BRect updateRect )
                        float height = ( r.Height() - timeHeight ) / 3.0;
                        SetFont( &tinyFont );
                        SetHighColor( 0, 180, 0, 255 );
-                       DrawString( "File", BPoint( r.left + 3.0, r.top + height ) );
-                       DrawString( "Title", BPoint( r.left + 3.0, r.top + 2.0 * height ) );
-                       DrawString( "Chapter", BPoint( r.left + 3.0, r.top + 3.0 * height ) );
+                       DrawString( _("File"), BPoint( r.left + 3.0, r.top + height ) );
+                       DrawString( _("Title"), BPoint( r.left + 3.0, r.top + 2.0 * height ) );
+                       DrawString( _("Chapter"), BPoint( r.left + 3.0, r.top + 3.0 * height ) );
                        SetFont( &smallFont );
                        BString helper;
                        SetHighColor( 0, 255, 0, 255 );
@@ -1454,12 +1468,12 @@ void
 PositionInfoView::_MakeString( BString& into, int32 index, int32 maxIndex ) const
 {
        into = "";
-       if ( index >= 0)
+       if ( index >= 0 && maxIndex >= 0 )
                into << index;
        else
                into << "-";
        into << "/";
-       if ( maxIndex >= 0)
+       if ( maxIndex >= 0 )
                into << maxIndex;
        else
                into << "-";