* 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
|
# for BRecentItems
|
||||||
UsePublicHeaders [ FDirName be_apps Tracker ] ;
|
UsePublicHeaders [ FDirName be_apps Tracker ] ;
|
||||||
UsePrivateHeaders shared ;
|
UsePrivateHeaders interface shared ;
|
||||||
|
|
||||||
# source directories
|
# source directories
|
||||||
local sourceDirs =
|
local sourceDirs =
|
||||||
@@ -27,6 +27,7 @@ Application MediaPlayer :
|
|||||||
# interface
|
# interface
|
||||||
DrawingTidbits.cpp
|
DrawingTidbits.cpp
|
||||||
PeakView.cpp
|
PeakView.cpp
|
||||||
|
PositionToolTip.cpp
|
||||||
SeekSlider.cpp
|
SeekSlider.cpp
|
||||||
TransportButton.cpp
|
TransportButton.cpp
|
||||||
VolumeSlider.cpp
|
VolumeSlider.cpp
|
||||||
|
|||||||
@@ -480,8 +480,10 @@ MainWin::MessageReceived(BMessage *msg)
|
|||||||
case MSG_CONTROLLER_POSITION_CHANGED:
|
case MSG_CONTROLLER_POSITION_CHANGED:
|
||||||
{
|
{
|
||||||
float position;
|
float position;
|
||||||
if (msg->FindFloat("position", &position) == B_OK)
|
if (msg->FindFloat("position", &position) == B_OK) {
|
||||||
fControls->SetPosition(position);
|
fControls->SetPosition(position, fController->TimePosition(),
|
||||||
|
fController->TimeDuration());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MSG_CONTROLLER_VOLUME_CHANGED:
|
case MSG_CONTROLLER_VOLUME_CHANGED:
|
||||||
|
|||||||
@@ -3,10 +3,12 @@
|
|||||||
* All rights reserved. Distributed under the terms of the MIT License.
|
* 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
|
// 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
|
// that I did during the VLC 0.4.3 - 0.4.6 times. Code not written by me
|
||||||
// removed. -Stephan Aßmus
|
// removed. -Stephan Aßmus
|
||||||
|
|
||||||
|
|
||||||
#include "TransportControlGroup.h"
|
#include "TransportControlGroup.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -17,6 +19,7 @@
|
|||||||
#include "ButtonBitmaps.h"
|
#include "ButtonBitmaps.h"
|
||||||
#include "PeakView.h"
|
#include "PeakView.h"
|
||||||
#include "PlaybackState.h"
|
#include "PlaybackState.h"
|
||||||
|
#include "PositionToolTip.h"
|
||||||
#include "SeekSlider.h"
|
#include "SeekSlider.h"
|
||||||
#include "TransportButton.h"
|
#include "TransportButton.h"
|
||||||
#include "VolumeSlider.h"
|
#include "VolumeSlider.h"
|
||||||
@@ -68,6 +71,9 @@ TransportControlGroup::TransportControlGroup(BRect frame, bool useSkipButtons,
|
|||||||
fSeekSlider->ResizeToPreferred();
|
fSeekSlider->ResizeToPreferred();
|
||||||
AddChild(fSeekSlider);
|
AddChild(fSeekSlider);
|
||||||
|
|
||||||
|
fPositionToolTip = new PositionToolTip();
|
||||||
|
fSeekSlider->SetToolTip(fPositionToolTip);
|
||||||
|
|
||||||
// Buttons
|
// Buttons
|
||||||
if (useSkipButtons) {
|
if (useSkipButtons) {
|
||||||
// Skip Back
|
// Skip Back
|
||||||
@@ -162,6 +168,8 @@ TransportControlGroup::TransportControlGroup(BRect frame, bool useSkipButtons,
|
|||||||
|
|
||||||
TransportControlGroup::~TransportControlGroup()
|
TransportControlGroup::~TransportControlGroup()
|
||||||
{
|
{
|
||||||
|
if (!fSeekSlider->IsEnabled())
|
||||||
|
delete fPositionToolTip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -342,6 +350,8 @@ TransportControlGroup::SetEnabled(uint32 buttons)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
fSeekSlider->SetEnabled(buttons & SEEK_ENABLED);
|
fSeekSlider->SetEnabled(buttons & SEEK_ENABLED);
|
||||||
|
fSeekSlider->SetToolTip((buttons & SEEK_ENABLED) != 0
|
||||||
|
? fPositionToolTip : NULL);
|
||||||
|
|
||||||
fVolumeSlider->SetEnabled(buttons & VOLUME_ENABLED);
|
fVolumeSlider->SetEnabled(buttons & VOLUME_ENABLED);
|
||||||
fMute->SetEnabled(buttons & VOLUME_ENABLED);
|
fMute->SetEnabled(buttons & VOLUME_ENABLED);
|
||||||
@@ -443,11 +453,13 @@ TransportControlGroup::SetVolume(float value)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TransportControlGroup::SetPosition(float value)
|
TransportControlGroup::SetPosition(float value, bigtime_t position,
|
||||||
|
bigtime_t duration)
|
||||||
{
|
{
|
||||||
if (fSeekSlider->IsTracking())
|
if (fSeekSlider->IsTracking())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
fPositionToolTip->Update(position, duration);
|
||||||
fSeekSlider->SetPosition(value);
|
fSeekSlider->SetPosition(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
class PeakView;
|
class PeakView;
|
||||||
class PlayPauseButton;
|
class PlayPauseButton;
|
||||||
|
class PositionToolTip;
|
||||||
class TransportButton;
|
class TransportButton;
|
||||||
class SeekSlider;
|
class SeekSlider;
|
||||||
class VolumeSlider;
|
class VolumeSlider;
|
||||||
@@ -65,7 +66,8 @@ public:
|
|||||||
void SetMuted(bool mute);
|
void SetMuted(bool mute);
|
||||||
|
|
||||||
void SetVolume(float value);
|
void SetVolume(float value);
|
||||||
void SetPosition(float value);
|
void SetPosition(float value, bigtime_t position,
|
||||||
|
bigtime_t duration);
|
||||||
|
|
||||||
PeakView* GetPeakView() const
|
PeakView* GetPeakView() const
|
||||||
{ return fPeakView; }
|
{ return fPeakView; }
|
||||||
@@ -93,6 +95,7 @@ private:
|
|||||||
float _GainToDb(float gain);
|
float _GainToDb(float gain);
|
||||||
|
|
||||||
SeekSlider* fSeekSlider;
|
SeekSlider* fSeekSlider;
|
||||||
|
PositionToolTip* fPositionToolTip;
|
||||||
PeakView* fPeakView;
|
PeakView* fPeakView;
|
||||||
VolumeSlider* fVolumeSlider;
|
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