* Added a position tool tip to the seek slider.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33816 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -4,7 +4,7 @@ SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||
|
||||
# for BRecentItems
|
||||
UsePublicHeaders [ FDirName be_apps Tracker ] ;
|
||||
UsePrivateHeaders shared ;
|
||||
UsePrivateHeaders interface shared ;
|
||||
|
||||
# source directories
|
||||
local sourceDirs =
|
||||
@@ -27,6 +27,7 @@ Application MediaPlayer :
|
||||
# interface
|
||||
DrawingTidbits.cpp
|
||||
PeakView.cpp
|
||||
PositionToolTip.cpp
|
||||
SeekSlider.cpp
|
||||
TransportButton.cpp
|
||||
VolumeSlider.cpp
|
||||
|
||||
@@ -480,8 +480,10 @@ MainWin::MessageReceived(BMessage *msg)
|
||||
case MSG_CONTROLLER_POSITION_CHANGED:
|
||||
{
|
||||
float position;
|
||||
if (msg->FindFloat("position", &position) == B_OK)
|
||||
fControls->SetPosition(position);
|
||||
if (msg->FindFloat("position", &position) == B_OK) {
|
||||
fControls->SetPosition(position, fController->TimePosition(),
|
||||
fController->TimeDuration());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MSG_CONTROLLER_VOLUME_CHANGED:
|
||||
|
||||
@@ -3,10 +3,12 @@
|
||||
* All rights reserved. Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
// NOTE: Based on my code in the BeOS interface for the VLC media player
|
||||
// that I did during the VLC 0.4.3 - 0.4.6 times. Code not written by me
|
||||
// removed. -Stephan Aßmus
|
||||
|
||||
|
||||
#include "TransportControlGroup.h"
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -17,6 +19,7 @@
|
||||
#include "ButtonBitmaps.h"
|
||||
#include "PeakView.h"
|
||||
#include "PlaybackState.h"
|
||||
#include "PositionToolTip.h"
|
||||
#include "SeekSlider.h"
|
||||
#include "TransportButton.h"
|
||||
#include "VolumeSlider.h"
|
||||
@@ -68,6 +71,9 @@ TransportControlGroup::TransportControlGroup(BRect frame, bool useSkipButtons,
|
||||
fSeekSlider->ResizeToPreferred();
|
||||
AddChild(fSeekSlider);
|
||||
|
||||
fPositionToolTip = new PositionToolTip();
|
||||
fSeekSlider->SetToolTip(fPositionToolTip);
|
||||
|
||||
// Buttons
|
||||
if (useSkipButtons) {
|
||||
// Skip Back
|
||||
@@ -162,6 +168,8 @@ TransportControlGroup::TransportControlGroup(BRect frame, bool useSkipButtons,
|
||||
|
||||
TransportControlGroup::~TransportControlGroup()
|
||||
{
|
||||
if (!fSeekSlider->IsEnabled())
|
||||
delete fPositionToolTip;
|
||||
}
|
||||
|
||||
|
||||
@@ -342,6 +350,8 @@ TransportControlGroup::SetEnabled(uint32 buttons)
|
||||
return;
|
||||
|
||||
fSeekSlider->SetEnabled(buttons & SEEK_ENABLED);
|
||||
fSeekSlider->SetToolTip((buttons & SEEK_ENABLED) != 0
|
||||
? fPositionToolTip : NULL);
|
||||
|
||||
fVolumeSlider->SetEnabled(buttons & VOLUME_ENABLED);
|
||||
fMute->SetEnabled(buttons & VOLUME_ENABLED);
|
||||
@@ -443,11 +453,13 @@ TransportControlGroup::SetVolume(float value)
|
||||
|
||||
|
||||
void
|
||||
TransportControlGroup::SetPosition(float value)
|
||||
TransportControlGroup::SetPosition(float value, bigtime_t position,
|
||||
bigtime_t duration)
|
||||
{
|
||||
if (fSeekSlider->IsTracking())
|
||||
return;
|
||||
|
||||
fPositionToolTip->Update(position, duration);
|
||||
fSeekSlider->SetPosition(value);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
class PeakView;
|
||||
class PlayPauseButton;
|
||||
class PositionToolTip;
|
||||
class TransportButton;
|
||||
class SeekSlider;
|
||||
class VolumeSlider;
|
||||
@@ -65,7 +66,8 @@ public:
|
||||
void SetMuted(bool mute);
|
||||
|
||||
void SetVolume(float value);
|
||||
void SetPosition(float value);
|
||||
void SetPosition(float value, bigtime_t position,
|
||||
bigtime_t duration);
|
||||
|
||||
PeakView* GetPeakView() const
|
||||
{ return fPeakView; }
|
||||
@@ -93,6 +95,7 @@ private:
|
||||
float _GainToDb(float gain);
|
||||
|
||||
SeekSlider* fSeekSlider;
|
||||
PositionToolTip* fPositionToolTip;
|
||||
PeakView* fPeakView;
|
||||
VolumeSlider* fVolumeSlider;
|
||||
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright 2009, Axel Dörfler, axeld@pinc-software.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include "PositionToolTip.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <StringView.h>
|
||||
|
||||
|
||||
class PositionToolTip::PositionView : public BStringView {
|
||||
public:
|
||||
PositionView()
|
||||
:
|
||||
BStringView("position", ""),
|
||||
fPosition(0),
|
||||
fDuration(0)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~PositionView()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void AttachedToWindow()
|
||||
{
|
||||
BStringView::AttachedToWindow();
|
||||
Update(-1, -1);
|
||||
}
|
||||
|
||||
void Update(bigtime_t position, bigtime_t duration)
|
||||
{
|
||||
if (!LockLooper())
|
||||
return;
|
||||
|
||||
if (position != -1) {
|
||||
position /= 1000000L;
|
||||
duration /= 1000000L;
|
||||
if (position == fPosition && duration == fDuration) {
|
||||
UnlockLooper();
|
||||
return;
|
||||
}
|
||||
|
||||
fPosition = position;
|
||||
fDuration = duration;
|
||||
}
|
||||
|
||||
char text[64];
|
||||
snprintf(text, sizeof(text), "%02ld:%02ld / %02ld:%02ld",
|
||||
fPosition / 60, fPosition % 60, fDuration / 60, fDuration % 60);
|
||||
SetText(text);
|
||||
|
||||
UnlockLooper();
|
||||
}
|
||||
|
||||
private:
|
||||
time_t fPosition;
|
||||
time_t fDuration;
|
||||
};
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
PositionToolTip::PositionToolTip()
|
||||
{
|
||||
fView = new PositionView();
|
||||
}
|
||||
|
||||
|
||||
PositionToolTip::~PositionToolTip()
|
||||
{
|
||||
delete fView;
|
||||
}
|
||||
|
||||
|
||||
BView*
|
||||
PositionToolTip::View() const
|
||||
{
|
||||
return fView;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PositionToolTip::Update(bigtime_t position, bigtime_t duration)
|
||||
{
|
||||
fView->Update(position, duration);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright 2009, Axel Dörfler, axeld@pinc-software.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef POSITION_TOOL_TIP_H
|
||||
#define POSITION_TOOL_TIP_H
|
||||
|
||||
|
||||
#include <ToolTip.h>
|
||||
|
||||
|
||||
class PositionToolTip : public BToolTip {
|
||||
public:
|
||||
PositionToolTip();
|
||||
virtual ~PositionToolTip();
|
||||
|
||||
virtual BView* View() const;
|
||||
|
||||
void Update(bigtime_t position, bigtime_t duration);
|
||||
|
||||
private:
|
||||
class PositionView;
|
||||
|
||||
PositionView* fView;
|
||||
};
|
||||
|
||||
#endif // POSITION_TOOL_TIP_H
|
||||
Reference in New Issue
Block a user