/*****************************************************************************
* MediaControlView.cpp: beos interface
*****************************************************************************
- * Copyright (C) 1999, 2000, 2001 VideoLAN
- * $Id: MediaControlView.cpp,v 1.16 2003/04/22 16:36:16 titer Exp $
+ * Copyright (C) 1999, 2000, 2001 the VideoLAN team
+ * $Id$
*
* Authors: Tony Castley <tony@castley.net>
* Stephan Aßmus <stippi@yellowbites.com>
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/* System headers */
/* VLC headers */
#include <vlc/vlc.h>
-#include <vlc/intf.h>
+#include <vlc_interface.h>
+extern "C"
+{
+ #include <audio_output.h>
+}
/* BeOS interface headers */
-#include "VlcWrapper.h"
#include "Bitmaps.h"
#include "DrawingTidbits.h"
#include "InterfaceWindow.h"
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")
+#define SEEKSLIDER_RANGE 2048
enum
{
};
// constructor
-MediaControlView::MediaControlView(BRect frame, intf_thread_t *p_interface)
+MediaControlView::MediaControlView( intf_thread_t * _p_intf, BRect frame)
: 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),
+ p_intf( _p_intf ),
+ fCurrentRate(INPUT_RATE_DEFAULT),
+ fCurrentStatus(-1),
fBottomControlHeight(0.0),
fIsEnabled( true )
{
- p_intf = 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( p_intf, frame, "seek slider", this );
fSeekSlider->SetValue(0);
fSeekSlider->ResizeToPreferred();
AddChild( fSeekSlider );
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
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
+ 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))
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
switch( status )
{
case PLAYING_S:
- case FORWARD_S:
- case BACKWARD_S:
- case START_S:
+ case OPENNING_S:
+ case BUFFERING_S:
fPlayPause->SetPlaying();
break;
case PAUSE_S:
fPlayPause->SetPaused();
break;
- case UNDEF_S:
- case NOT_STARTED_S:
default:
fPlayPause->SetStopped();
break;
if (rate != fCurrentRate)
{
fCurrentRate = rate;
- if ( rate < DEFAULT_RATE )
+ if ( rate < INPUT_RATE_DEFAULT )
{
// TODO: ...
}
fVolumeSlider->SetEnabled(enabled);
}
-// GetSeekTo
-uint32
-MediaControlView::GetSeekTo() const
-{
- return fSeekSlider->Value();
-}
-
// GetVolume
uint32
MediaControlView::GetVolume() const
/*****************************************************************************
* SeekSlider
*****************************************************************************/
-SeekSlider::SeekSlider(BRect frame, const char* name, MediaControlView *owner,
- int32 minValue, int32 maxValue)
+SeekSlider::SeekSlider( intf_thread_t * _p_intf,
+ BRect frame, const char* name, MediaControlView *owner )
: BControl(frame, name, NULL, NULL, B_FOLLOW_NONE,
B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE),
+ p_intf(_p_intf),
fOwner(owner),
- fTracking(false),
- fMinValue(minValue),
- fMaxValue(maxValue)
+ fTracking(false)
{
BFont font(be_plain_font);
font.SetSize(9.0);
SeekSlider::~SeekSlider()
{
- _EndSeek();
}
/*****************************************************************************
float sliderStart = (r.left + knobWidth2);
float sliderEnd = (r.right - knobWidth2);
float knobPos = sliderStart
- + floorf((sliderEnd - sliderStart - 1.0) * (Value() - fMinValue)
- / (fMaxValue - fMinValue) + 0.5);
+ + floorf((sliderEnd - sliderStart - 1.0) * Value()
+ / SEEKSLIDER_RANGE);
// draw both sides (the original from Be doesn't seem
// to make a difference for enabled/disabled state)
// DrawBitmapAsync(fLeftSideBits, r.LeftTop());
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);
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));
}
}
SetValue(_ValueFor(where.x));
fTracking = true;
SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS);
- _BeginSeek();
}
}
if (fTracking)
{
SetValue(_ValueFor(where.x));
- _Seek();
}
}
if (fTracking)
{
fTracking = false;
- _EndSeek();
+ input_thread_t * p_input;
+ p_input = (input_thread_t *)
+ vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
+
+ if( p_input )
+ {
+ var_SetFloat( p_input, "position",
+ (float) Value() / SEEKSLIDER_RANGE );
+ vlc_object_release( p_input );
+ }
}
}
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);
}
{
if ( LockLooper() )
{
- SetValue(fMinValue + (int32)floorf((fMaxValue - fMinValue) * position + 0.5));
+ if( !fTracking )
+ {
+ SetValue( SEEKSLIDER_RANGE * position );
+ }
UnlockLooper();
}
}
float knobWidth2 = SEEK_SLIDER_KNOB_WIDTH / 2.0;
float sliderStart = (r.left + knobWidth2);
float sliderEnd = (r.right - knobWidth2);
- int32 value = fMinValue + (int32)(((xPos - sliderStart) * (fMaxValue - fMinValue))
+ int32 value = (int32)(((xPos - sliderStart) * SEEKSLIDER_RANGE)
/ (sliderEnd - sliderStart - 1.0));
- if (value < fMinValue)
- value = fMinValue;
- if (value > fMaxValue)
- value = fMaxValue;
+ if (value < 0)
+ value = 0;
+ if (value > SEEKSLIDER_RANGE)
+ value = SEEKSLIDER_RANGE;
return value;
}
EndLineArray();
}
-/*****************************************************************************
- * SeekSlider::_BeginSeek
- *****************************************************************************/
-void
-SeekSlider::_BeginSeek()
-{
- fOwner->fScrubSem = create_sem(0, "Vlc::fScrubSem");
- if (fOwner->fScrubSem >= B_OK)
- release_sem(fOwner->fScrubSem);
-}
-
-/*****************************************************************************
- * SeekSlider::_Seek
- *****************************************************************************/
-void
-SeekSlider::_Seek()
-{
- if (fOwner->fScrubSem >= B_OK)
- delete_sem(fOwner->fScrubSem);
- fOwner->fScrubSem = create_sem(0, "Vlc::fScrubSem");
- if (fOwner->fScrubSem >= B_OK)
- release_sem(fOwner->fScrubSem);
-}
-
-/*****************************************************************************
- * SeekSlider::_EndSeek
- *****************************************************************************/
-void
-SeekSlider::_EndSeek()
-{
- if (fOwner->fScrubSem >= B_OK)
- delete_sem(fOwner->fScrubSem);
- fOwner->fScrubSem = B_ERROR;
-}
-
-
/*****************************************************************************
* VolumeSlider
*****************************************************************************/
bigtime_t now = system_time();
if ( now - fLastPulseUpdate > 900000 )
{
+#if 0
int32 index, size;
p_intf->p_sys->p_wrapper->GetPlaylistInfo( index, size );
SetFile( index + 1, size );
SetChapter( index, size );
SetTime( p_intf->p_sys->p_wrapper->GetTimeAsString() );
fLastPulseUpdate = now;
+#endif
}
}