Implemented Fast Forward and Rewind
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13649 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include "CDPlayer.h"
|
#include "CDPlayer.h"
|
||||||
#include "DrawButton.h"
|
#include "DrawButton.h"
|
||||||
|
#include "DoubleShotDrawButton.h"
|
||||||
#include "TwoStateDrawButton.h"
|
#include "TwoStateDrawButton.h"
|
||||||
#include <TranslationUtils.h>
|
#include <TranslationUtils.h>
|
||||||
#include <TranslatorFormats.h>
|
#include <TranslatorFormats.h>
|
||||||
@@ -177,24 +178,23 @@ void CDPlayer::BuildGUI(void)
|
|||||||
fNextTrack->SetDisabled(BTranslationUtils::GetBitmap(B_PNG_FORMAT,"next_disabled"));
|
fNextTrack->SetDisabled(BTranslationUtils::GetBitmap(B_PNG_FORMAT,"next_disabled"));
|
||||||
AddChild(fNextTrack);
|
AddChild(fNextTrack);
|
||||||
|
|
||||||
// TODO: Fast Forward and Rewind are special buttons. Implement as two-state buttons
|
fRewind = new DoubleShotDrawButton( BRect(0,0,1,1), "Rewind",
|
||||||
fRewind = new DrawButton( BRect(0,0,1,1), "Rewind", BTranslationUtils::GetBitmap(B_PNG_FORMAT,"rew_up"),
|
BTranslationUtils::GetBitmap(B_PNG_FORMAT,"rew_up"),
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT,"rew_down"), new BMessage(M_PREV_TRACK),
|
BTranslationUtils::GetBitmap(B_PNG_FORMAT,"rew_down"),
|
||||||
B_FOLLOW_BOTTOM, B_WILL_DRAW);
|
new BMessage(M_REWIND), B_FOLLOW_BOTTOM, B_WILL_DRAW);
|
||||||
fRewind->ResizeToPreferred();
|
fRewind->ResizeToPreferred();
|
||||||
fRewind->MoveTo(fNextTrack->Frame().right + 10, Bounds().bottom - 5 - fRewind->Frame().Height());
|
fRewind->MoveTo(fNextTrack->Frame().right + 10, Bounds().bottom - 5 - fRewind->Frame().Height());
|
||||||
fRewind->SetDisabled(BTranslationUtils::GetBitmap(B_PNG_FORMAT,"rew_disabled"));
|
fRewind->SetDisabled(BTranslationUtils::GetBitmap(B_PNG_FORMAT,"rew_disabled"));
|
||||||
AddChild(fRewind);
|
AddChild(fRewind);
|
||||||
fRewind->SetEnabled(false);
|
|
||||||
|
|
||||||
fFastFwd = new DrawButton( BRect(0,0,1,1), "FastFwd", BTranslationUtils::GetBitmap(B_PNG_FORMAT,"ffwd_up"),
|
fFastFwd = new DoubleShotDrawButton( BRect(0,0,1,1), "FastFwd",
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT,"ffwd_down"), new BMessage(M_NEXT_TRACK),
|
BTranslationUtils::GetBitmap(B_PNG_FORMAT,"ffwd_up"),
|
||||||
B_FOLLOW_BOTTOM, B_WILL_DRAW);
|
BTranslationUtils::GetBitmap(B_PNG_FORMAT,"ffwd_down"),
|
||||||
|
new BMessage(M_FFWD), B_FOLLOW_BOTTOM, B_WILL_DRAW);
|
||||||
fFastFwd->ResizeToPreferred();
|
fFastFwd->ResizeToPreferred();
|
||||||
fFastFwd->MoveTo(fRewind->Frame().right + 2, Bounds().bottom - 5 - fFastFwd->Frame().Height());
|
fFastFwd->MoveTo(fRewind->Frame().right + 2, Bounds().bottom - 5 - fFastFwd->Frame().Height());
|
||||||
fFastFwd->SetDisabled(BTranslationUtils::GetBitmap(B_PNG_FORMAT,"ffwd_disabled"));
|
fFastFwd->SetDisabled(BTranslationUtils::GetBitmap(B_PNG_FORMAT,"ffwd_disabled"));
|
||||||
AddChild(fFastFwd);
|
AddChild(fFastFwd);
|
||||||
fFastFwd->SetEnabled(false);
|
|
||||||
|
|
||||||
fEject = new DrawButton( BRect(0,0,1,1), "Eject", BTranslationUtils::GetBitmap(B_PNG_FORMAT,"eject_up"),
|
fEject = new DrawButton( BRect(0,0,1,1), "Eject", BTranslationUtils::GetBitmap(B_PNG_FORMAT,"eject_up"),
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT,"eject_down"), new BMessage(M_EJECT),
|
BTranslationUtils::GetBitmap(B_PNG_FORMAT,"eject_down"), new BMessage(M_EJECT),
|
||||||
@@ -295,11 +295,19 @@ CDPlayer::MessageReceived(BMessage *msg)
|
|||||||
case M_FFWD:
|
case M_FFWD:
|
||||||
{
|
{
|
||||||
// TODO: Implement
|
// TODO: Implement
|
||||||
|
if(fFastFwd->Value() == B_CONTROL_ON)
|
||||||
|
engine->StartSkippingForward();
|
||||||
|
else
|
||||||
|
engine->StopSkipping();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case M_REWIND:
|
case M_REWIND:
|
||||||
{
|
{
|
||||||
// TODO: Implement
|
// TODO: Implement
|
||||||
|
if(fRewind->Value() == B_CONTROL_ON)
|
||||||
|
engine->StartSkippingBackward();
|
||||||
|
else
|
||||||
|
engine->StopSkipping();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case M_SAVE:
|
case M_SAVE:
|
||||||
@@ -437,8 +445,7 @@ CDPlayer::AdjustButtonStates(void)
|
|||||||
fPlay->SetEnabled(false);
|
fPlay->SetEnabled(false);
|
||||||
fNextTrack->SetEnabled(false);
|
fNextTrack->SetEnabled(false);
|
||||||
fPrevTrack->SetEnabled(false);
|
fPrevTrack->SetEnabled(false);
|
||||||
fFastFwd->SetEnabled(false);
|
|
||||||
fRewind->SetEnabled(false);
|
|
||||||
fSave->SetEnabled(false);
|
fSave->SetEnabled(false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -449,9 +456,6 @@ CDPlayer::AdjustButtonStates(void)
|
|||||||
fNextTrack->SetEnabled(true);
|
fNextTrack->SetEnabled(true);
|
||||||
fPrevTrack->SetEnabled(true);
|
fPrevTrack->SetEnabled(true);
|
||||||
|
|
||||||
fFastFwd->SetEnabled(false);
|
|
||||||
fRewind->SetEnabled(false);
|
|
||||||
|
|
||||||
// TODO: Enable when Save is implemented
|
// TODO: Enable when Save is implemented
|
||||||
// fSave->SetEnabled(true);
|
// fSave->SetEnabled(true);
|
||||||
|
|
||||||
@@ -460,9 +464,6 @@ CDPlayer::AdjustButtonStates(void)
|
|||||||
}
|
}
|
||||||
case kPaused:
|
case kPaused:
|
||||||
{
|
{
|
||||||
// We can only pause when everything is enabled, so this is all we should do.
|
|
||||||
fFastFwd->SetEnabled(false);
|
|
||||||
fRewind->SetEnabled(false);
|
|
||||||
fPlay->SetState(0);
|
fPlay->SetState(0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -473,9 +474,6 @@ CDPlayer::AdjustButtonStates(void)
|
|||||||
fNextTrack->SetEnabled(true);
|
fNextTrack->SetEnabled(true);
|
||||||
fPrevTrack->SetEnabled(true);
|
fPrevTrack->SetEnabled(true);
|
||||||
|
|
||||||
fFastFwd->SetEnabled(true);
|
|
||||||
fRewind->SetEnabled(true);
|
|
||||||
|
|
||||||
// TODO: Enable when Save is implemented
|
// TODO: Enable when Save is implemented
|
||||||
// fSave->SetEnabled(true);
|
// fSave->SetEnabled(true);
|
||||||
|
|
||||||
@@ -629,8 +627,8 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
CDPlayerWindow::CDPlayerWindow(void)
|
CDPlayerWindow::CDPlayerWindow(void)
|
||||||
: BWindow(BRect (100, 100, 610, 200), "CD Player", B_TITLED_WINDOW, B_NOT_V_RESIZABLE |
|
: BWindow(BRect (100, 100, 610, 200), "CD Player", B_TITLED_WINDOW, B_NOT_V_RESIZABLE |
|
||||||
B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS)
|
B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS)
|
||||||
{
|
{
|
||||||
float wmin,wmax,hmin,hmax;
|
float wmin,wmax,hmin,hmax;
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#include "TrackMenu.h"
|
#include "TrackMenu.h"
|
||||||
|
|
||||||
class DrawButton;
|
class DrawButton;
|
||||||
|
class DoubleShotDrawButton;
|
||||||
class TwoStateDrawButton;
|
class TwoStateDrawButton;
|
||||||
|
|
||||||
class CDPlayer : public BView, private Observer
|
class CDPlayer : public BView, private Observer
|
||||||
@@ -40,8 +41,7 @@ public:
|
|||||||
virtual void MessageReceived(BMessage *);
|
virtual void MessageReceived(BMessage *);
|
||||||
|
|
||||||
// observing overrides
|
// observing overrides
|
||||||
virtual BHandler *RecipientHandler() const
|
virtual BHandler *RecipientHandler() const { return (BHandler *)this; }
|
||||||
{ return (BHandler *)this; }
|
|
||||||
|
|
||||||
virtual void NoticeChange(Notifier *);
|
virtual void NoticeChange(Notifier *);
|
||||||
|
|
||||||
@@ -54,13 +54,14 @@ private:
|
|||||||
CDEngine *engine;
|
CDEngine *engine;
|
||||||
|
|
||||||
DrawButton *fStop,
|
DrawButton *fStop,
|
||||||
// *fPlay,
|
|
||||||
*fNextTrack,
|
*fNextTrack,
|
||||||
*fPrevTrack,
|
*fPrevTrack,
|
||||||
*fFastFwd,
|
|
||||||
*fRewind,
|
|
||||||
*fEject,
|
*fEject,
|
||||||
*fSave;
|
*fSave;
|
||||||
|
|
||||||
|
DoubleShotDrawButton
|
||||||
|
*fFastFwd,
|
||||||
|
*fRewind;
|
||||||
|
|
||||||
TwoStateDrawButton *fShuffle,
|
TwoStateDrawButton *fShuffle,
|
||||||
*fRepeat,
|
*fRepeat,
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
#include "DoubleShotDrawButton.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
// The only difference between this class and DrawButton is the fact that it is invoked
|
||||||
|
// twice during a mousedown-mouseup cycle. It fires when pushed, and then again when
|
||||||
|
// released.
|
||||||
|
|
||||||
|
DoubleShotDrawButton::DoubleShotDrawButton(BRect frame, const char *name, BBitmap *up,
|
||||||
|
BBitmap *down,BMessage *msg, int32 resize,
|
||||||
|
int32 flags)
|
||||||
|
: DrawButton(frame, name, up,down, msg, resize, flags)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
DoubleShotDrawButton::MouseDown(BPoint point)
|
||||||
|
{
|
||||||
|
Invoke();
|
||||||
|
DrawButton::MouseDown(point);
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
#ifndef _DOUBLESHOT_DRAW_BUTTON_H
|
||||||
|
#define _DOUBLESHOT_DRAW_BUTTON_H
|
||||||
|
|
||||||
|
#include <Looper.h>
|
||||||
|
#include <Application.h>
|
||||||
|
#include <Window.h>
|
||||||
|
#include <Button.h>
|
||||||
|
#include <Bitmap.h>
|
||||||
|
#include <Rect.h>
|
||||||
|
#include "DrawButton.h"
|
||||||
|
|
||||||
|
class DoubleShotDrawButton : public DrawButton
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DoubleShotDrawButton(BRect frame, const char *name, BBitmap *up,
|
||||||
|
BBitmap *down,BMessage *msg, int32 resize,
|
||||||
|
int32 flags);
|
||||||
|
|
||||||
|
void MouseDown(BPoint point);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -12,16 +12,16 @@
|
|||||||
class DrawButton : public BButton
|
class DrawButton : public BButton
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DrawButton(BRect frame, const char *name, BBitmap *up,
|
DrawButton(BRect frame, const char *name, BBitmap *up,
|
||||||
BBitmap *down,BMessage *msg, int32 resize,
|
BBitmap *down,BMessage *msg, int32 resize,
|
||||||
int32 flags);
|
int32 flags);
|
||||||
~DrawButton(void);
|
virtual ~DrawButton(void);
|
||||||
|
|
||||||
void Draw(BRect update);
|
void Draw(BRect update);
|
||||||
|
|
||||||
void SetBitmaps(BBitmap *up, BBitmap *down);
|
void SetBitmaps(BBitmap *up, BBitmap *down);
|
||||||
void ResizeToPreferred(void);
|
void ResizeToPreferred(void);
|
||||||
void SetDisabled(BBitmap *disabled);
|
void SetDisabled(BBitmap *disabled);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ App CDPlayer :
|
|||||||
CDDBSupport.cpp
|
CDDBSupport.cpp
|
||||||
CDEngine.cpp
|
CDEngine.cpp
|
||||||
CDPlayer.cpp
|
CDPlayer.cpp
|
||||||
|
DoubleShotDrawButton.cpp
|
||||||
DrawButton.cpp
|
DrawButton.cpp
|
||||||
FunctionObjectMessage.cpp
|
FunctionObjectMessage.cpp
|
||||||
Observer.cpp
|
Observer.cpp
|
||||||
|
|||||||
Reference in New Issue
Block a user