From 8a9bec42ee850c316ed94d6afc1c5d2cfd74882c Mon Sep 17 00:00:00 2001 From: Eric Petit Date: Tue, 17 Aug 2004 20:55:55 +0000 Subject: [PATCH] beos/*: fixed seek, clean up --- modules/gui/beos/InterfaceWindow.cpp | 2 +- modules/gui/beos/MediaControlView.cpp | 89 ++++++++------------------- modules/gui/beos/MediaControlView.h | 16 ++--- 3 files changed, 31 insertions(+), 76 deletions(-) diff --git a/modules/gui/beos/InterfaceWindow.cpp b/modules/gui/beos/InterfaceWindow.cpp index 9e4da2678a..630be2005c 100644 --- a/modules/gui/beos/InterfaceWindow.cpp +++ b/modules/gui/beos/InterfaceWindow.cpp @@ -851,7 +851,7 @@ void InterfaceWindow::UpdateInterface() #endif audio_volume_t i_volume; - aout_VolumeGet( p_input, &i_volume ); + aout_VolumeGet( p_intf, &i_volume ); p_mediaControl->SetAudioEnabled( true ); p_mediaControl->SetMuted( i_volume ); diff --git a/modules/gui/beos/MediaControlView.cpp b/modules/gui/beos/MediaControlView.cpp index 1839e34476..dc6cb0af45 100644 --- a/modules/gui/beos/MediaControlView.cpp +++ b/modules/gui/beos/MediaControlView.cpp @@ -81,7 +81,6 @@ 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), p_intf( _p_intf ), - fScrubSem(B_ERROR), fCurrentRate(INPUT_RATE_DEFAULT), fCurrentStatus(-1), fBottomControlHeight(0.0), @@ -90,8 +89,7 @@ MediaControlView::MediaControlView( intf_thread_t * _p_intf, BRect frame) BRect frame(0.0, 0.0, 10.0, 10.0); // Seek Slider - fSeekSlider = new SeekSlider( frame, "seek slider", this, - 0, SEEKSLIDER_RANGE ); + fSeekSlider = new SeekSlider( p_intf, frame, "seek slider", this ); fSeekSlider->SetValue(0); fSeekSlider->ResizeToPreferred(); AddChild( fSeekSlider ); @@ -370,13 +368,6 @@ MediaControlView::SetAudioEnabled(bool enabled) fVolumeSlider->SetEnabled(enabled); } -// GetSeekTo -uint32 -MediaControlView::GetSeekTo() const -{ - return fSeekSlider->Value(); -} - // GetVolume uint32 MediaControlView::GetVolume() const @@ -531,14 +522,13 @@ MediaControlView::_LayoutControl(BView* view, BRect frame, /***************************************************************************** * 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); @@ -547,7 +537,6 @@ SeekSlider::SeekSlider(BRect frame, const char* name, MediaControlView *owner, SeekSlider::~SeekSlider() { - _EndSeek(); } /***************************************************************************** @@ -571,8 +560,8 @@ SeekSlider::Draw(BRect updateRect) 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()); @@ -740,7 +729,6 @@ SeekSlider::MouseDown(BPoint where) SetValue(_ValueFor(where.x)); fTracking = true; SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS); - _BeginSeek(); } } @@ -753,7 +741,6 @@ SeekSlider::MouseMoved(BPoint where, uint32 code, const BMessage* dragMessage) if (fTracking) { SetValue(_ValueFor(where.x)); - _Seek(); } } @@ -766,7 +753,16 @@ SeekSlider::MouseUp(BPoint where) 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 ); + } } } @@ -788,7 +784,10 @@ SeekSlider::SetPosition(float position) { if ( LockLooper() ) { - SetValue(fMinValue + (int32)floorf((fMaxValue - fMinValue) * position + 0.5)); + if( !fTracking ) + { + SetValue( SEEKSLIDER_RANGE * position ); + } UnlockLooper(); } } @@ -803,12 +802,12 @@ SeekSlider::_ValueFor(float xPos) const 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; } @@ -827,42 +826,6 @@ SeekSlider::_StrokeFrame(BRect r, rgb_color left, rgb_color top, 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 *****************************************************************************/ diff --git a/modules/gui/beos/MediaControlView.h b/modules/gui/beos/MediaControlView.h index f324a35a42..6e7b6d14e3 100644 --- a/modules/gui/beos/MediaControlView.h +++ b/modules/gui/beos/MediaControlView.h @@ -54,13 +54,10 @@ class MediaControlView : public BBox void SetStatus(int status, int rate); void SetEnabled(bool enable); void SetAudioEnabled(bool enable); - uint32 GetSeekTo() const; uint32 GetVolume() const; void SetSkippable(bool backward, bool forward); void SetMuted(bool mute); - - sem_id fScrubSem; private: void _LayoutControls(BRect frame) const; @@ -94,11 +91,10 @@ class MediaControlView : public BBox class SeekSlider : public BControl { public: - SeekSlider(BRect frame, + SeekSlider(intf_thread_t * p_intf, + BRect frame, const char* name, - MediaControlView* owner, - int32 minValue, - int32 maxValue); + MediaControlView* owner ); virtual ~SeekSlider(); @@ -121,14 +117,10 @@ private: rgb_color top, rgb_color right, rgb_color bottom); - void _BeginSeek(); - void _Seek(); - void _EndSeek(); + intf_thread_t * p_intf; MediaControlView* fOwner; bool fTracking; - int32 fMinValue; - int32 fMaxValue; }; class VolumeSlider : public BControl -- 2.39.2