Commit 8a9bec42 authored by Eric Petit's avatar Eric Petit

beos/*: fixed seek, clean up

parent 254f695e
...@@ -851,7 +851,7 @@ void InterfaceWindow::UpdateInterface() ...@@ -851,7 +851,7 @@ void InterfaceWindow::UpdateInterface()
#endif #endif
audio_volume_t i_volume; audio_volume_t i_volume;
aout_VolumeGet( p_input, &i_volume ); aout_VolumeGet( p_intf, &i_volume );
p_mediaControl->SetAudioEnabled( true ); p_mediaControl->SetAudioEnabled( true );
p_mediaControl->SetMuted( i_volume ); p_mediaControl->SetMuted( i_volume );
......
...@@ -81,7 +81,6 @@ MediaControlView::MediaControlView( intf_thread_t * _p_intf, BRect frame) ...@@ -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, : BBox(frame, NULL, B_FOLLOW_NONE, B_WILL_DRAW | B_FRAME_EVENTS | B_PULSE_NEEDED,
B_PLAIN_BORDER), B_PLAIN_BORDER),
p_intf( _p_intf ), p_intf( _p_intf ),
fScrubSem(B_ERROR),
fCurrentRate(INPUT_RATE_DEFAULT), fCurrentRate(INPUT_RATE_DEFAULT),
fCurrentStatus(-1), fCurrentStatus(-1),
fBottomControlHeight(0.0), fBottomControlHeight(0.0),
...@@ -90,8 +89,7 @@ MediaControlView::MediaControlView( intf_thread_t * _p_intf, BRect frame) ...@@ -90,8 +89,7 @@ MediaControlView::MediaControlView( intf_thread_t * _p_intf, BRect frame)
BRect frame(0.0, 0.0, 10.0, 10.0); BRect frame(0.0, 0.0, 10.0, 10.0);
// Seek Slider // Seek Slider
fSeekSlider = new SeekSlider( frame, "seek slider", this, fSeekSlider = new SeekSlider( p_intf, frame, "seek slider", this );
0, SEEKSLIDER_RANGE );
fSeekSlider->SetValue(0); fSeekSlider->SetValue(0);
fSeekSlider->ResizeToPreferred(); fSeekSlider->ResizeToPreferred();
AddChild( fSeekSlider ); AddChild( fSeekSlider );
...@@ -370,13 +368,6 @@ MediaControlView::SetAudioEnabled(bool enabled) ...@@ -370,13 +368,6 @@ MediaControlView::SetAudioEnabled(bool enabled)
fVolumeSlider->SetEnabled(enabled); fVolumeSlider->SetEnabled(enabled);
} }
// GetSeekTo
uint32
MediaControlView::GetSeekTo() const
{
return fSeekSlider->Value();
}
// GetVolume // GetVolume
uint32 uint32
MediaControlView::GetVolume() const MediaControlView::GetVolume() const
...@@ -531,14 +522,13 @@ MediaControlView::_LayoutControl(BView* view, BRect frame, ...@@ -531,14 +522,13 @@ MediaControlView::_LayoutControl(BView* view, BRect frame,
/***************************************************************************** /*****************************************************************************
* SeekSlider * SeekSlider
*****************************************************************************/ *****************************************************************************/
SeekSlider::SeekSlider(BRect frame, const char* name, MediaControlView *owner, SeekSlider::SeekSlider( intf_thread_t * _p_intf,
int32 minValue, int32 maxValue) BRect frame, const char* name, MediaControlView *owner )
: BControl(frame, name, NULL, NULL, B_FOLLOW_NONE, : BControl(frame, name, NULL, NULL, B_FOLLOW_NONE,
B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE), B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE),
p_intf(_p_intf),
fOwner(owner), fOwner(owner),
fTracking(false), fTracking(false)
fMinValue(minValue),
fMaxValue(maxValue)
{ {
BFont font(be_plain_font); BFont font(be_plain_font);
font.SetSize(9.0); font.SetSize(9.0);
...@@ -547,7 +537,6 @@ SeekSlider::SeekSlider(BRect frame, const char* name, MediaControlView *owner, ...@@ -547,7 +537,6 @@ SeekSlider::SeekSlider(BRect frame, const char* name, MediaControlView *owner,
SeekSlider::~SeekSlider() SeekSlider::~SeekSlider()
{ {
_EndSeek();
} }
/***************************************************************************** /*****************************************************************************
...@@ -571,8 +560,8 @@ SeekSlider::Draw(BRect updateRect) ...@@ -571,8 +560,8 @@ SeekSlider::Draw(BRect updateRect)
float sliderStart = (r.left + knobWidth2); float sliderStart = (r.left + knobWidth2);
float sliderEnd = (r.right - knobWidth2); float sliderEnd = (r.right - knobWidth2);
float knobPos = sliderStart float knobPos = sliderStart
+ floorf((sliderEnd - sliderStart - 1.0) * (Value() - fMinValue) + floorf((sliderEnd - sliderStart - 1.0) * Value()
/ (fMaxValue - fMinValue) + 0.5); / SEEKSLIDER_RANGE);
// draw both sides (the original from Be doesn't seem // draw both sides (the original from Be doesn't seem
// to make a difference for enabled/disabled state) // to make a difference for enabled/disabled state)
// DrawBitmapAsync(fLeftSideBits, r.LeftTop()); // DrawBitmapAsync(fLeftSideBits, r.LeftTop());
...@@ -740,7 +729,6 @@ SeekSlider::MouseDown(BPoint where) ...@@ -740,7 +729,6 @@ SeekSlider::MouseDown(BPoint where)
SetValue(_ValueFor(where.x)); SetValue(_ValueFor(where.x));
fTracking = true; fTracking = true;
SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS); SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS);
_BeginSeek();
} }
} }
...@@ -753,7 +741,6 @@ SeekSlider::MouseMoved(BPoint where, uint32 code, const BMessage* dragMessage) ...@@ -753,7 +741,6 @@ SeekSlider::MouseMoved(BPoint where, uint32 code, const BMessage* dragMessage)
if (fTracking) if (fTracking)
{ {
SetValue(_ValueFor(where.x)); SetValue(_ValueFor(where.x));
_Seek();
} }
} }
...@@ -766,7 +753,16 @@ SeekSlider::MouseUp(BPoint where) ...@@ -766,7 +753,16 @@ SeekSlider::MouseUp(BPoint where)
if (fTracking) if (fTracking)
{ {
fTracking = false; 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) ...@@ -788,7 +784,10 @@ SeekSlider::SetPosition(float position)
{ {
if ( LockLooper() ) if ( LockLooper() )
{ {
SetValue(fMinValue + (int32)floorf((fMaxValue - fMinValue) * position + 0.5)); if( !fTracking )
{
SetValue( SEEKSLIDER_RANGE * position );
}
UnlockLooper(); UnlockLooper();
} }
} }
...@@ -803,12 +802,12 @@ SeekSlider::_ValueFor(float xPos) const ...@@ -803,12 +802,12 @@ SeekSlider::_ValueFor(float xPos) const
float knobWidth2 = SEEK_SLIDER_KNOB_WIDTH / 2.0; float knobWidth2 = SEEK_SLIDER_KNOB_WIDTH / 2.0;
float sliderStart = (r.left + knobWidth2); float sliderStart = (r.left + knobWidth2);
float sliderEnd = (r.right - 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)); / (sliderEnd - sliderStart - 1.0));
if (value < fMinValue) if (value < 0)
value = fMinValue; value = 0;
if (value > fMaxValue) if (value > SEEKSLIDER_RANGE)
value = fMaxValue; value = SEEKSLIDER_RANGE;
return value; return value;
} }
...@@ -827,42 +826,6 @@ SeekSlider::_StrokeFrame(BRect r, rgb_color left, rgb_color top, ...@@ -827,42 +826,6 @@ SeekSlider::_StrokeFrame(BRect r, rgb_color left, rgb_color top,
EndLineArray(); 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 * VolumeSlider
*****************************************************************************/ *****************************************************************************/
......
...@@ -54,14 +54,11 @@ class MediaControlView : public BBox ...@@ -54,14 +54,11 @@ class MediaControlView : public BBox
void SetStatus(int status, int rate); void SetStatus(int status, int rate);
void SetEnabled(bool enable); void SetEnabled(bool enable);
void SetAudioEnabled(bool enable); void SetAudioEnabled(bool enable);
uint32 GetSeekTo() const;
uint32 GetVolume() const; uint32 GetVolume() const;
void SetSkippable(bool backward, void SetSkippable(bool backward,
bool forward); bool forward);
void SetMuted(bool mute); void SetMuted(bool mute);
sem_id fScrubSem;
private: private:
void _LayoutControls(BRect frame) const; void _LayoutControls(BRect frame) const;
BRect _MinFrame() const; BRect _MinFrame() const;
...@@ -94,11 +91,10 @@ class MediaControlView : public BBox ...@@ -94,11 +91,10 @@ class MediaControlView : public BBox
class SeekSlider : public BControl class SeekSlider : public BControl
{ {
public: public:
SeekSlider(BRect frame, SeekSlider(intf_thread_t * p_intf,
BRect frame,
const char* name, const char* name,
MediaControlView* owner, MediaControlView* owner );
int32 minValue,
int32 maxValue);
virtual ~SeekSlider(); virtual ~SeekSlider();
...@@ -121,14 +117,10 @@ private: ...@@ -121,14 +117,10 @@ private:
rgb_color top, rgb_color top,
rgb_color right, rgb_color right,
rgb_color bottom); rgb_color bottom);
void _BeginSeek();
void _Seek();
void _EndSeek();
intf_thread_t * p_intf;
MediaControlView* fOwner; MediaControlView* fOwner;
bool fTracking; bool fTracking;
int32 fMinValue;
int32 fMaxValue;
}; };
class VolumeSlider : public BControl class VolumeSlider : public BControl
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment