CDPlayer: remove from image & delete
* Does not work on recent hardware * It now lives at: https://github.com/HaikuArchives/CDPlayer Signed-off-by: Axel Dörfler <axeld@pinc-software.de>
This commit is contained in:
parent
de9c061339
commit
7481292e36
|
@ -15,7 +15,7 @@ SYSTEM_BIN += [ FFilterByBuildFeatures
|
||||||
] ;
|
] ;
|
||||||
|
|
||||||
SYSTEM_APPS += [ FFilterByBuildFeatures
|
SYSTEM_APPS += [ FFilterByBuildFeatures
|
||||||
CDPlayer CodyCam
|
CodyCam
|
||||||
GLInfo@mesa
|
GLInfo@mesa
|
||||||
HaikuDepot
|
HaikuDepot
|
||||||
Icon-O-Matic Installer LaunchBox
|
Icon-O-Matic Installer LaunchBox
|
||||||
|
@ -28,7 +28,7 @@ SYSTEM_APPS += [ FFilterByBuildFeatures
|
||||||
] ;
|
] ;
|
||||||
|
|
||||||
DESKBAR_APPLICATIONS +=
|
DESKBAR_APPLICATIONS +=
|
||||||
CodyCam CDPlayer
|
CodyCam
|
||||||
HaikuDepot
|
HaikuDepot
|
||||||
Icon-O-Matic Installer
|
Icon-O-Matic Installer
|
||||||
Magnify Mail MediaConverter MediaPlayer MidiPlayer
|
Magnify Mail MediaConverter MediaPlayer MidiPlayer
|
||||||
|
|
|
@ -6,7 +6,6 @@ HaikuSubInclude activitymonitor ;
|
||||||
HaikuSubInclude autoraise ;
|
HaikuSubInclude autoraise ;
|
||||||
HaikuSubInclude bsnow ;
|
HaikuSubInclude bsnow ;
|
||||||
HaikuSubInclude bootmanager ;
|
HaikuSubInclude bootmanager ;
|
||||||
HaikuSubInclude cdplayer ;
|
|
||||||
HaikuSubInclude charactermap ;
|
HaikuSubInclude charactermap ;
|
||||||
HaikuSubInclude clock ;
|
HaikuSubInclude clock ;
|
||||||
HaikuSubInclude codycam ;
|
HaikuSubInclude codycam ;
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,632 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2006-2007, Haiku, Inc. All Rights Reserved.
|
|
||||||
* Distributed under the terms of the MIT license.
|
|
||||||
*
|
|
||||||
* Author:
|
|
||||||
* DarkWyrm, bpmagic@columbus.rr.com
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "CDAudioDevice.h"
|
|
||||||
#include "scsi.h"
|
|
||||||
|
|
||||||
#include <Debug.h>
|
|
||||||
#include <Directory.h>
|
|
||||||
#include <Entry.h>
|
|
||||||
#include <Path.h>
|
|
||||||
#include <String.h>
|
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
|
|
||||||
struct ConvertedToc {
|
|
||||||
int32 min;
|
|
||||||
int32 sec;
|
|
||||||
int32 frame;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static int32
|
|
||||||
cddb_sum(int n)
|
|
||||||
{
|
|
||||||
char buf[12];
|
|
||||||
int32 ret = 0;
|
|
||||||
|
|
||||||
sprintf(buf, "%u", n);
|
|
||||||
for (const char *p = buf; *p != '\0'; p++)
|
|
||||||
ret += (*p - '0');
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
|
||||||
|
|
||||||
|
|
||||||
CDAudioData::CDAudioData(const int32 &id, const int32 &count,
|
|
||||||
const int32 &discLength)
|
|
||||||
:
|
|
||||||
fDiscId(id),
|
|
||||||
fTrackCount(count),
|
|
||||||
fLength(discLength)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CDAudioData::CDAudioData(const CDAudioData &from)
|
|
||||||
:
|
|
||||||
fDiscId(from.fDiscId),
|
|
||||||
fTrackCount(from.fTrackCount),
|
|
||||||
fLength(from.fLength)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CDAudioData &
|
|
||||||
CDAudioData::operator=(const CDAudioData &from)
|
|
||||||
{
|
|
||||||
fDiscId = from.fDiscId;
|
|
||||||
fTrackCount = from.fTrackCount;
|
|
||||||
fLength = from.fLength;
|
|
||||||
fFrameOffsets = from.fFrameOffsets;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
|
||||||
|
|
||||||
|
|
||||||
CDAudioTime::CDAudioTime(const int32 min,const int32 &sec)
|
|
||||||
:
|
|
||||||
fMinutes(min),
|
|
||||||
fSeconds(sec)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CDAudioTime::CDAudioTime(const CDAudioTime &from)
|
|
||||||
:
|
|
||||||
fMinutes(from.fMinutes),
|
|
||||||
fSeconds(from.fSeconds)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CDAudioTime &
|
|
||||||
CDAudioTime::operator=(const CDAudioTime &from)
|
|
||||||
{
|
|
||||||
fMinutes = from.fMinutes;
|
|
||||||
fSeconds = from.fSeconds;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CDAudioTime
|
|
||||||
CDAudioTime::operator+(const CDAudioTime &from)
|
|
||||||
{
|
|
||||||
CDAudioTime time;
|
|
||||||
|
|
||||||
time.fMinutes = fMinutes + from.fMinutes;
|
|
||||||
time.fSeconds = fSeconds + from.fSeconds;
|
|
||||||
|
|
||||||
while (time.fSeconds > 59) {
|
|
||||||
time.fMinutes++;
|
|
||||||
time.fSeconds -= 60;
|
|
||||||
}
|
|
||||||
return time;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CDAudioTime
|
|
||||||
CDAudioTime::operator-(const CDAudioTime &from)
|
|
||||||
{
|
|
||||||
CDAudioTime time;
|
|
||||||
|
|
||||||
int32 tsec = ((fMinutes * 60) + fSeconds) - ((from.fMinutes * 60)
|
|
||||||
+ from.fSeconds);
|
|
||||||
if (tsec < 0) {
|
|
||||||
time.fMinutes = 0;
|
|
||||||
time.fSeconds = 0;
|
|
||||||
return time;
|
|
||||||
}
|
|
||||||
|
|
||||||
time.fMinutes = tsec / 60;
|
|
||||||
time.fSeconds = tsec % 60;
|
|
||||||
|
|
||||||
return time;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
|
||||||
|
|
||||||
|
|
||||||
CDAudioDevice::CDAudioDevice()
|
|
||||||
{
|
|
||||||
_FindDrives("/dev/disk");
|
|
||||||
if (CountDrives() > 0)
|
|
||||||
SetDrive(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CDAudioDevice::~CDAudioDevice()
|
|
||||||
{
|
|
||||||
for (int32 i = 0; i < fDriveList.CountItems(); i++)
|
|
||||||
delete (BString*) fDriveList.ItemAt(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//! This plays only one track - the track specified
|
|
||||||
bool
|
|
||||||
CDAudioDevice::Play(const int16 &track)
|
|
||||||
{
|
|
||||||
if (GetState() == kNoCD) {
|
|
||||||
// no CD available, bail out
|
|
||||||
ioctl(fFileHandle, B_LOAD_MEDIA, 0, 0);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
scsi_play_track playtrack;
|
|
||||||
|
|
||||||
playtrack.start_track = track;
|
|
||||||
playtrack.start_index = 1;
|
|
||||||
playtrack.end_track = track;
|
|
||||||
playtrack.end_index = 1;
|
|
||||||
|
|
||||||
status_t result = ioctl(fFileHandle, B_SCSI_PLAY_TRACK, &playtrack);
|
|
||||||
if (result != B_OK) {
|
|
||||||
printf("Couldn't play track: %s\n", strerror(errno));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
CDAudioDevice::Pause()
|
|
||||||
{
|
|
||||||
status_t result = ioctl(fFileHandle, B_SCSI_PAUSE_AUDIO);
|
|
||||||
if (result != B_OK) {
|
|
||||||
printf("Couldn't pause track: %s\n", strerror(errno));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
CDAudioDevice::Resume()
|
|
||||||
{
|
|
||||||
CDState state = GetState();
|
|
||||||
if (state == kNoCD) {
|
|
||||||
// no CD available, bail out
|
|
||||||
ioctl(fFileHandle, B_LOAD_MEDIA, 0, 0);
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
if (state == kStopped)
|
|
||||||
return Play(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
status_t result = ioctl(fFileHandle, B_SCSI_RESUME_AUDIO);
|
|
||||||
if (result != B_OK) {
|
|
||||||
printf("Couldn't resume track: %s\n", strerror(errno));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
CDAudioDevice::Stop()
|
|
||||||
{
|
|
||||||
status_t result = ioctl(fFileHandle, B_SCSI_STOP_AUDIO);
|
|
||||||
if (result != B_OK) {
|
|
||||||
printf("Couldn't stop CD: %s\n", strerror(errno));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//! Open or close the CD tray
|
|
||||||
bool
|
|
||||||
CDAudioDevice::Eject()
|
|
||||||
{
|
|
||||||
status_t media_status = B_DEV_NO_MEDIA;
|
|
||||||
|
|
||||||
// get the status first
|
|
||||||
ioctl(fFileHandle, B_GET_MEDIA_STATUS, &media_status, sizeof(media_status));
|
|
||||||
|
|
||||||
// if door open, load the media, else eject the CD
|
|
||||||
status_t result = ioctl(fFileHandle,
|
|
||||||
media_status == B_DEV_DOOR_OPEN ? B_LOAD_MEDIA : B_EJECT_DEVICE);
|
|
||||||
|
|
||||||
if (result != B_OK) {
|
|
||||||
printf("Couldn't eject CD: %s\n", strerror(errno));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
CDAudioDevice::StartFastFwd()
|
|
||||||
{
|
|
||||||
scsi_scan scan;
|
|
||||||
scan.direction = 1;
|
|
||||||
scan.speed = 1;
|
|
||||||
status_t result = ioctl(fFileHandle, B_SCSI_SCAN, &scan);
|
|
||||||
if (result != B_OK) {
|
|
||||||
printf("Couldn't fast forward: %s\n", strerror(errno));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
CDAudioDevice::StopFastFwd()
|
|
||||||
{
|
|
||||||
scsi_scan scan;
|
|
||||||
scan.direction = 0;
|
|
||||||
scan.speed = 1;
|
|
||||||
status_t result = ioctl(fFileHandle, B_SCSI_SCAN, &scan);
|
|
||||||
if (result != B_OK) {
|
|
||||||
printf("Couldn't stop fast forwarding: %s\n", strerror(errno));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
CDAudioDevice::StartRewind()
|
|
||||||
{
|
|
||||||
scsi_scan scan;
|
|
||||||
scan.direction = -1;
|
|
||||||
scan.speed = 1;
|
|
||||||
status_t result = ioctl(fFileHandle, B_SCSI_SCAN, &scan);
|
|
||||||
if (result != B_OK) {
|
|
||||||
printf("Couldn't rewind: %s\n", strerror(errno));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
CDAudioDevice::StopRewind()
|
|
||||||
{
|
|
||||||
scsi_scan scan;
|
|
||||||
scan.direction = 0;
|
|
||||||
scan.speed = 1;
|
|
||||||
status_t result = ioctl(fFileHandle, B_SCSI_SCAN, &scan);
|
|
||||||
if (result != B_OK) {
|
|
||||||
printf("Couldn't stop rewinding: %s\n", strerror(errno));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
CDAudioDevice::SetVolume(uint8 value)
|
|
||||||
{
|
|
||||||
scsi_volume vol;
|
|
||||||
|
|
||||||
// change only port0's volume
|
|
||||||
vol.flags = 2;
|
|
||||||
vol.port0_volume = value;
|
|
||||||
|
|
||||||
status_t result = ioctl(fFileHandle, B_SCSI_SET_VOLUME, &vol);
|
|
||||||
if (result != B_OK) {
|
|
||||||
printf("Couldn't set volume: %s\n", strerror(errno));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
uint8
|
|
||||||
CDAudioDevice::GetVolume()
|
|
||||||
{
|
|
||||||
scsi_volume vol;
|
|
||||||
ioctl(fFileHandle, B_SCSI_GET_VOLUME, &vol);
|
|
||||||
return vol.port0_volume;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//! Check the current CD play state
|
|
||||||
CDState
|
|
||||||
CDAudioDevice::GetState()
|
|
||||||
{
|
|
||||||
scsi_position pos;
|
|
||||||
status_t media_status = B_DEV_NO_MEDIA;
|
|
||||||
|
|
||||||
ioctl(fFileHandle, B_GET_MEDIA_STATUS, &media_status, sizeof(media_status));
|
|
||||||
if (media_status != B_OK)
|
|
||||||
return kNoCD;
|
|
||||||
|
|
||||||
status_t result = ioctl(fFileHandle, B_SCSI_GET_POSITION, &pos);
|
|
||||||
if (result != B_OK)
|
|
||||||
return kNoCD;
|
|
||||||
else if ((!pos.position[1]) || (pos.position[1] >= 0x13) ||
|
|
||||||
((pos.position[1] == 0x12) && (!pos.position[6])))
|
|
||||||
return kStopped;
|
|
||||||
else if (pos.position[1] == 0x11)
|
|
||||||
return kPlaying;
|
|
||||||
else
|
|
||||||
return kPaused;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int16
|
|
||||||
CDAudioDevice::CountTracks()
|
|
||||||
{
|
|
||||||
scsi_toc toc;
|
|
||||||
status_t result = ioctl(fFileHandle, B_SCSI_GET_TOC, &toc);
|
|
||||||
|
|
||||||
if (result != B_OK)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
return toc.toc_data[3];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//! Get the 0-based index of the current track
|
|
||||||
int16
|
|
||||||
CDAudioDevice::GetTrack()
|
|
||||||
{
|
|
||||||
scsi_position pos;
|
|
||||||
|
|
||||||
status_t media_status = B_DEV_NO_MEDIA;
|
|
||||||
|
|
||||||
ioctl(fFileHandle, B_GET_MEDIA_STATUS, &media_status, sizeof(media_status));
|
|
||||||
if (media_status != B_OK)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
status_t result = ioctl(fFileHandle, B_SCSI_GET_POSITION, &pos);
|
|
||||||
if (result != B_OK)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (!pos.position[1] || pos.position[1] >= 0x13
|
|
||||||
|| (pos.position[1] == 0x12 && !pos.position[6]))
|
|
||||||
return 0;
|
|
||||||
else
|
|
||||||
return pos.position[6];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
uint8
|
|
||||||
CDAudioDevice::CountDrives()
|
|
||||||
{
|
|
||||||
return fDriveList.CountItems();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
CDAudioDevice::SetDrive(const int32 &drive)
|
|
||||||
{
|
|
||||||
BString *path = (BString*) fDriveList.ItemAt(drive);
|
|
||||||
|
|
||||||
if (!path)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
int device = open(path->String(), O_RDONLY);
|
|
||||||
if (device >= 0) {
|
|
||||||
fFileHandle = device;
|
|
||||||
fDrivePath = path;
|
|
||||||
fDriveIndex = drive;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const char *
|
|
||||||
CDAudioDevice::GetDrivePath() const
|
|
||||||
{
|
|
||||||
if (!fDrivePath)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return fDrivePath->String();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int32
|
|
||||||
CDAudioDevice::_FindDrives(const char *path)
|
|
||||||
{
|
|
||||||
BDirectory dir(path);
|
|
||||||
|
|
||||||
if (dir.InitCheck() != B_OK)
|
|
||||||
return B_ERROR;
|
|
||||||
|
|
||||||
dir.Rewind();
|
|
||||||
|
|
||||||
BEntry entry;
|
|
||||||
while (dir.GetNextEntry(&entry) >= 0) {
|
|
||||||
BPath path;
|
|
||||||
const char *name;
|
|
||||||
entry_ref e;
|
|
||||||
|
|
||||||
if (entry.GetPath(&path) != B_OK)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
name = path.Path();
|
|
||||||
if (entry.GetRef(&e) != B_OK)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (entry.IsDirectory()) {
|
|
||||||
// ignore floppy -- it is not silent
|
|
||||||
if (strcmp(e.name, "floppy") == 0)
|
|
||||||
continue;
|
|
||||||
else if (strcmp(e.name, "ata") == 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Note that if we check for the count here, we could
|
|
||||||
// just search for one drive. However, we want to find *all* drives
|
|
||||||
// that are available, so we keep searching even if we've found one
|
|
||||||
_FindDrives(name);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
int devfd;
|
|
||||||
device_geometry g;
|
|
||||||
|
|
||||||
// ignore partitions
|
|
||||||
if (strcmp(e.name, "raw") != 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
devfd = open(name, O_RDONLY);
|
|
||||||
if (devfd < 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (ioctl(devfd, B_GET_GEOMETRY, &g, sizeof(g)) >= 0) {
|
|
||||||
if (g.device_type == B_CD)
|
|
||||||
fDriveList.AddItem(new BString(name));
|
|
||||||
}
|
|
||||||
close(devfd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return fDriveList.CountItems();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
CDAudioDevice::GetTime(CDAudioTime &track, CDAudioTime &disc)
|
|
||||||
{
|
|
||||||
scsi_position pos;
|
|
||||||
|
|
||||||
// Sanity check
|
|
||||||
status_t media_status = B_DEV_NO_MEDIA;
|
|
||||||
ioctl(fFileHandle, B_GET_MEDIA_STATUS, &media_status, sizeof(media_status));
|
|
||||||
if (media_status != B_OK)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
status_t result = ioctl(fFileHandle, B_SCSI_GET_POSITION, &pos);
|
|
||||||
|
|
||||||
if (result != B_OK)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if ((!pos.position[1]) || (pos.position[1] >= 0x13) ||
|
|
||||||
((pos.position[1] == 0x12) && (!pos.position[6]))) {
|
|
||||||
// This indicates that we have a CD, but we are stopped.
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
disc.SetMinutes(pos.position[9]);
|
|
||||||
disc.SetSeconds(pos.position[10]);
|
|
||||||
track.SetMinutes(pos.position[13]);
|
|
||||||
track.SetSeconds(pos.position[14]);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
CDAudioDevice::GetTimeForTrack(const int16 &index, CDAudioTime &track)
|
|
||||||
{
|
|
||||||
scsi_toc toc;
|
|
||||||
status_t result = ioctl(fFileHandle, B_SCSI_GET_TOC, &toc);
|
|
||||||
|
|
||||||
if (result != B_OK)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
int16 trackcount = toc.toc_data[3] - toc.toc_data[2] + 1;
|
|
||||||
|
|
||||||
if (index < 1 || index > trackcount)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
TrackDescriptor *desc = (TrackDescriptor*)&(toc.toc_data[4]);
|
|
||||||
|
|
||||||
int32 tracktime = (desc[index].min * 60) + desc[index].sec;
|
|
||||||
|
|
||||||
tracktime -= (desc[index - 1].min * 60) + desc[index - 1].sec;
|
|
||||||
track.SetMinutes(tracktime / 60);
|
|
||||||
track.SetSeconds(tracktime % 60);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
CDAudioDevice::GetTimeForDisc(CDAudioTime &disc)
|
|
||||||
{
|
|
||||||
scsi_toc toc;
|
|
||||||
status_t result = ioctl(fFileHandle, B_SCSI_GET_TOC, &toc);
|
|
||||||
|
|
||||||
if (result != B_OK)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
int16 trackcount = toc.toc_data[3] - toc.toc_data[2] + 1;
|
|
||||||
TrackDescriptor *desc = (TrackDescriptor*)&(toc.toc_data[4]);
|
|
||||||
|
|
||||||
disc.SetMinutes(desc[trackcount].min);
|
|
||||||
disc.SetSeconds(desc[trackcount].sec);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int32
|
|
||||||
CDAudioDevice::GetDiscID()
|
|
||||||
{
|
|
||||||
// Read the disc
|
|
||||||
scsi_toc toc;
|
|
||||||
status_t result = ioctl(fFileHandle, B_SCSI_GET_TOC, &toc);
|
|
||||||
|
|
||||||
if (result != B_OK)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
|
|
||||||
int32 id, numTracks;
|
|
||||||
BString frameOffsetsString;
|
|
||||||
|
|
||||||
ConvertedToc tocData[100];
|
|
||||||
|
|
||||||
// figure out the disc ID
|
|
||||||
for (int index = 0; index < 100; index++) {
|
|
||||||
tocData[index].min = toc.toc_data[9 + 8 * index];
|
|
||||||
tocData[index].sec = toc.toc_data[10 + 8 * index];
|
|
||||||
tocData[index].frame = toc.toc_data[11 + 8 * index];
|
|
||||||
}
|
|
||||||
numTracks = toc.toc_data[3] - toc.toc_data[2] + 1;
|
|
||||||
|
|
||||||
int32 sum1 = 0;
|
|
||||||
int32 sum2 = 0;
|
|
||||||
for (int index = 0; index < numTracks; index++) {
|
|
||||||
sum1 += cddb_sum((tocData[index].min * 60) + tocData[index].sec);
|
|
||||||
|
|
||||||
// the following is probably running over too far
|
|
||||||
sum2 += (tocData[index + 1].min * 60 + tocData[index + 1].sec) -
|
|
||||||
(tocData[index].min * 60 + tocData[index].sec);
|
|
||||||
}
|
|
||||||
id = ((sum1 % 0xff) << 24) + (sum2 << 8) + numTracks;
|
|
||||||
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
CDAudioDevice::IsDataTrack(const int16 &track)
|
|
||||||
{
|
|
||||||
scsi_toc toc;
|
|
||||||
status_t result = ioctl(fFileHandle, B_SCSI_GET_TOC, &toc);
|
|
||||||
|
|
||||||
if (result != B_OK)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
TrackDescriptor *trackindex = (TrackDescriptor*) &(toc.toc_data[4]);
|
|
||||||
if (track > toc.toc_data[3])
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// At least under R5, the SCSI CD drive has each legitimate audio track
|
|
||||||
// have a value of 0x10. Data tracks have a value of 0x14;
|
|
||||||
if (trackindex[track].adr_control & 4)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
|
@ -1,142 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2006-2007, Haiku, Inc. All Rights Reserved.
|
|
||||||
* Distributed under the terms of the MIT license.
|
|
||||||
*
|
|
||||||
* Author:
|
|
||||||
* DarkWyrm, bpmagic@columbus.rr.com
|
|
||||||
*/
|
|
||||||
#ifndef CDAUDIODEVICE_H
|
|
||||||
#define CDAUDIODEVICE_H
|
|
||||||
|
|
||||||
#include <List.h>
|
|
||||||
#include <String.h>
|
|
||||||
#include <SupportDefs.h>
|
|
||||||
|
|
||||||
|
|
||||||
// The SCSI table of contents consists of a 4-byte header followed by 100 track
|
|
||||||
// descriptors, which are each 8 bytes. We don't really need the first 5 bytes
|
|
||||||
// of the track descriptor, so we'll just ignore them. All we really want is the
|
|
||||||
// fLength of each track, which happen to be the last 3 bytes of the descriptor.
|
|
||||||
typedef struct {
|
|
||||||
uint8 reserved;
|
|
||||||
uint8 adr_control; // bytes 0-3 are control, 4-7 are ADR
|
|
||||||
uint8 track_number;
|
|
||||||
uint8 reserved2;
|
|
||||||
|
|
||||||
uint8 reserved3;
|
|
||||||
uint8 min;
|
|
||||||
uint8 sec;
|
|
||||||
uint8 frame;
|
|
||||||
} TrackDescriptor;
|
|
||||||
|
|
||||||
enum CDState {
|
|
||||||
kNoCD = 0,
|
|
||||||
kStopped,
|
|
||||||
kPaused,
|
|
||||||
kPlaying,
|
|
||||||
kSkipping,
|
|
||||||
kError,
|
|
||||||
kInit
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class CDAudioTime {
|
|
||||||
public:
|
|
||||||
CDAudioTime(const int32 min = -1, const int32 &sec = -1);
|
|
||||||
CDAudioTime(const CDAudioTime &from);
|
|
||||||
CDAudioTime &operator=(const CDAudioTime &from);
|
|
||||||
CDAudioTime operator+(const CDAudioTime &from);
|
|
||||||
CDAudioTime operator-(const CDAudioTime &from);
|
|
||||||
|
|
||||||
void SetMinutes(const int32& minutes)
|
|
||||||
{
|
|
||||||
fMinutes = minutes;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetSeconds(const int32& seconds)
|
|
||||||
{
|
|
||||||
fSeconds = seconds;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32 GetMinutes() const
|
|
||||||
{
|
|
||||||
return fMinutes;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32 GetSeconds() const
|
|
||||||
{
|
|
||||||
return fSeconds;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
int32 fMinutes;
|
|
||||||
int32 fSeconds;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class CDAudioData {
|
|
||||||
public:
|
|
||||||
CDAudioData(const int32 &id = -1, const int32 &count = -1,
|
|
||||||
const int32 &discLength = -1);
|
|
||||||
CDAudioData(const CDAudioData &from);
|
|
||||||
CDAudioData &operator=(const CDAudioData &from);
|
|
||||||
|
|
||||||
private:
|
|
||||||
int32 fDiscId;
|
|
||||||
int32 fTrackCount;
|
|
||||||
int32 fLength;
|
|
||||||
BString fFrameOffsets;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class CDAudioDevice {
|
|
||||||
public:
|
|
||||||
CDAudioDevice();
|
|
||||||
~CDAudioDevice();
|
|
||||||
|
|
||||||
bool Play(const int16 &track);
|
|
||||||
bool Pause();
|
|
||||||
bool Resume();
|
|
||||||
bool Stop();
|
|
||||||
bool Eject();
|
|
||||||
|
|
||||||
bool StartFastFwd();
|
|
||||||
bool StopFastFwd();
|
|
||||||
|
|
||||||
bool StartRewind();
|
|
||||||
bool StopRewind();
|
|
||||||
|
|
||||||
bool SetVolume(uint8 value);
|
|
||||||
uint8 GetVolume();
|
|
||||||
|
|
||||||
CDState GetState();
|
|
||||||
|
|
||||||
int16 CountTracks();
|
|
||||||
int16 GetTrack();
|
|
||||||
|
|
||||||
uint8 CountDrives();
|
|
||||||
bool SetDrive(const int32 &drive);
|
|
||||||
const char* GetDrivePath() const;
|
|
||||||
|
|
||||||
int32 GetDrive() const
|
|
||||||
{
|
|
||||||
return fDriveIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GetTime(CDAudioTime &track, CDAudioTime &disc);
|
|
||||||
bool GetTimeForTrack(const int16 &index, CDAudioTime &track);
|
|
||||||
bool GetTimeForDisc(CDAudioTime &disc);
|
|
||||||
int32 GetDiscID();
|
|
||||||
|
|
||||||
bool IsDataTrack(const int16 &track);
|
|
||||||
|
|
||||||
private:
|
|
||||||
int32 _FindDrives(const char *path);
|
|
||||||
|
|
||||||
int fFileHandle;
|
|
||||||
BString* fDrivePath;
|
|
||||||
BList fDriveList;
|
|
||||||
int32 fDriveIndex;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // CDAUDIODEVICE_H
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,212 +0,0 @@
|
||||||
#ifndef CDDBSUPPORT_H
|
|
||||||
#define CDDBSUPPORT_H
|
|
||||||
|
|
||||||
#include "CDAudioDevice.h"
|
|
||||||
|
|
||||||
#include <Entry.h>
|
|
||||||
#include <List.h>
|
|
||||||
#include <NetEndpoint.h>
|
|
||||||
#include <String.h>
|
|
||||||
|
|
||||||
#include <scsi.h>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
using std::vector;
|
|
||||||
|
|
||||||
|
|
||||||
class CDDBData {
|
|
||||||
public:
|
|
||||||
CDDBData(int32 discid = -1);
|
|
||||||
CDDBData(const CDDBData &from);
|
|
||||||
~CDDBData();
|
|
||||||
CDDBData& operator=(const CDDBData &from);
|
|
||||||
|
|
||||||
status_t Load(const entry_ref &ref);
|
|
||||||
status_t Save(const char *filename);
|
|
||||||
|
|
||||||
status_t Load();
|
|
||||||
status_t Save();
|
|
||||||
|
|
||||||
void MakeEmpty();
|
|
||||||
|
|
||||||
void SetDiscID(const int32 &id)
|
|
||||||
{
|
|
||||||
fDiscID = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32 DiscID() const
|
|
||||||
{
|
|
||||||
return fDiscID;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16 CountTracks() const;
|
|
||||||
const char* TrackAt(const int16 &index) const;
|
|
||||||
bool RenameTrack(const int32 &index, const char *newname);
|
|
||||||
void AddTrack(const char *track, const CDAudioTime &time,
|
|
||||||
const int16 &index=-1);
|
|
||||||
void RemoveTrack(const int16 &index);
|
|
||||||
|
|
||||||
CDAudioTime* TrackTimeAt(const int16 &index);
|
|
||||||
|
|
||||||
void SetDiscTime(const CDAudioTime time)
|
|
||||||
{
|
|
||||||
fDiscTime = time;
|
|
||||||
}
|
|
||||||
|
|
||||||
CDAudioTime* DiscTime()
|
|
||||||
{
|
|
||||||
return &fDiscTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetGenre(const char *genre)
|
|
||||||
{
|
|
||||||
fGenre=genre;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* Genre()
|
|
||||||
{
|
|
||||||
return fGenre.String();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetArtist(const char *artist)
|
|
||||||
{
|
|
||||||
fArtist = artist;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* Artist() const
|
|
||||||
{
|
|
||||||
return fArtist.String();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetAlbum(const char *album)
|
|
||||||
{
|
|
||||||
fAlbum = album;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* Album() const
|
|
||||||
{
|
|
||||||
return fAlbum.String();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetYear(const int16 &year)
|
|
||||||
{
|
|
||||||
fYear = year;
|
|
||||||
}
|
|
||||||
|
|
||||||
int16 Year() const
|
|
||||||
{
|
|
||||||
return fYear;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
void _EmptyLists();
|
|
||||||
|
|
||||||
int32 fDiscID;
|
|
||||||
|
|
||||||
BString fArtist;
|
|
||||||
BString fAlbum;
|
|
||||||
BString fGenre;
|
|
||||||
|
|
||||||
BList fTrackList;
|
|
||||||
BList fTimeList;
|
|
||||||
|
|
||||||
CDAudioTime fDiscTime;
|
|
||||||
int32 fYear;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// based on Jukebox by Chip Paul
|
|
||||||
|
|
||||||
|
|
||||||
class CDDBQuery {
|
|
||||||
public:
|
|
||||||
CDDBQuery(const char *server, int32 port = 888);
|
|
||||||
~CDDBQuery();
|
|
||||||
void SetToSite(const char *server, int32 port);
|
|
||||||
status_t GetSites(bool (*)(const char *site, int port,
|
|
||||||
const char *latitude, const char *longitude,
|
|
||||||
const char *description, void *state), void *);
|
|
||||||
|
|
||||||
void SetToCD(const char *devicepath);
|
|
||||||
|
|
||||||
const char* GetArtist()
|
|
||||||
{
|
|
||||||
return fCDData.Artist();
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* GetAlbum()
|
|
||||||
{
|
|
||||||
return fCDData.Album();
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* GetGenre()
|
|
||||||
{
|
|
||||||
return fCDData.Genre();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GetData(CDDBData *data, bigtime_t timeout);
|
|
||||||
void SetData(const CDDBData &data);
|
|
||||||
|
|
||||||
bool Ready() const
|
|
||||||
{
|
|
||||||
return fState == kDone;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32 CurrentDiscID() const
|
|
||||||
{
|
|
||||||
return fCDData.DiscID();
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32 GetDiscID(const scsi_toc *);
|
|
||||||
static int32 GetTrackCount(const scsi_toc *);
|
|
||||||
static CDAudioTime GetDiscTime(const scsi_toc *);
|
|
||||||
static void GetTrackTimes(const scsi_toc *, vector<CDAudioTime> ×);
|
|
||||||
static BString OffsetsToString(const scsi_toc *);
|
|
||||||
|
|
||||||
private:
|
|
||||||
status_t _Connect();
|
|
||||||
void _Disconnect();
|
|
||||||
bool _IsConnected() const;
|
|
||||||
|
|
||||||
static int32 _QueryThread(void *);
|
|
||||||
|
|
||||||
// cached retrieved data
|
|
||||||
enum State {
|
|
||||||
kInitial,
|
|
||||||
kReading,
|
|
||||||
kDone,
|
|
||||||
kInterrupting,
|
|
||||||
kError
|
|
||||||
};
|
|
||||||
|
|
||||||
void _SetDefaultInfo();
|
|
||||||
status_t _OpenContentFile(const int32 &discID);
|
|
||||||
|
|
||||||
status_t _ReadFromServer(BString &data);
|
|
||||||
void _ParseData(const BString &data);
|
|
||||||
void _WriteFile();
|
|
||||||
|
|
||||||
void _ReadLine(BString &);
|
|
||||||
status_t _IdentifySelf();
|
|
||||||
|
|
||||||
const char* _GetToken(const char*, BString &);
|
|
||||||
|
|
||||||
// state data
|
|
||||||
BString fServerName;
|
|
||||||
BNetEndpoint fSocket;
|
|
||||||
int32 fPort;
|
|
||||||
bool fConnected;
|
|
||||||
|
|
||||||
thread_id fThread;
|
|
||||||
State fState;
|
|
||||||
status_t fResult;
|
|
||||||
|
|
||||||
// disc information
|
|
||||||
CDDBData fCDData;
|
|
||||||
BString fFrameOffsetString;
|
|
||||||
scsi_toc fSCSIData;
|
|
||||||
};
|
|
||||||
|
|
||||||
BString GetLineFromString(const char *string);
|
|
||||||
|
|
||||||
#endif // CDDBSUPPORT_H
|
|
|
@ -1,678 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2006-2009, Haiku, Inc. All Rights Reserved.
|
|
||||||
* Distributed under the terms of the MIT license.
|
|
||||||
*
|
|
||||||
* Author:
|
|
||||||
* DarkWyrm, bpmagic@columbus.rr.com
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "ButtonBitmaps.h"
|
|
||||||
#include "CDPlayer.h"
|
|
||||||
#include "DrawButton.h"
|
|
||||||
#include "DoubleShotDrawButton.h"
|
|
||||||
#include "TwoStateDrawButton.h"
|
|
||||||
|
|
||||||
#include <Alert.h>
|
|
||||||
#include <Application.h>
|
|
||||||
#include <Bitmap.h>
|
|
||||||
#include <BitmapStream.h>
|
|
||||||
#include <Box.h>
|
|
||||||
#include <Button.h>
|
|
||||||
#include <Catalog.h>
|
|
||||||
#include <Debug.h>
|
|
||||||
#include <Deskbar.h>
|
|
||||||
#include <Dragger.h>
|
|
||||||
#include <Entry.h>
|
|
||||||
#include <MenuItem.h>
|
|
||||||
#include <PopUpMenu.h>
|
|
||||||
#include <Roster.h>
|
|
||||||
#include <TranslatorFormats.h>
|
|
||||||
#include <TranslatorRoster.h>
|
|
||||||
#include <TranslationUtils.h>
|
|
||||||
#include <Window.h>
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#undef B_TRANSLATION_CONTEXT
|
|
||||||
#define B_TRANSLATION_CONTEXT "CDPlayer"
|
|
||||||
|
|
||||||
enum {
|
|
||||||
M_STOP = 'mstp',
|
|
||||||
M_PLAY,
|
|
||||||
M_NEXT_TRACK,
|
|
||||||
M_PREV_TRACK,
|
|
||||||
M_FFWD,
|
|
||||||
M_REWIND,
|
|
||||||
M_EJECT,
|
|
||||||
M_SAVE,
|
|
||||||
M_SHUFFLE,
|
|
||||||
M_REPEAT,
|
|
||||||
M_SET_VOLUME,
|
|
||||||
M_SET_CD_TITLE
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class CDPlayerWindow : public BWindow {
|
|
||||||
public:
|
|
||||||
CDPlayerWindow();
|
|
||||||
bool QuitRequested();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
inline void
|
|
||||||
SetLabel(BStringView *label, const char *text)
|
|
||||||
{
|
|
||||||
if (strcmp(label->Text(), text) != 0)
|
|
||||||
label->SetText(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
|
||||||
|
|
||||||
|
|
||||||
CDPlayer::CDPlayer(BRect frame, const char *name, uint32 resizeMask,
|
|
||||||
uint32 flags)
|
|
||||||
: BView(frame, name, resizeMask, flags | B_FRAME_EVENTS),
|
|
||||||
fCDQuery("freedb.freedb.org")
|
|
||||||
{
|
|
||||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
|
||||||
|
|
||||||
fVolume = 255;
|
|
||||||
|
|
||||||
BuildGUI();
|
|
||||||
|
|
||||||
if (fCDDrive.CountDrives() < 1) {
|
|
||||||
BAlert *alert = new BAlert("CDPlayer", B_TRANSLATE(
|
|
||||||
"It appears that there are no CD"
|
|
||||||
" drives on your computer or there is no system software to "
|
|
||||||
"support one. Sorry."), B_TRANSLATE("OK"));
|
|
||||||
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
|
|
||||||
alert->Go();
|
|
||||||
}
|
|
||||||
|
|
||||||
fWindowState = fCDDrive.GetState();
|
|
||||||
fVolumeSlider->SetValue(fCDDrive.GetVolume());
|
|
||||||
if (fVolumeSlider->Value() <= 2) {
|
|
||||||
fCDDrive.SetVolume(255);
|
|
||||||
fVolumeSlider->SetValue(255);
|
|
||||||
}
|
|
||||||
_WatchCDState();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CDPlayer::~CDPlayer()
|
|
||||||
{
|
|
||||||
fCDDrive.Stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
CDPlayer::InitCheck()
|
|
||||||
{
|
|
||||||
return fCDDrive.CountDrives() > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
CDPlayer::BuildGUI()
|
|
||||||
{
|
|
||||||
fStopColor.red = 80;
|
|
||||||
fStopColor.green = 164;
|
|
||||||
fStopColor.blue = 80;
|
|
||||||
fStopColor.alpha = 255;
|
|
||||||
|
|
||||||
fPlayColor.red = 40;
|
|
||||||
fPlayColor.green = 230;
|
|
||||||
fPlayColor.blue = 40;
|
|
||||||
fPlayColor.alpha = 255;
|
|
||||||
|
|
||||||
BRect r(Bounds().InsetByCopy(10, 10));
|
|
||||||
BBox *box = new BBox(r, "", B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
|
|
||||||
AddChild(box);
|
|
||||||
|
|
||||||
r = box->Bounds().InsetByCopy(10, 10);
|
|
||||||
r.bottom = 25;
|
|
||||||
|
|
||||||
float labelWidth, labelHeight;
|
|
||||||
fCDTitle = new BStringView(r, "CDTitle", B_TRANSLATE("CD drive is empty"),
|
|
||||||
B_FOLLOW_LEFT_RIGHT);
|
|
||||||
fCDTitle->GetPreferredSize(&labelWidth, &labelHeight);
|
|
||||||
fCDTitle->ResizeTo(r.Width(), labelHeight);
|
|
||||||
box->AddChild(fCDTitle);
|
|
||||||
|
|
||||||
r.bottom = r.top + labelHeight;
|
|
||||||
r.OffsetBy(0, r.Height() + 5);
|
|
||||||
|
|
||||||
fCurrentTrack = new BStringView(r, "TrackNumber",
|
|
||||||
"", B_FOLLOW_LEFT_RIGHT);
|
|
||||||
box->AddChild(fCurrentTrack);
|
|
||||||
|
|
||||||
r.OffsetBy(0, r.Height() + 5);
|
|
||||||
r.right = r.left + (r.Width() / 2);
|
|
||||||
fTrackTime = new BStringView(r, "TrackTime",
|
|
||||||
B_TRANSLATE("Track: 88:88 / 88:88"), B_FOLLOW_LEFT_RIGHT);
|
|
||||||
fTrackTime->ResizeToPreferred();
|
|
||||||
fTrackTime->SetText(B_TRANSLATE("Track: --:-- / --:--"));
|
|
||||||
box->AddChild(fTrackTime);
|
|
||||||
|
|
||||||
r.OffsetTo(fTrackTime->Frame().right + 5, r.top);
|
|
||||||
fDiscTime = new BStringView(r, "DiscTime",
|
|
||||||
B_TRANSLATE("Disc: 88:88 / 88:88"), B_FOLLOW_RIGHT);
|
|
||||||
fDiscTime->ResizeToPreferred();
|
|
||||||
fDiscTime->SetText(B_TRANSLATE("Disc: --:-- / --:--"));
|
|
||||||
box->AddChild(fDiscTime);
|
|
||||||
|
|
||||||
float maxWidth = max_c(fDiscTime->Frame().right, fCDTitle->Frame().right);
|
|
||||||
|
|
||||||
box->ResizeTo(maxWidth + 5, fDiscTime->Frame().bottom + 10);
|
|
||||||
|
|
||||||
fStop = new DrawButton(BRect(0, 0, 1, 1), "Stop",
|
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "stop_up"),
|
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "stop_down"),
|
|
||||||
new BMessage(M_STOP), B_FOLLOW_BOTTOM, B_WILL_DRAW);
|
|
||||||
fStop->ResizeToPreferred();
|
|
||||||
fStop->MoveTo(10, box->Frame().bottom + 15);
|
|
||||||
fStop->SetDisabled(BTranslationUtils::GetBitmap(B_PNG_FORMAT,
|
|
||||||
"stop_disabled"));
|
|
||||||
AddChild(fStop);
|
|
||||||
float stopTop = fStop->Frame().top;
|
|
||||||
|
|
||||||
|
|
||||||
fPlay = new TwoStateDrawButton(BRect(0, 0, 1, 1), "Play",
|
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "play_up"),
|
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "play_down"),
|
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "play_up_on"),
|
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "play_down"),
|
|
||||||
new BMessage(M_PLAY), B_FOLLOW_NONE, B_WILL_DRAW);
|
|
||||||
|
|
||||||
fPlay->ResizeToPreferred();
|
|
||||||
fPlay->MoveTo(fStop->Frame().right + 2, stopTop);
|
|
||||||
AddChild(fPlay);
|
|
||||||
|
|
||||||
fPrevTrack = new DrawButton(BRect(0, 0, 1, 1), "PrevTrack",
|
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "prev_up"),
|
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "prev_down"),
|
|
||||||
new BMessage(M_PREV_TRACK), 0, B_WILL_DRAW);
|
|
||||||
fPrevTrack->ResizeToPreferred();
|
|
||||||
fPrevTrack->MoveTo(fPlay->Frame().right + 40, stopTop);
|
|
||||||
AddChild(fPrevTrack);
|
|
||||||
|
|
||||||
fNextTrack = new DrawButton(BRect(0, 0, 1, 1), "NextTrack",
|
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "next_up"),
|
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "next_down"),
|
|
||||||
new BMessage(M_NEXT_TRACK), 0, B_WILL_DRAW);
|
|
||||||
fNextTrack->ResizeToPreferred();
|
|
||||||
fNextTrack->MoveTo(fPrevTrack->Frame().right + 1, stopTop);
|
|
||||||
AddChild(fNextTrack);
|
|
||||||
|
|
||||||
fRewind = new DoubleShotDrawButton(BRect(0, 0, 1, 1), "Rewind",
|
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "rew_up"),
|
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "rew_down"),
|
|
||||||
new BMessage(M_REWIND), 0, B_WILL_DRAW);
|
|
||||||
fRewind->ResizeToPreferred();
|
|
||||||
fRewind->MoveTo(fNextTrack->Frame().right + 40, stopTop);
|
|
||||||
AddChild(fRewind);
|
|
||||||
|
|
||||||
fFastFwd = new DoubleShotDrawButton(BRect(0, 0, 1, 1), "FastFwd",
|
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "ffwd_up"),
|
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "ffwd_down"),
|
|
||||||
new BMessage(M_FFWD), 0, B_WILL_DRAW);
|
|
||||||
fFastFwd->ResizeToPreferred();
|
|
||||||
fFastFwd->MoveTo(fRewind->Frame().right + 1, stopTop);
|
|
||||||
AddChild(fFastFwd);
|
|
||||||
|
|
||||||
r.left = 10;
|
|
||||||
r.right = fPlay->Frame().right;
|
|
||||||
r.top = fStop->Frame().bottom + 14;
|
|
||||||
r.bottom = r.top + 14;
|
|
||||||
fVolumeSlider = new VolumeSlider(r, "VolumeSlider",
|
|
||||||
0, 255, new BMessage(M_SET_VOLUME), this);
|
|
||||||
AddChild(fVolumeSlider);
|
|
||||||
|
|
||||||
fRepeat = new TwoStateDrawButton(BRect(0, 0, 1, 1), "Repeat",
|
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "repeat_up_off"),
|
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "repeat_down"),
|
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "repeat_up_on"),
|
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "repeat_down"),
|
|
||||||
new BMessage(M_REPEAT), B_FOLLOW_NONE, B_WILL_DRAW);
|
|
||||||
fRepeat->ResizeToPreferred();
|
|
||||||
fRepeat->MoveTo(fPrevTrack->Frame().left, fVolumeSlider->Frame().top -
|
|
||||||
((fRepeat->Frame().Height() - fVolumeSlider->Frame().Height()) / 2));
|
|
||||||
AddChild(fRepeat);
|
|
||||||
|
|
||||||
fShuffle = new TwoStateDrawButton(BRect(0, 0, 1, 1), "Shuffle",
|
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "shuffle_up_off"),
|
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "shuffle_down"),
|
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "shuffle_up_on"),
|
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "shuffle_down"),
|
|
||||||
new BMessage(M_SHUFFLE), B_FOLLOW_NONE, B_WILL_DRAW);
|
|
||||||
fShuffle->ResizeToPreferred();
|
|
||||||
fShuffle->MoveTo(fRepeat->Frame().right + 2, fRepeat->Frame().top);
|
|
||||||
AddChild(fShuffle);
|
|
||||||
|
|
||||||
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), 0, B_WILL_DRAW);
|
|
||||||
fEject->ResizeToPreferred();
|
|
||||||
fEject->MoveTo(fFastFwd->Frame().left, fShuffle->Frame().top);
|
|
||||||
AddChild(fEject);
|
|
||||||
|
|
||||||
ResizeTo(box->Frame().right + 10, fVolumeSlider->Frame().bottom + 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
CDPlayer::MessageReceived(BMessage *msg)
|
|
||||||
{
|
|
||||||
switch (msg->what) {
|
|
||||||
case M_SET_VOLUME:
|
|
||||||
fCDDrive.SetVolume(fVolumeSlider->Value());
|
|
||||||
break;
|
|
||||||
|
|
||||||
case M_STOP:
|
|
||||||
if (fWindowState == kPaused) {
|
|
||||||
fPlay->SetBitmaps(0, BTranslationUtils::GetBitmap(B_PNG_FORMAT,
|
|
||||||
"play_up"),
|
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "play_down"));
|
|
||||||
fPlay->SetState(1);
|
|
||||||
}
|
|
||||||
fWindowState = kStopped;
|
|
||||||
fCDDrive.Stop();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case M_PLAY:
|
|
||||||
// If we are currently playing, then we will be showing
|
|
||||||
// the pause images and will want to switch back to the play images
|
|
||||||
if (fWindowState == kPlaying) {
|
|
||||||
fWindowState = kPaused;
|
|
||||||
fCDDrive.Pause();
|
|
||||||
fPlay->SetBitmaps(0, BTranslationUtils::GetBitmap(B_PNG_FORMAT,
|
|
||||||
"paused_up"),
|
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "play_down"));
|
|
||||||
} else if (fWindowState == kPaused) {
|
|
||||||
fWindowState = kPlaying;
|
|
||||||
fCDDrive.Resume();
|
|
||||||
fPlay->SetBitmaps(0, BTranslationUtils::GetBitmap(B_PNG_FORMAT,
|
|
||||||
"play_up"),
|
|
||||||
BTranslationUtils::GetBitmap(B_PNG_FORMAT, "play_down"));
|
|
||||||
} else {
|
|
||||||
fWindowState = kPlaying;
|
|
||||||
fCDDrive.Play(fPlayList.GetCurrentTrack());
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case M_EJECT:
|
|
||||||
fCDDrive.Eject();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case M_NEXT_TRACK:
|
|
||||||
{
|
|
||||||
int16 next = fPlayList.GetNextTrack();
|
|
||||||
if (next <= 0) {
|
|
||||||
// force a "wrap around" when possible. This makes it
|
|
||||||
// possible for the user to be able to, for example, jump
|
|
||||||
// back to the first track from the last one with 1 button push
|
|
||||||
next = fPlayList.GetFirstTrack();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (next > 0) {
|
|
||||||
CDState state = fCDDrive.GetState();
|
|
||||||
if (state == kPlaying) {
|
|
||||||
while (!fCDDrive.Play(next)) {
|
|
||||||
next = fPlayList.GetNextTrack();
|
|
||||||
if (next < 1) {
|
|
||||||
fWindowState = kStopped;
|
|
||||||
fCDDrive.Stop();
|
|
||||||
fPlayList.Rewind();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (state == kPaused) {
|
|
||||||
fCDDrive.Play(next);
|
|
||||||
fCDDrive.Pause();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
fPlayList.SetCurrentTrack(next);
|
|
||||||
|
|
||||||
// Force an update for better responsiveness
|
|
||||||
_WatchCDState();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case M_PREV_TRACK:
|
|
||||||
{
|
|
||||||
int16 prev = fPlayList.GetPreviousTrack();
|
|
||||||
if (prev <= 0) {
|
|
||||||
// force a "wrap around" when possible. This makes it
|
|
||||||
// possible for the user to be able to, for example, jump
|
|
||||||
// back to the first track from the last one with 1 button push
|
|
||||||
prev = fPlayList.GetLastTrack();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (prev > 0) {
|
|
||||||
CDState state = fCDDrive.GetState();
|
|
||||||
if (state == kPlaying) {
|
|
||||||
while (!fCDDrive.Play(prev)) {
|
|
||||||
prev = fPlayList.GetPreviousTrack();
|
|
||||||
if (prev < 1) {
|
|
||||||
fWindowState = kStopped;
|
|
||||||
fCDDrive.Stop();
|
|
||||||
fPlayList.Rewind();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (state == kPaused) {
|
|
||||||
fCDDrive.Play(prev);
|
|
||||||
fCDDrive.Pause();
|
|
||||||
} else
|
|
||||||
fPlayList.SetCurrentTrack(prev);
|
|
||||||
|
|
||||||
// Force an update for better responsiveness
|
|
||||||
_WatchCDState();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case M_FFWD:
|
|
||||||
if (fFastFwd->Value() == B_CONTROL_ON)
|
|
||||||
fCDDrive.StartFastFwd();
|
|
||||||
else
|
|
||||||
fCDDrive.StopFastFwd();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case M_REWIND:
|
|
||||||
if (fRewind->Value() == B_CONTROL_ON)
|
|
||||||
fCDDrive.StartRewind();
|
|
||||||
else
|
|
||||||
fCDDrive.StopRewind();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case M_SHUFFLE:
|
|
||||||
if (fPlayList.IsShuffled()) {
|
|
||||||
int16 track = fPlayList.GetCurrentTrack();
|
|
||||||
fPlayList.SetShuffle(false);
|
|
||||||
fPlayList.SetStartingTrack(track);
|
|
||||||
fPlayList.SetTrackCount(fCDDrive.CountTracks());
|
|
||||||
fShuffle->SetState(0);
|
|
||||||
} else {
|
|
||||||
fPlayList.SetTrackCount(fCDDrive.CountTracks());
|
|
||||||
fPlayList.SetShuffle(true);
|
|
||||||
fShuffle->SetState(1);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case M_REPEAT:
|
|
||||||
if (fPlayList.IsLoop()) {
|
|
||||||
fPlayList.SetLoop(false);
|
|
||||||
fRepeat->SetState(0);
|
|
||||||
} else {
|
|
||||||
fPlayList.SetLoop(true);
|
|
||||||
fRepeat->SetState(1);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
BView::MessageReceived(msg);
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
CDPlayer::AttachedToWindow()
|
|
||||||
{
|
|
||||||
fStop->SetTarget(this);
|
|
||||||
fPlay->SetTarget(this);
|
|
||||||
fNextTrack->SetTarget(this);
|
|
||||||
fPrevTrack->SetTarget(this);
|
|
||||||
fFastFwd->SetTarget(this);
|
|
||||||
fRewind->SetTarget(this);
|
|
||||||
fEject->SetTarget(this);
|
|
||||||
fShuffle->SetTarget(this);
|
|
||||||
fRepeat->SetTarget(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
CDPlayer::Pulse()
|
|
||||||
{
|
|
||||||
_WatchCDState();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
CDPlayer::_WatchCDState()
|
|
||||||
{
|
|
||||||
// One watcher function to rule them all
|
|
||||||
|
|
||||||
// first, watch the one setting independent of having a CD: volume
|
|
||||||
uint8 driveVolume = fCDDrive.GetVolume();
|
|
||||||
if (fVolume == driveVolume) {
|
|
||||||
fVolume = driveVolume;
|
|
||||||
fVolumeSlider->SetValue(fVolume);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Second, establish whether or not we have a CD in the drive
|
|
||||||
CDState playState = fCDDrive.GetState();
|
|
||||||
bool internalTrackChange = false;
|
|
||||||
|
|
||||||
if (playState == kNoCD) {
|
|
||||||
// Yes, we have no bananas!
|
|
||||||
|
|
||||||
// Do something only if there is a change in the app's play state
|
|
||||||
if (fWindowState != kNoCD) {
|
|
||||||
// We have just discovered that we have no bananas
|
|
||||||
fWindowState = kNoCD;
|
|
||||||
|
|
||||||
// Because we are changing play states, we will need to update
|
|
||||||
// the GUI
|
|
||||||
fCDData.SetDiscID(-1);
|
|
||||||
SetLabel(fCDTitle, B_TRANSLATE("CD drive is empty"));
|
|
||||||
|
|
||||||
SetLabel(fCurrentTrack, "");
|
|
||||||
SetLabel(fTrackTime, B_TRANSLATE("Track: --:-- / --:--"));
|
|
||||||
SetLabel(fDiscTime, B_TRANSLATE("Disc: --:-- / --:--"));
|
|
||||||
fPlayList.SetTrackCount(0);
|
|
||||||
fPlayList.SetStartingTrack(1);
|
|
||||||
fPlayList.SetCurrentTrack(1);
|
|
||||||
|
|
||||||
if (fPlay->GetState() == 1)
|
|
||||||
fPlay->SetState(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now otherwise handle the play state
|
|
||||||
if (playState == kStopped) {
|
|
||||||
if (fWindowState == kPlaying) {
|
|
||||||
internalTrackChange = true;
|
|
||||||
|
|
||||||
// This means that the drive finished playing the song, so get
|
|
||||||
// the next one from the list and play it
|
|
||||||
int16 next = fPlayList.GetNextTrack();
|
|
||||||
if (next > 0)
|
|
||||||
fCDDrive.Play(next);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fPlay->GetState() == 1)
|
|
||||||
fPlay->SetState(0);
|
|
||||||
} else if (playState == kPlaying) {
|
|
||||||
if (fPlay->GetState() == 0)
|
|
||||||
fPlay->SetState(1);
|
|
||||||
} else if (playState == kPaused)
|
|
||||||
fPlay->SetState(0);
|
|
||||||
|
|
||||||
// If we got this far, then there must be a CD in the drive. The next order
|
|
||||||
// on the agenda is to find out which CD it is
|
|
||||||
int32 discId = fCDDrive.GetDiscID();
|
|
||||||
bool updateTrackGui = false;
|
|
||||||
|
|
||||||
if (discId != fCDData.DiscID()) {
|
|
||||||
updateTrackGui = true;
|
|
||||||
|
|
||||||
// Apparently the disc has changed since we last looked.
|
|
||||||
if (fCDQuery.CurrentDiscID() != discId)
|
|
||||||
fCDQuery.SetToCD(fCDDrive.GetDrivePath());
|
|
||||||
|
|
||||||
if (fCDQuery.Ready()) {
|
|
||||||
// Note that we only update the CD title for now. We still need a
|
|
||||||
// track number in order to update the display for the selected track
|
|
||||||
if (fCDQuery.GetData(&fCDData, 1000000)) {
|
|
||||||
BString display(fCDData.Artist());
|
|
||||||
display << " - " << fCDData.Album();
|
|
||||||
SetLabel(fCDTitle, display.String());
|
|
||||||
} else
|
|
||||||
SetLabel(fCDTitle, B_TRANSLATE("Audio CD"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now that we know which CD it is, update the track info
|
|
||||||
int16 driveCount = fCDDrive.CountTracks();
|
|
||||||
int16 driveTrack = fCDDrive.GetTrack();
|
|
||||||
|
|
||||||
int16 playlistTrack = fPlayList.GetCurrentTrack();
|
|
||||||
int16 playlistCount = fPlayList.TrackCount();
|
|
||||||
|
|
||||||
if (playState == kPlaying) {
|
|
||||||
if (playlistTrack != driveTrack) {
|
|
||||||
playlistTrack = driveTrack;
|
|
||||||
|
|
||||||
if (!internalTrackChange) {
|
|
||||||
// The main thing is that we need to make sure that the
|
|
||||||
// playlist and the drive's track stay in sync. The CD's
|
|
||||||
// track may have been changed by an outside source, so if
|
|
||||||
// the drive is playing, check for playlist sync.
|
|
||||||
fPlayList.SetTrackCount(driveCount);
|
|
||||||
fPlayList.SetCurrentTrack(driveTrack);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
updateTrackGui = true;
|
|
||||||
} else {
|
|
||||||
if (playlistCount != driveCount) {
|
|
||||||
// This happens only when CDs are changed
|
|
||||||
if (driveCount < 0) {
|
|
||||||
// There is no CD in the drive. The playlist needs to have its
|
|
||||||
// track count set to 0 and it also needs to be rewound.
|
|
||||||
fPlayList.SetStartingTrack(1);
|
|
||||||
fPlayList.SetTrackCount(0);
|
|
||||||
playlistTrack = 1;
|
|
||||||
playlistCount = 0;
|
|
||||||
} else {
|
|
||||||
// Two possible cases here: playlist is empty or playlist has a
|
|
||||||
// different number of tracks. In either case, the playlist
|
|
||||||
// needs to be reinitialized to the current track data
|
|
||||||
fPlayList.SetStartingTrack(1);
|
|
||||||
fPlayList.SetTrackCount(driveCount);
|
|
||||||
playlistTrack = fPlayList.GetCurrentTrack();
|
|
||||||
playlistCount = driveCount;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// update only with a track change
|
|
||||||
if (playlistTrack != driveTrack)
|
|
||||||
updateTrackGui = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (updateTrackGui) {
|
|
||||||
BString currentTrackName(B_TRANSLATE("Track %whichTrack%: %trackAt%"));
|
|
||||||
|
|
||||||
if (playlistTrack >= 0) {
|
|
||||||
int16 whichTrack = playlistTrack;
|
|
||||||
|
|
||||||
if (whichTrack == 0)
|
|
||||||
whichTrack++;
|
|
||||||
|
|
||||||
BString stringTrack;
|
|
||||||
stringTrack << whichTrack;
|
|
||||||
|
|
||||||
BString stringTrackAt;
|
|
||||||
stringTrack << fCDData.TrackAt(whichTrack - 1);
|
|
||||||
|
|
||||||
currentTrackName.ReplaceFirst("%whichTrack%", stringTrack);
|
|
||||||
currentTrackName.ReplaceFirst("%trackAt%", stringTrackAt);
|
|
||||||
|
|
||||||
SetLabel(fCurrentTrack, currentTrackName.String());
|
|
||||||
|
|
||||||
} else
|
|
||||||
SetLabel(fCurrentTrack, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now update the time info
|
|
||||||
CDAudioTime trackTime;
|
|
||||||
CDAudioTime discTime;
|
|
||||||
CDAudioTime trackTotal;
|
|
||||||
CDAudioTime discTotal;
|
|
||||||
char timeString[1024];
|
|
||||||
|
|
||||||
if (fCDDrive.GetTime(trackTime, discTime)) {
|
|
||||||
fCDDrive.GetTimeForDisc(discTotal);
|
|
||||||
sprintf(timeString, B_TRANSLATE("Disc: %ld:%.2ld / %ld:%.2ld"),
|
|
||||||
discTime.GetMinutes(), discTime.GetSeconds(),
|
|
||||||
discTotal.GetMinutes(), discTotal.GetSeconds());
|
|
||||||
SetLabel(fDiscTime, timeString);
|
|
||||||
|
|
||||||
fCDDrive.GetTimeForTrack(playlistTrack, trackTotal);
|
|
||||||
sprintf(timeString, B_TRANSLATE("Track: %ld:%.2ld / %ld:%.2ld"),
|
|
||||||
trackTime.GetMinutes(), trackTime.GetSeconds(),
|
|
||||||
trackTotal.GetMinutes(), trackTotal.GetSeconds());
|
|
||||||
SetLabel(fTrackTime, timeString);
|
|
||||||
} else {
|
|
||||||
SetLabel(fTrackTime, B_TRANSLATE("Track: --:-- / --:--"));
|
|
||||||
SetLabel(fDiscTime, B_TRANSLATE("Disc: --:-- / --:--"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
|
||||||
|
|
||||||
|
|
||||||
CDPlayerWindow::CDPlayerWindow()
|
|
||||||
:
|
|
||||||
BWindow(BRect (100, 100, 405, 280), B_TRANSLATE_SYSTEM_NAME("CDPlayer"),
|
|
||||||
B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE
|
|
||||||
| B_ASYNCHRONOUS_CONTROLS)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
CDPlayerWindow::QuitRequested()
|
|
||||||
{
|
|
||||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
|
||||||
|
|
||||||
|
|
||||||
CDPlayerApplication::CDPlayerApplication()
|
|
||||||
: BApplication("application/x-vnd.Haiku-CDPlayer")
|
|
||||||
{
|
|
||||||
BWindow *window = new CDPlayerWindow();
|
|
||||||
CDPlayer *view = new CDPlayer(window->Bounds(), B_TRANSLATE("CD"));
|
|
||||||
if (view->InitCheck()) {
|
|
||||||
window->ResizeTo(view->Bounds().Width(), view->Bounds().Height());
|
|
||||||
window->AddChild(view);
|
|
||||||
window->Show();
|
|
||||||
} else
|
|
||||||
PostMessage(B_QUIT_REQUESTED);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
main(int, char **argv)
|
|
||||||
{
|
|
||||||
CDPlayerApplication app;
|
|
||||||
app.Run();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,89 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 1999, Be Incorporated. All Rights Reserved.
|
|
||||||
This file may be used under the terms of the Be Sample Code License.
|
|
||||||
*/
|
|
||||||
// This defines the replicant button
|
|
||||||
|
|
||||||
#ifndef CDPLAYER_H
|
|
||||||
#define CDPLAYER_H
|
|
||||||
|
|
||||||
#include "CDAudioDevice.h"
|
|
||||||
#include "CDDBSupport.h"
|
|
||||||
#include "PlayList.h"
|
|
||||||
#include "VolumeSlider.h"
|
|
||||||
|
|
||||||
#include <Application.h>
|
|
||||||
#include <Box.h>
|
|
||||||
#include <Button.h>
|
|
||||||
#include <StringView.h>
|
|
||||||
#include <TextControl.h>
|
|
||||||
#include <View.h>
|
|
||||||
#include <Window.h>
|
|
||||||
|
|
||||||
|
|
||||||
class DrawButton;
|
|
||||||
class DoubleShotDrawButton;
|
|
||||||
class TwoStateDrawButton;
|
|
||||||
|
|
||||||
|
|
||||||
class CDPlayer : public BView {
|
|
||||||
public:
|
|
||||||
CDPlayer(BRect frame, const char *name, uint32 resizeMask = B_FOLLOW_ALL,
|
|
||||||
uint32 flags = B_WILL_DRAW | B_NAVIGABLE | B_PULSE_NEEDED);
|
|
||||||
virtual ~CDPlayer();
|
|
||||||
|
|
||||||
void BuildGUI();
|
|
||||||
bool InitCheck();
|
|
||||||
|
|
||||||
virtual void AttachedToWindow();
|
|
||||||
virtual void Pulse();
|
|
||||||
virtual void MessageReceived(BMessage *);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void _WatchCDState();
|
|
||||||
|
|
||||||
DrawButton *fStop,
|
|
||||||
*fNextTrack,
|
|
||||||
*fPrevTrack,
|
|
||||||
*fEject;
|
|
||||||
|
|
||||||
DoubleShotDrawButton
|
|
||||||
*fFastFwd,
|
|
||||||
*fRewind;
|
|
||||||
|
|
||||||
TwoStateDrawButton *fShuffle,
|
|
||||||
*fRepeat,
|
|
||||||
*fPlay;
|
|
||||||
|
|
||||||
VolumeSlider *fVolumeSlider;
|
|
||||||
|
|
||||||
BStringView *fCDTitle,
|
|
||||||
*fCurrentTrack,
|
|
||||||
*fTrackTime,
|
|
||||||
*fDiscTime;
|
|
||||||
|
|
||||||
BBox *fCDBox,
|
|
||||||
*fTrackBox,
|
|
||||||
*fTimeBox;
|
|
||||||
|
|
||||||
CDState fCDState;
|
|
||||||
|
|
||||||
rgb_color fStopColor;
|
|
||||||
rgb_color fPlayColor;
|
|
||||||
|
|
||||||
CDAudioDevice fCDDrive;
|
|
||||||
PlayList fPlayList;
|
|
||||||
CDState fWindowState;
|
|
||||||
CDDBQuery fCDQuery;
|
|
||||||
CDDBData fCDData;
|
|
||||||
uint8 fVolume;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class CDPlayerApplication : public BApplication {
|
|
||||||
public:
|
|
||||||
CDPlayerApplication();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif // CDPLAYER_H
|
|
|
@ -1,407 +0,0 @@
|
||||||
resource app_signature "application/x-vnd.Haiku-CDPlayer";
|
|
||||||
|
|
||||||
resource app_name_catalog_entry "x-vnd.Haiku-CDPlayer:System name:CDPlayer";
|
|
||||||
|
|
||||||
resource app_flags B_SINGLE_LAUNCH;
|
|
||||||
|
|
||||||
resource app_version {
|
|
||||||
major = 1,
|
|
||||||
middle = 0,
|
|
||||||
minor = 0,
|
|
||||||
|
|
||||||
/* 0 = development 1 = alpha 2 = beta
|
|
||||||
3 = gamma 4 = golden master 5 = final */
|
|
||||||
variety = 2,
|
|
||||||
|
|
||||||
internal = 0,
|
|
||||||
|
|
||||||
short_info = "CDPlayer",
|
|
||||||
long_info = "CDPlayer ©2005-2009 Haiku, Inc."
|
|
||||||
};
|
|
||||||
|
|
||||||
resource vector_icon {
|
|
||||||
$"6E6369660F050004006A02000602AD28AB3B838DBC3FFCAE05CB4B2E7848A224"
|
|
||||||
$"00FF5E06FFFF9806020006023C60000000000000004000004AD00000000000FF"
|
|
||||||
$"7200FFFF980002000602B78719BB8D143DE1CFB9DB454A835A491AE900DD6311"
|
|
||||||
$"FEFF9F59020006023A98E5BA20E63A20E63A98E54A99374A20B800FFD600FFD7"
|
|
||||||
$"4F0502000604B8123C00000000000038123C4A9CEB4A564700CBCBFF54CBFFCB"
|
|
||||||
$"AACBFF33FFFFCB6603FFA200020006023B77D73A60C0BAD3D43C0FD7487A314A"
|
|
||||||
$"859D00FFDD59FFFFCB00020006023C8000000000000000400000484000000000"
|
|
||||||
$"00FEFFACFFFFEA3E03005C00038EB68E02030605B63D2FBC2D3D3C1BD3B62B46"
|
|
||||||
$"4A1AE649E3B100F1F1F136D9DDF48A9996B9B4B8BEDBFFF4F4F403C9A5880200"
|
|
||||||
$"06023C92C0388F5FB854503C576348D8DF48895B004137A9FFB9B9B9110A065C"
|
|
||||||
$"42415E485E574E604E5E430A0D552A372236233E35294426422246224E3E5C42"
|
|
||||||
$"5C5A445A405B3F0A043E355A40465328450A0446585A445A404653020442364A"
|
|
||||||
$"363A363240323A3246424A3A4A4A4A52405246523A0204423D443D403D3F3F3F"
|
|
||||||
$"3E3F40424140414441453F4540453E0204483F483D4841424346433E433C3F3C"
|
|
||||||
$"413C3D423B3E3B463B0A043E543E5C425C42540A0446504254425C46580A0422"
|
|
||||||
$"483E543E5C224E0A062642224622483E54425446500A06264246504653475247"
|
|
||||||
$"4F26400A04552A542B5A405B3F0A043623542B552A37220A043E355A40542B36"
|
|
||||||
$"230A06304931C323B64FC19EB524C2C92648B64FC2040A043049B649C20A2648"
|
|
||||||
$"2E4B120A010100000A0001011001178400040A050102000A030103000A04010C"
|
|
||||||
$"000A08010D000A02010E000A000204051001178400040A0C020604000A0D0205"
|
|
||||||
$"06000A0E01061001178200040A070107000A030108000A080109000A09010A00"
|
|
||||||
$"0A00010B000A0A010F0815FF0A0B011000"
|
|
||||||
};
|
|
||||||
|
|
||||||
resource(1, "stop_down") #'PNG ' array {
|
|
||||||
$"89504E470D0A1A0A0000000D494844520000001C00000015080300000062DC7E"
|
|
||||||
$"6E0000000467414D410000AFC837058AE90000001974455874536F6674776172"
|
|
||||||
$"650041646F626520496D616765526561647971C9653C00000021504C54451818"
|
|
||||||
$"18BFBFBFCECBCE101010848284000000E7E7E76361637B7D7B2124216365639D"
|
|
||||||
$"66D1620000008E4944415478DA6260C203000288818985031760010820A02403"
|
|
||||||
$"330EC0021040404966561C80052080C0920CD8010B4000E19504082024494618"
|
|
||||||
$"804B0204105E498000C22B0910407825010208AF244000E195040820BC920001"
|
|
||||||
$"8457122080F04A020410DE10020820BC920001049264E0C40E5800020828C9C9"
|
|
||||||
$"8503B000041050921D27000820062636DC0020C0004B4D065C99EE4871000000"
|
|
||||||
$"0049454E44AE426082"
|
|
||||||
};
|
|
||||||
|
|
||||||
resource(2, "stop_up") #'PNG ' array {
|
|
||||||
$"89504E470D0A1A0A0000000D494844520000001C00000015080300000062DC7E"
|
|
||||||
$"6E0000000467414D410000AFC837058AE90000001974455874536F6674776172"
|
|
||||||
$"650041646F626520496D616765526561647971C9653C0000001B504C54459C9A"
|
|
||||||
$"9CDEDBDE636163EFEFEFCECBCE848284404040FFFFFFE7E7E724E86FE5000000"
|
|
||||||
$"8C4944415478DA6260C10300028881851537000820A02407330EC00A10404049"
|
|
||||||
$"66761C80152080C0921CD8012B4000E19504082024493618804B0204105E4980"
|
|
||||||
$"00C22B0910407825010208AF244000E195040820BC9200018457122080F04A02"
|
|
||||||
$"0410DE10020820BC9200010492E460C40E5801020828C9C88003B00204105092"
|
|
||||||
$"092700082006160EDC0020C00066DB0D59EF1DF8F60000000049454E44AE4260"
|
|
||||||
$"82"
|
|
||||||
};
|
|
||||||
|
|
||||||
resource(3, "shuffle_up_on") #'PNG ' array {
|
|
||||||
$"89504E470D0A1A0A0000000D494844520000003A000000150803000000209F0D"
|
|
||||||
$"F90000000467414D410000AFC837058AE90000001974455874536F6674776172"
|
|
||||||
$"650041646F626520496D616765526561647971C9653C000000DE504C54456D6D"
|
|
||||||
$"6DDCDCDCC6C6C6D1D1D15656566161614B4B4BAFAFAFA4A4A48E8E8E69BA59E9"
|
|
||||||
$"E9E9E8E8E86CBB5CD8D8D886C87AE3E3E33F7035EBEBEB4F6A4BA7C7A1979797"
|
|
||||||
$"577452D2D2D2579A4A91BD87C3C3C3727D7042753894CE89838383B2B2B2DEDE"
|
|
||||||
$"DEECECEC85BF7885C77884BE788AA385EAEAEA9D9D9D9A9A9A559748F0F0F0AD"
|
|
||||||
$"C1A97D8B7A62AE53CCD8CA597753A8A8A892B38BE4E7E3788A74EBECEBD9D9D9"
|
|
||||||
$"529045B7B9B7BCBCBC8DA788C2CEC0EDEDED599E4B8C8C8CAAD8A1404040BABA"
|
|
||||||
$"BADEDBDE9C9A9CEFEFEF636163848284CECBCE999999FFFFFFE7E7E7FF841062"
|
|
||||||
$"0000019D4944415478DA6270231B000410839B2B99C0132080805A3D9DC9008E"
|
|
||||||
$"2E9E000104D4EAEC413AF07472F1040820B0564F928123502B400051A0152080"
|
|
||||||
$"30B5323A38307A3231200BB933B8833007278A5680008269E593175597520032"
|
|
||||||
$"98D95859183C1DEC917432D9B3B383B03B038A568000826A15B795B634543537"
|
|
||||||
$"05DAC002D40ED4CAE8C0ECE909B29FD9D3DDDE81118C815A99814250AD000104"
|
|
||||||
$"D56AA06327CBAFACC227E0C96ECF099474B067616563F6B477F004BA95D59E81"
|
|
||||||
$"0984815A39D840C210AD000104D5AA21C9CFC5C56BA60714656761E3006AE500"
|
|
||||||
$"E9836805B91E84815A59381D58DCA15A010208AAD54289978B4B57C68A1B144E"
|
|
||||||
$"9CF64C2095D8B4DAB332307040B50204102C9844346D2404C54CB881FEF464B4"
|
|
||||||
$"77806B656243B5550E114C000104D5CAC3ADAD2F6C6CA40894B7676083843050"
|
|
||||||
$"2B2B0B0BAA56763656569883010208662B8F9AB596B310382A1C9840910B0E5E"
|
|
||||||
$"6030034318C4016166B08403CC568000A22035010410055A010208A4D5D39174"
|
|
||||||
$"00D40A104040AD8E4E640057174F8000026A75210F78020410839B27B90020C0"
|
|
||||||
$"0028E229A6998C9D9D0000000049454E44AE426082"
|
|
||||||
};
|
|
||||||
|
|
||||||
resource(4, "shuffle_up_off") #'PNG ' array {
|
|
||||||
$"89504E470D0A1A0A0000000D494844520000003A000000150803000000209F0D"
|
|
||||||
$"F90000000467414D410000AFC837058AE90000001974455874536F6674776172"
|
|
||||||
$"650041646F626520496D616765526561647971C9653C000000D5504C54456D6D"
|
|
||||||
$"6DDCDCDCC6C6C6D1D1D16161614B4B4B565656AFAFAFA4A4A48E8E8EC4C4C4EB"
|
|
||||||
$"EBEBE9E9E9D5D5D5CACACAC5C5C5D0D0D09DA19C757874E5E7E4C6CFC5A2A2A2"
|
|
||||||
$"DDDDDD8A9288939593ECECECF2F2F2B8B8B86B706AABB0AAEFF0EFBABFB97B7B"
|
|
||||||
$"7BCBCBCBBBC2BA989898F5F5F59F9F9FF0F0F0A7B9A4838383686C67CFCFCF67"
|
|
||||||
$"6767BFBFBF595C58A6B0A48A8A8A7A7A7A5D605DDFDFDF6B6B6B767676636363"
|
|
||||||
$"BCC3BB555555656964A6A6A6F4F4F4ADBBAA404040BABABADEDBDE9C9A9CEFEF"
|
|
||||||
$"EF636163848284CECBCE999999FFFFFFE7E7E7D832BDA00000019D4944415478"
|
|
||||||
$"DA6270261B00041083B31399C00D2080805ADD1CC800768E6E000104D4EAE04A"
|
|
||||||
$"3A70B37774030820B0563792811D502B400051A015208030B532DADA32BA3131"
|
|
||||||
$"200BB930B8803007278A5680008269E5D33735E6E00532985959D818DC6C6D90"
|
|
||||||
$"7432D9B0B383B00B038A568000826AD531D7159415975004DAC006D40ED4CA68"
|
|
||||||
$"CBECE606B29FD9CDC5C696118C815A99814250AD000104D56A2023C62BA065CD"
|
|
||||||
$"67E4C66EC30994B4B56163616576B3B17503BA95C586810984815A395841C210"
|
|
||||||
$"AD000104D5AA2D2FC0C5C5AF2C0214656763E5006AE500E9836805B91E84815A"
|
|
||||||
$"D9386DD95CA05A010208AAD5C58C9F8B4B5A41891B144E9C364C2095D8B4DAB0"
|
|
||||||
$"30307040B50204102C98D4552D454D2CE4B881FE7463B4B1856B656245B55503"
|
|
||||||
$"114C000104D5CAC3ADA7692824AC0694B76160858430502B0B1B1BAA56765616"
|
|
||||||
$"169883010208662B8FA4948A9503382A6C9940910B0E5E6030034318C4016166"
|
|
||||||
$"B0842DCC568000A22035010410055A010208A4D5CD8E7400D40A104040AD76F6"
|
|
||||||
$"64002747378000026A75240FB801041083B31BB90020C0003F2F1CF1AA88B47B"
|
|
||||||
$"0000000049454E44AE426082"
|
|
||||||
};
|
|
||||||
|
|
||||||
resource(5, "shuffle_down") #'PNG ' array {
|
|
||||||
$"89504E470D0A1A0A0000000D494844520000003A000000150803000000209F0D"
|
|
||||||
$"F90000000467414D410000AFC837058AE90000001974455874536F6674776172"
|
|
||||||
$"650041646F626520496D616765526561647971C9653C000000E4504C54451818"
|
|
||||||
$"18CECBCEE7E7E7848284636163101010636563212421000000454545BFBFBF66"
|
|
||||||
$"66669292922323233939392E2E2EA9A9A99E9E9EB4B4B45050505B5B5B717171"
|
|
||||||
$"9645A61616167937852727279344A31717177C7C7C1212126E42781414148274"
|
|
||||||
$"857A388787758B212121A661B4AA68B7725877686868262626BD8AC7B095B448"
|
|
||||||
$"4648523E564343431515158D828F6D4C746565659D51ACC08FCA332735A688AC"
|
|
||||||
$"141314AD6FBAA88BAD7A4087755C7A5757573C3C3C6262626B31767B41871313"
|
|
||||||
$"131B181C3D313F55275E7373732D2D2D7B7D7B4D4D4D0F0F0FA865B51C1C1C58"
|
|
||||||
$"385E209137060000019D4944415478DA6260241B000410032333998009208080"
|
|
||||||
$"5A1958C900EC2C4C000104D4CACA413A60606361020820B0560692013B502B40"
|
|
||||||
$"0051A015208030B5F27272F232F0F1200B71F37083B088288A56800082699574"
|
|
||||||
$"57B7B5510632F8850405781838B99074F271090B8330370F8A568000826A7575"
|
|
||||||
$"D15733B0D2D600DA2000D40ED4CACBC9CFC000B29F9F819B8B93178C815AF981"
|
|
||||||
$"4250AD000104D56AADE06C27A1682FE9C520CC250A94E4E4121014E267E0E264"
|
|
||||||
$"00BA55908B870F84815A458440C210AD000104D56A2827212626656E02141516"
|
|
||||||
$"1012016A1501E9836805B91E84815A05443905B8A15A010208AA55D7524A4CCC"
|
|
||||||
$"48D3491C144EA25C7C2095D8B47209F2F08840B50204102C98BC55553C8D2DCC"
|
|
||||||
$"C481FE64E0E5E2846BE51342B55506114C000104D52A2DAE63AAA5E4E80094E7"
|
|
||||||
$"E21182843050ABA08000AA5661214141988301020866ABB49EAC07AB3C382A38"
|
|
||||||
$"F940910B0E5E6030034318C401617EB00427CC568000A22035010410055A0102"
|
|
||||||
$"08A495819D7400D40A104040ADEC6C64003716268000026A65210F3001041003"
|
|
||||||
$"2313B90020C000992E1E6DC556B8640000000049454E44AE426082"
|
|
||||||
};
|
|
||||||
|
|
||||||
resource(6, "rew_down") #'PNG ' array {
|
|
||||||
$"89504E470D0A1A0A0000000D4948445200000023000000150803000000FB24A7"
|
|
||||||
$"DB0000000467414D410000AFC837058AE90000001974455874536F6674776172"
|
|
||||||
$"650041646F626520496D616765526561647971C9653C00000024504C54451818"
|
|
||||||
$"18BFBFBFCECBCE848284101010000000E7E7E76361632124216365637B7D7B1C"
|
|
||||||
$"1C1CBC1DBBD0000000B24944415478DA6260220C00028881899920000820A01A"
|
|
||||||
$"0616FC800B2080806A5858F1032E800002AB61C00BB80002881835000184AE86"
|
|
||||||
$"911183C5051040A86A1819613208160317400021AB616484C920582035000184"
|
|
||||||
$"50C3C8089341B0206A000208A686110B80A901082062CC010820B81A6EB82BB8"
|
|
||||||
$"D1DD031040C4F80B208088091F800022269C010288183500010452C3C0811770"
|
|
||||||
$"010410500D07277EC00510404035EC840040003130B1110400010600A1E40785"
|
|
||||||
$"A9210D8B0000000049454E44AE426082"
|
|
||||||
};
|
|
||||||
|
|
||||||
resource(7, "rew_up") #'PNG ' array {
|
|
||||||
$"89504E470D0A1A0A0000000D4948445200000023000000150803000000FB24A7"
|
|
||||||
$"DB0000000467414D410000AFC837058AE90000001974455874536F6674776172"
|
|
||||||
$"650041646F626520496D616765526561647971C9653C0000001E504C5445E3E3"
|
|
||||||
$"E39C9A9CDEDBDE636163EFEFEFCECBCE848284404040FFFFFFE7E7E7E071FC71"
|
|
||||||
$"000000B24944415478DA6260250C00028881958D20000820A01A4E16FC800D20"
|
|
||||||
$"80806A5838F00336800002ABE1C40BD80002881835000184AE869D1D83C50610"
|
|
||||||
$"40A86AD8D961320816271B400021AB616787C92058203500018450C3CE0E9341"
|
|
||||||
$"B0206A000208A6861D0B80A901082062CC010820B81A06B82B18D0DD031040C4"
|
|
||||||
$"F80B208088091F800022269C010288183500010452C3C98417B0010410500D13"
|
|
||||||
$"237EC00610404035CC8400400031B072120400010600E9AA13AA1F2D6E440000"
|
|
||||||
$"000049454E44AE426082"
|
|
||||||
};
|
|
||||||
|
|
||||||
resource(8, "prev_down") #'PNG ' array {
|
|
||||||
$"89504E470D0A1A0A0000000D494844520000001F00000015080300000089EBC5"
|
|
||||||
$"6D0000000467414D410000AFC837058AE90000001974455874536F6674776172"
|
|
||||||
$"650041646F626520496D616765526561647971C9653C00000021504C54451818"
|
|
||||||
$"18BFBFBF848284CECBCE101010000000E7E7E76361636365632124211C1C1C7E"
|
|
||||||
$"A8A44E000000A34944415478DA6260C60F0002888199092F000820A03C030B6E"
|
|
||||||
$"C004104040791656DC80092080C0F20C38011340001192070820247946464698"
|
|
||||||
$"309CC5041040D8E419112A99000208539E9111591E2080D0E5191951E5010208"
|
|
||||||
$"551E0160F2000144483F4000A1C973A1DB0F104084DC0F104084FC0F104084C2"
|
|
||||||
$"0F208008C9030410489E81132760020820A03C27076EC00410404079767C0020"
|
|
||||||
$"801898D9F002800003004041062DA94CAAB70000000049454E44AE426082"
|
|
||||||
};
|
|
||||||
|
|
||||||
resource(9, "prev_up") #'PNG ' array {
|
|
||||||
$"89504E470D0A1A0A0000000D494844520000001F00000015080300000089EBC5"
|
|
||||||
$"6D0000000467414D410000AFC837058AE90000001974455874536F6674776172"
|
|
||||||
$"650041646F626520496D616765526561647971C9653C0000001E504C5445E3E3"
|
|
||||||
$"E39C9A9CDEDBDE636163EFEFEFCECBCE848284404040FFFFFFE7E7E7E071FC71"
|
|
||||||
$"000000A34944415478DA6260C50F00028881950D2F000820A03C270B6EC00610"
|
|
||||||
$"404079160EDC800D2080C0F29C38011B40001192070820247976767698309CC5"
|
|
||||||
$"061040D8E4D9112AD9000208539E9D1D591E2080D0E5D9D951E5010208551E01"
|
|
||||||
$"60F2000144483F4000A1C933A0DB0F104084DC0F104084FC0F104084C20F2080"
|
|
||||||
$"08C9030410489E93092760030820A03C13236EC00610404079667C0020801858"
|
|
||||||
$"39F1028000030094AB11758434ABDD0000000049454E44AE426082"
|
|
||||||
};
|
|
||||||
|
|
||||||
resource(10, "play_down") #'PNG ' array {
|
|
||||||
$"89504E470D0A1A0A0000000D494844520000002800000015080300000003C45C"
|
|
||||||
$"2C0000000467414D410000AFC837058AE90000001974455874536F6674776172"
|
|
||||||
$"650041646F626520496D616765526561647971C9653C00000024504C54451818"
|
|
||||||
$"18BFBFBFE7E7E7636163848284636563212421CECBCE1010100000007B7D7B1C"
|
|
||||||
$"1C1CE52CB398000000B14944415478DA62602712000410030B71800920801858"
|
|
||||||
$"3888006CCC4C0001C4C0C2491830B03233010410030B0361C00654081040442B"
|
|
||||||
$"040820B8424646241946108F112E0452081040480A91946251081040280A4132"
|
|
||||||
$"DC38140204109A42A81C1685000184A1102C8B45214000116D22400061B81197"
|
|
||||||
$"42800022DAD70001447438020410D131031040442B0408200616362200502140"
|
|
||||||
$"0031B0B01201B89899000288819938C00410400C4C4402800003000BCF081A22"
|
|
||||||
$"DA76AF0000000049454E44AE426082"
|
|
||||||
};
|
|
||||||
|
|
||||||
resource(11, "play_up") #'PNG ' array {
|
|
||||||
$"89504E470D0A1A0A0000000D494844520000002800000015080300000003C45C"
|
|
||||||
$"2C0000000467414D410000AFC837058AE90000001974455874536F6674776172"
|
|
||||||
$"650041646F626520496D616765526561647971C9653C0000001E504C5445E3E3"
|
|
||||||
$"E3EFEFEFCECBCEDEDBDE9C9A9C636163848284404040FFFFFFE7E7E7217A6570"
|
|
||||||
$"000000B14944415478DA62602212000410031B718013208018D8188900CCAC9C"
|
|
||||||
$"0001C4C0C6411870B2B072020410031B2761C00C54081040442B040820B84276"
|
|
||||||
$"76241976108F1D2E0452081040480A91946251081040280A41320C3814020410"
|
|
||||||
$"9A42A81C1685000184A1102C8B45214000116D22400061B8119742800022DAD7"
|
|
||||||
$"0001447438020410D131031040442B04082006366622005021400031B0B11001"
|
|
||||||
$"D85839010288819538C00910400C9C440280000300C6C8169FB4102432000000"
|
|
||||||
$"0049454E44AE426082"
|
|
||||||
};
|
|
||||||
|
|
||||||
resource(12, "next_down") #'PNG ' array {
|
|
||||||
$"89504E470D0A1A0A0000000D494844520000001D0000001508030000008D1E15"
|
|
||||||
$"500000000467414D410000AFC837058AE90000001974455874536F6674776172"
|
|
||||||
$"650041646F626520496D616765526561647971C9653C00000024504C54451818"
|
|
||||||
$"18BFBFBFE7E7E7636163636563212421CECBCE8482841010100000001C1C1C7B"
|
|
||||||
$"7D7B41373F2B000000A04944415478DA6260C307000288811D0F60020820060E"
|
|
||||||
$"9C8095990920801838710106166626800062C0095881B20001845F162080606C"
|
|
||||||
$"4646048B112E0B104048628C98B20001842C0B12E6429105082054599004B22C"
|
|
||||||
$"4000A1CB323222CB0204107EBD0001846E2FAA2C4000E177334000E1F72F4000"
|
|
||||||
$"E10F2B8000C22F0B10400CAC380150162080185870026E662680006260C60398"
|
|
||||||
$"00028881091F00083000D82205D9820E455D0000000049454E44AE426082"
|
|
||||||
};
|
|
||||||
|
|
||||||
resource(13, "next_up") #'PNG ' array {
|
|
||||||
$"89504E470D0A1A0A0000000D494844520000001D0000001508030000008D1E15"
|
|
||||||
$"500000000467414D410000AFC837058AE90000001974455874536F6674776172"
|
|
||||||
$"650041646F626520496D616765526561647971C9653C0000001E504C5445E3E3"
|
|
||||||
$"E3EFEFEFCECBCE848284DEDBDE9C9A9C636163404040FFFFFFE7E7E7CD8E4595"
|
|
||||||
$"000000A34944415478DA6260C20700028881190FE004082006469C80858D1320"
|
|
||||||
$"80183870014E56364E800062E0C4055880B20001845F16208060B2ECEC9C7016"
|
|
||||||
$"3B5C16208010B23079645980004296050933A0C8020410AA2C480259162080D0"
|
|
||||||
$"65D9D99165010208BF5E800042B71755162080F0BB192080F0FB172080F08715"
|
|
||||||
$"4000E19705082006169C00280B10400CAC3801331B27400031B0E1019C000184"
|
|
||||||
$"DB5E1000083000F03F1072763DB7B80000000049454E44AE426082"
|
|
||||||
};
|
|
||||||
|
|
||||||
resource(14, "repeat_up_on") #'PNG ' array {
|
|
||||||
$"89504E470D0A1A0A0000000D494844520000002C0000001508030000000A2FFC"
|
|
||||||
$"560000000467414D410000AFC837058AE90000001974455874536F6674776172"
|
|
||||||
$"650041646F626520496D616765526561647971C9653C000000B7504C544569BA"
|
|
||||||
$"59E9E9E96CBB5C86C87AD8D8D8E8E8E885C778577452F0F0F09A9A9AEAEAEA7D"
|
|
||||||
$"8B7AE3E3E3427538D2D2D2D9D9D9A7C7A18C8C8CADC1A962AE534F6A4B599E4B"
|
|
||||||
$"EBECEBCCD8CAB7B9B7529045BCBCBCA8A8A8DEDEDEC2CEC0579A4A91BD87EDED"
|
|
||||||
$"ED788A74597753559748C3C3C392B38BE4E7E3EBEBEB84BE7885BF7894CE8972"
|
|
||||||
$"7D708DA7883F7035B2B2B29797979D9D9DAAD8A1ECECEC8AA385DEDBDE9C9A9C"
|
|
||||||
$"EFEFEF636163848284CECBCE494949FFFFFFE7E7E72E5D330E0000010F494441"
|
|
||||||
$"5478DA62B0240100041083A505D1C0062080808A6DCC880226E636000104546C"
|
|
||||||
$"664D0CB03135B7010820B0621B2280095031400091A4182080B02AB6B2022204"
|
|
||||||
$"802B0608209862163D7D031519985A2CAA418A010208AA984F505B47D558821F"
|
|
||||||
$"AA166A3C5C2F5431400041154B731B6A31B369B0F020A9B24272154431400041"
|
|
||||||
$"1573CA33333030498AA31889A1182080A08AA5349918188479651951145BA129"
|
|
||||||
$"0608209807059445E574D9C518116E866B43B8192080A08A591985944414D58C"
|
|
||||||
$"E0A1010F08E4D000082098C9AC5C0A1C66EA08FF23AB86873340009114830001"
|
|
||||||
$"44926280000229B6312106001503041050B1892951C0C2DC062080808ACD8905"
|
|
||||||
$"360001C46069433C00083000A3F2C770525CB4110000000049454E44AE426082"
|
|
||||||
};
|
|
||||||
|
|
||||||
resource(15, "repeat_up_off") #'PNG ' array {
|
|
||||||
$"89504E470D0A1A0A0000000D494844520000002C0000001508030000000A2FFC"
|
|
||||||
$"560000000467414D410000AFC837058AE90000001974455874536F6674776172"
|
|
||||||
$"650041646F626520496D616765526561647971C9653C000000A5504C5445C4C4"
|
|
||||||
$"C4E9E9E9C5C5C5D0D0D0C3C3C3D8D8D8ECECECE8E8E8D9D9D99898989F9F9FA6"
|
|
||||||
$"A6A68B8B8BBCBCBCB7B7B7C7C7C77B7B7BD2D2D2B9B9B9CFCFCF8D8D8DB2B2B2"
|
|
||||||
$"CBCBCB6D6D6D7A7A7ADADADAEBEBEBDEDEDEDDDDDDEDEDED9D9D9DE3E3E38C8C"
|
|
||||||
$"8C979797F0F0F0A2A2A2A8A8A8767676B8B8B8EAEAEA7E7E7ED5D5D5ABABAB77"
|
|
||||||
$"77779A9A9AA7A7A7DEDBDE9C9A9CEFEFEF636163848284CECBCE494949FFFFFF"
|
|
||||||
$"E7E7E70B3909DF0000010F4944415478DA6230260100041083B111D1C00C2080"
|
|
||||||
$"808ACD0C88027A8666000104546C604A0C30D33734030820B0623322801E5031"
|
|
||||||
$"400091A4182080B02A3631012204802B0608209862565145391669985A2CAA41"
|
|
||||||
$"8A010208AA585041438B4F578803AA166A3C5C2F543140004115AB88C868320B"
|
|
||||||
$"33B1CA23A932417215443140004115EB3030333030714AA21889A1182080A08A"
|
|
||||||
$"79F9991818D404981951149BA0290608209807C5B8B89555B5D918116E866B43"
|
|
||||||
$"B8192080A08AD9195924C479CCD8E0A1010F08E4D000082098C9ECEAB24A0652"
|
|
||||||
$"08FF23AB868733400091148300014492628000022936D32306001503041050B1"
|
|
||||||
$"9E3E51C0C8D00C2080808A0D8905660001C4606C463C000830007CBDB25B32D5"
|
|
||||||
$"44EB0000000049454E44AE426082"
|
|
||||||
};
|
|
||||||
|
|
||||||
resource(16, "repeat_down") #'PNG ' array {
|
|
||||||
$"89504E470D0A1A0A0000000D494844520000002C0000001508030000000A2FFC"
|
|
||||||
$"560000000467414D410000AFC837058AE90000001974455874536F6674776172"
|
|
||||||
$"650041646F626520496D616765526561647971C9653C000000BD504C54451818"
|
|
||||||
$"18B6B6B6CECBCEE7E7E78482846361631010106365632124210000009645A616"
|
|
||||||
$"16162727271717177937859344A313131387758B212121151515725877262626"
|
|
||||||
$"58385E6E4278BD8AC77B7D7B523E56A688AC434343A88BAD1C1C1CAA68B76B31"
|
|
||||||
$"76AD6FBAA661B48274856868684D4D4D6D4C74C08FCA7A38871B181C7B418714"
|
|
||||||
$"14143C3C3C121212484648B095B4A865B59D51AC0F0F0F6565653327357A4087"
|
|
||||||
$"3D313F737373755C7A55275E1413142D2D2D5757578D828F626262FA21648900"
|
|
||||||
$"00010F4944415478DA6260220100041003130BD180192080808A19D888021CAC"
|
|
||||||
$"CC00010454CCC6490C60606765060820B062062200075031400091A4182080B0"
|
|
||||||
$"2A6664042204802B06082098621E55153B1D21985A2CAA418A010208AAD8DADC"
|
|
||||||
$"5644CD424F14AA166A3C5C2F543140004115DB285B2AF06968F1C821A9624472"
|
|
||||||
$"154431400041151B8BF37171F12B9AA01889A1182080A08A654CF9B9B80C25CC"
|
|
||||||
$"B8511433A2290608209807C5E4950CD465ADB8116E866B43B8192080A08A79B9"
|
|
||||||
$"A5A4F5053505E0A1010F08E4D000082098C9BCC2BA466CDA08FF23AB86873340"
|
|
||||||
$"0091148300014492628000022966E0200600150304105031073B514092951920"
|
|
||||||
$"80808A598905CC0001C4C0C44C3C00083000D89E119E45174D07000000004945"
|
|
||||||
$"4E44AE426082"
|
|
||||||
};
|
|
||||||
|
|
||||||
resource(17, "ffwd_down") #'PNG ' array {
|
|
||||||
$"89504E470D0A1A0A0000000D494844520000001E0000001508030000006629AE"
|
|
||||||
$"530000000467414D410000AFC837058AE90000001974455874536F6674776172"
|
|
||||||
$"650041646F626520496D616765526561647971C9653C00000024504C54451818"
|
|
||||||
$"18BFBFBFE7E7E7636163636563212421CECBCE8482841010100000001C1C1C7B"
|
|
||||||
$"7D7B41373F2B000000A84944415478DA6260C30B000288811D1F60020820060E"
|
|
||||||
$"DC8095990920801838710206166626800062C00D5881D2000144401A20804034"
|
|
||||||
$"23234C04C1824A0304104410268C6041A5010208260812E6426241A501020821"
|
|
||||||
$"0D1246B0A0D20001842C8D0CA0D20001444037400021DB8DCC824A0304100197"
|
|
||||||
$"030410017F030410815003082002D20001C4C08A1B00A5010288810537E06666"
|
|
||||||
$"02082006667C800920801898F0028000030099530626E0F55351000000004945"
|
|
||||||
$"4E44AE426082"
|
|
||||||
};
|
|
||||||
|
|
||||||
resource(18, "ffwd_up") #'PNG ' array {
|
|
||||||
$"89504E470D0A1A0A0000000D494844520000001E0000001508030000006629AE"
|
|
||||||
$"530000000467414D410000AFC837058AE90000001974455874536F6674776172"
|
|
||||||
$"650041646F626520496D616765526561647971C9653C0000001E504C5445E3E3"
|
|
||||||
$"E3EFEFEFCECBCE848284DEDBDE9C9A9C636163404040FFFFFFE7E7E7CD8E4595"
|
|
||||||
$"000000A94944415478DA6260C20B00028881191FE00408200646DC80858D1320"
|
|
||||||
$"80183870024E56364E800062E0C4095880D2000144401A208040D2ECEC301104"
|
|
||||||
$"0B2A0D104010699830820595060820983448980189059506082084344818C182"
|
|
||||||
$"4A030410B23432804A03041001DD0001846C37320B2A0D1040045C0E104004FC"
|
|
||||||
$"0D104004420D20800848030410030B6E00940608200656DC80998D13208018D8"
|
|
||||||
$"F0014E8000C26337080004180000C610D6FAA81D2B0000000049454E44AE4260"
|
|
||||||
$"82"
|
|
||||||
};
|
|
||||||
|
|
||||||
resource(19, "eject_down") #'PNG ' array {
|
|
||||||
$"89504E470D0A1A0A0000000D494844520000002000000015080300000010131C"
|
|
||||||
$"D80000000467414D410000AFC837058AE90000001974455874536F6674776172"
|
|
||||||
$"650041646F626520496D616765526561647971C9653C00000021504C54451818"
|
|
||||||
$"18BFBFBFCECBCEE7E7E78482846361631010106365632124210000007B7D7B54"
|
|
||||||
$"B16A73000000AC4944415478DA626022000002888189052F60060820A0020636"
|
|
||||||
$"9C808395192080800AD8387101067656668000022B60C00138800A000288A002"
|
|
||||||
$"80004257C0C888A6002080D014303222AB002900082054058C8C282A400A0002"
|
|
||||||
$"0845012323AA0A9002800022A8002080082A00082082DE040820822600041041"
|
|
||||||
$"05000144D00A800022A8002080400A18387001A0028000022AE060C709B85899"
|
|
||||||
$"010208A880151F60060820062666FC0020C000DD73078EF9B85C950000000049"
|
|
||||||
$"454E44AE426082"
|
|
||||||
};
|
|
||||||
|
|
||||||
resource(20, "eject_up") #'PNG ' array {
|
|
||||||
$"89504E470D0A1A0A0000000D494844520000002000000015080300000010131C"
|
|
||||||
$"D80000000467414D410000AFC837058AE90000001974455874536F6674776172"
|
|
||||||
$"650041646F626520496D616765526561647971C9653C0000001B504C5445DEDB"
|
|
||||||
$"DE9C9A9CEFEFEF636163848284404040CECBCEFFFFFFE7E7E70F06920C000000"
|
|
||||||
$"AC4944415478DA62602300000288818D052FE0000820A0020E269C8081990320"
|
|
||||||
$"80800A98D871010E46660E8000022BE0C00118800A000288A00280004257C0CA"
|
|
||||||
$"8AA6002080D014B0B222AB00290008205405ACAC282A400A00020845012B2BAA"
|
|
||||||
$"0A9002800022A8002080082A00082082DE04082082260004104105000144D00A"
|
|
||||||
$"800022A8002080400A38187001A0028000022A6060C409589839000208A88019"
|
|
||||||
$"1FE000082006360EFC0020C000B61F0ED83F7D28B30000000049454E44AE4260"
|
|
||||||
$"82"
|
|
||||||
};
|
|
||||||
|
|
||||||
resource(21, "paused_up") #'PNG ' array {
|
|
||||||
$"89504E470D0A1A0A0000000D494844520000002800000015080300000003C45C"
|
|
||||||
$"2C0000000467414D410000AFC837058AE90000001974455874536F6674776172"
|
|
||||||
$"650041646F626520496D616765526561647971C9653C00000021504C5445E7E7"
|
|
||||||
$"E784828463616369BA599C9A9CDEDBDE404040CECBCEEFEFEFFFFFFFE3E3E3BB"
|
|
||||||
$"3117C6000000AF4944415478DA62602712000410032371800120801818398800"
|
|
||||||
$"AC4C0C0001C4C0C8491830B0303100041003230361C00A54081040442B040820"
|
|
||||||
$"B84236362419666666280157081040480A91946251081040280A414AB9702804"
|
|
||||||
$"082034855053B1280408200C8560A55814020410D126020410861B7129040820"
|
|
||||||
$"A27D0D10404487234000111D33000144B4428000626064250200150204100323"
|
|
||||||
$"0B11809189012080189888030C0001C4402C00083000E49407BBAA2FBF830000"
|
|
||||||
$"000049454E44AE426082"
|
|
||||||
};
|
|
||||||
|
|
||||||
resource(22, "play_up_on") #'PNG ' array {
|
|
||||||
$"89504E470D0A1A0A0000000D4948445200000028000000150802000000BB783B"
|
|
||||||
$"49000000D549444154789CC5D5310A83301406E0DF9203E4223D90B374922E1E"
|
|
||||||
$"A08360C75E2337B09B3D40C1C503644C86824BC125438740905A4D02E9F39F5E"
|
|
||||||
$"10F97C0F79C9FA678F3DC2DA7B4BAF16A7820128CF251939BEC6E6DA00600038"
|
|
||||||
$"E734AAD6BA7B74B666F64C034FEFC9D5071A7219B6F6A01E2A0097E36DFBFD3C"
|
|
||||||
$"CF6D2184581E37E2E9B81E2AFB05C91334EA396F8C4902AF8EFA278F80E10726"
|
|
||||||
$"FAE74A35FC888E6D52751C01A72223E0B46410FC0FD20307925F8BC2BB375C76"
|
|
||||||
$"5D99F3DD4D0ABBAB8A20EE2664524A292519EC9229A5E855001F00D549BD62C7"
|
|
||||||
$"07500000000049454E44AE426082"
|
|
||||||
};
|
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2006-2007, Haiku, Inc.
|
|
||||||
* Distributed under the terms of the MIT license.
|
|
||||||
*
|
|
||||||
* Author:
|
|
||||||
* DarkWyrm <bpmagic@columbus.rr.com>
|
|
||||||
*/
|
|
||||||
#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);
|
|
||||||
}
|
|
|
@ -1,29 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2006-2007, Haiku, Inc.
|
|
||||||
* Distributed under the terms of the MIT license.
|
|
||||||
*
|
|
||||||
* Author:
|
|
||||||
* DarkWyrm <bpmagic@columbus.rr.com>
|
|
||||||
*/
|
|
||||||
#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
|
|
|
@ -1,88 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2006-2007, Haiku, Inc.
|
|
||||||
* Distributed under the terms of the MIT license.
|
|
||||||
*
|
|
||||||
* Author:
|
|
||||||
* DarkWyrm <bpmagic@columbus.rr.com>
|
|
||||||
*/
|
|
||||||
#include "DrawButton.h"
|
|
||||||
|
|
||||||
DrawButton::DrawButton(BRect frame, const char *name, BBitmap *up, BBitmap *down,
|
|
||||||
BMessage *msg, int32 resize, int32 flags)
|
|
||||||
: BButton(frame, name, "", msg, resize, flags)
|
|
||||||
{
|
|
||||||
fUp = up;
|
|
||||||
fDown = down;
|
|
||||||
fDisabled = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
DrawButton::~DrawButton(void)
|
|
||||||
{
|
|
||||||
delete fUp;
|
|
||||||
delete fDown;
|
|
||||||
delete fDisabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
DrawButton::SetBitmaps(BBitmap *up, BBitmap *down)
|
|
||||||
{
|
|
||||||
delete fUp;
|
|
||||||
delete fDown;
|
|
||||||
|
|
||||||
fUp = up;
|
|
||||||
fDown = down;
|
|
||||||
|
|
||||||
if (IsEnabled())
|
|
||||||
Invalidate();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
DrawButton::SetDisabled(BBitmap *disabled)
|
|
||||||
{
|
|
||||||
delete fDisabled;
|
|
||||||
|
|
||||||
fDisabled = disabled;
|
|
||||||
|
|
||||||
if (!IsEnabled())
|
|
||||||
Invalidate();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
DrawButton::Draw(BRect update)
|
|
||||||
{
|
|
||||||
if (!IsEnabled()) {
|
|
||||||
if (fDisabled)
|
|
||||||
DrawBitmap(fDisabled, BPoint(0,0));
|
|
||||||
else
|
|
||||||
StrokeRect(Bounds());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Value() == B_CONTROL_ON) {
|
|
||||||
if (fDown)
|
|
||||||
DrawBitmap(fDown, BPoint(0,0));
|
|
||||||
else
|
|
||||||
StrokeRect(Bounds());
|
|
||||||
} else {
|
|
||||||
if (fUp)
|
|
||||||
DrawBitmap(fUp, BPoint(0,0));
|
|
||||||
else
|
|
||||||
StrokeRect(Bounds());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
DrawButton::ResizeToPreferred(void)
|
|
||||||
{
|
|
||||||
if (fUp)
|
|
||||||
ResizeTo(fUp->Bounds().Width(),fUp->Bounds().Height());
|
|
||||||
else if (fDown)
|
|
||||||
ResizeTo(fDown->Bounds().Width(),fDown->Bounds().Height());
|
|
||||||
else if (fDisabled)
|
|
||||||
ResizeTo(fDisabled->Bounds().Width(),fDisabled->Bounds().Height());
|
|
||||||
}
|
|
|
@ -1,40 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2006-2007, Haiku, Inc.
|
|
||||||
* Distributed under the terms of the MIT license.
|
|
||||||
*
|
|
||||||
* Author:
|
|
||||||
* DarkWyrm <bpmagic@columbus.rr.com>
|
|
||||||
*/
|
|
||||||
#ifndef _DRAW_BUTTON_H
|
|
||||||
#define _DRAW_BUTTON_H
|
|
||||||
|
|
||||||
#include <Looper.h>
|
|
||||||
#include <Application.h>
|
|
||||||
#include <Window.h>
|
|
||||||
#include <Button.h>
|
|
||||||
#include <Bitmap.h>
|
|
||||||
#include <Rect.h>
|
|
||||||
|
|
||||||
|
|
||||||
class DrawButton : public BButton
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
DrawButton(BRect frame, const char *name, BBitmap *up,
|
|
||||||
BBitmap *down,BMessage *msg, int32 resize,
|
|
||||||
int32 flags);
|
|
||||||
virtual ~DrawButton(void);
|
|
||||||
|
|
||||||
void Draw(BRect update);
|
|
||||||
|
|
||||||
void SetBitmaps(BBitmap *up, BBitmap *down);
|
|
||||||
void ResizeToPreferred(void);
|
|
||||||
void SetDisabled(BBitmap *disabled);
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
BBitmap *fUp,
|
|
||||||
*fDown,
|
|
||||||
*fDisabled;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,24 +0,0 @@
|
||||||
SubDir HAIKU_TOP src apps cdplayer ;
|
|
||||||
|
|
||||||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
|
||||||
|
|
||||||
Application CDPlayer :
|
|
||||||
CDAudioDevice.cpp
|
|
||||||
CDDBSupport.cpp
|
|
||||||
CDPlayer.cpp
|
|
||||||
DoubleShotDrawButton.cpp
|
|
||||||
DrawButton.cpp
|
|
||||||
PlayList.cpp
|
|
||||||
TwoStateDrawButton.cpp
|
|
||||||
VolumeSlider.cpp
|
|
||||||
|
|
||||||
: be $(TARGET_SELECT_UNAME_ETC_LIB) $(TARGET_NETAPI_LIB) $(TARGET_LIBSTDC++)
|
|
||||||
localestub translation textencoding
|
|
||||||
: CDPlayer.rdef
|
|
||||||
;
|
|
||||||
|
|
||||||
DoCatalogs CDPlayer :
|
|
||||||
x-vnd.Haiku-CDPlayer
|
|
||||||
:
|
|
||||||
CDPlayer.cpp
|
|
||||||
;
|
|
|
@ -1,31 +0,0 @@
|
||||||
----------------------
|
|
||||||
Be Sample Code License
|
|
||||||
----------------------
|
|
||||||
|
|
||||||
Copyright 1991-1999, Be Incorporated.
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions
|
|
||||||
are met:
|
|
||||||
|
|
||||||
1. Redistributions of source code must retain the above copyright
|
|
||||||
notice, this list of conditions, and the following disclaimer.
|
|
||||||
|
|
||||||
2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
notice, this list of conditions, and the following disclaimer in the
|
|
||||||
documentation and/or other materials provided with the distribution.
|
|
||||||
|
|
||||||
3. The name of the author may not be used to endorse or promote products
|
|
||||||
derived from this software without specific prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
|
|
||||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
|
||||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
||||||
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
|
||||||
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
@ -1,299 +0,0 @@
|
||||||
#include "PlayList.h"
|
|
||||||
|
|
||||||
#include <OS.h>
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
//#define DEBUG_PLAYLIST
|
|
||||||
|
|
||||||
#ifdef DEBUG_PLAYLIST
|
|
||||||
#include <stdio.h>
|
|
||||||
#define STRACE(x) printf x
|
|
||||||
#else
|
|
||||||
#define STRACE(x) /* nothing */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
PlayList::PlayList(int16 count, int16 start)
|
|
||||||
:
|
|
||||||
fTrackCount(count),
|
|
||||||
fTrackIndex(0),
|
|
||||||
fStartingTrack(start),
|
|
||||||
fRandom(false),
|
|
||||||
fLoop(false)
|
|
||||||
{
|
|
||||||
STRACE(("PlayList(count=%d,start=%d)\n",count,start));
|
|
||||||
|
|
||||||
srand(real_time_clock_usecs());
|
|
||||||
|
|
||||||
if (fTrackCount < 0)
|
|
||||||
fTrackCount = 0;
|
|
||||||
else if (fTrackCount > 500)
|
|
||||||
fTrackCount = 500;
|
|
||||||
|
|
||||||
if (fStartingTrack >= fTrackCount)
|
|
||||||
fStartingTrack = fTrackCount - 1;
|
|
||||||
|
|
||||||
if (fStartingTrack < 1)
|
|
||||||
fStartingTrack = 1;
|
|
||||||
|
|
||||||
memset(fTrackList, -1, 500);
|
|
||||||
|
|
||||||
Unrandomize();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
PlayList::SetTrackCount(const int16 &count)
|
|
||||||
{
|
|
||||||
fLocker.Lock();
|
|
||||||
|
|
||||||
STRACE(("PlayList::SetTrackCount(%d)\n",count));
|
|
||||||
|
|
||||||
if (count <= 0) {
|
|
||||||
fTrackCount = 0;
|
|
||||||
fTrackIndex = 0;
|
|
||||||
}
|
|
||||||
else if (count > 500)
|
|
||||||
fTrackCount = 500;
|
|
||||||
else
|
|
||||||
fTrackCount = count;
|
|
||||||
|
|
||||||
memset(fTrackList, -1, 500);
|
|
||||||
SetShuffle(IsShuffled());
|
|
||||||
|
|
||||||
fLocker.Unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
PlayList::SetStartingTrack(const int16 &start)
|
|
||||||
{
|
|
||||||
fLocker.Lock();
|
|
||||||
|
|
||||||
STRACE(("PlayList::SetStartingTrack(%d)\n",start));
|
|
||||||
|
|
||||||
fStartingTrack = start;
|
|
||||||
|
|
||||||
fLocker.Unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
PlayList::Rewind()
|
|
||||||
{
|
|
||||||
STRACE(("PlayList::Rewind()\n"));
|
|
||||||
fLocker.Lock();
|
|
||||||
|
|
||||||
fTrackIndex = 0;
|
|
||||||
|
|
||||||
fLocker.Unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
PlayList::SetShuffle(const bool &random)
|
|
||||||
{
|
|
||||||
STRACE(("PlayList::SetShuffle(%s)\n", random ? "random" : "sequential"));
|
|
||||||
fLocker.Lock();
|
|
||||||
|
|
||||||
if (random)
|
|
||||||
Randomize();
|
|
||||||
else
|
|
||||||
Unrandomize();
|
|
||||||
|
|
||||||
fRandom = random;
|
|
||||||
|
|
||||||
fLocker.Unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
PlayList::SetLoop(const bool &loop)
|
|
||||||
{
|
|
||||||
STRACE(("PlayList::SetLoop(%s)\n", loop ? "loop" : "non-loop"));
|
|
||||||
fLocker.Lock();
|
|
||||||
|
|
||||||
fLoop = loop;
|
|
||||||
|
|
||||||
fLocker.Unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
PlayList::SetCurrentTrack(const int16 &track)
|
|
||||||
{
|
|
||||||
STRACE(("PlayList::SetCurrentTrack(%d)\n",track));
|
|
||||||
|
|
||||||
if (track < 0 || track > fTrackCount)
|
|
||||||
return;
|
|
||||||
|
|
||||||
fLocker.Lock();
|
|
||||||
|
|
||||||
for (int16 i = 0; i < fTrackCount; i++) {
|
|
||||||
if (fTrackList[i] == track) {
|
|
||||||
fTrackIndex = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fLocker.Unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int16
|
|
||||||
PlayList::GetCurrentTrack()
|
|
||||||
{
|
|
||||||
fLocker.Lock();
|
|
||||||
|
|
||||||
int16 value = fTrackList[fTrackIndex];
|
|
||||||
// STRACE(("PlayList::GetCurrentTrack()=%d\n",value));
|
|
||||||
|
|
||||||
fLocker.Unlock();
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int16
|
|
||||||
PlayList::GetNextTrack()
|
|
||||||
{
|
|
||||||
fLocker.Lock();
|
|
||||||
|
|
||||||
if (fTrackCount < 1) {
|
|
||||||
fLocker.Unlock();
|
|
||||||
STRACE(("PlayList::GetNextTrack()=-1 (no tracks)\n"));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fTrackIndex > (fTrackCount - fStartingTrack)) {
|
|
||||||
if (fLoop)
|
|
||||||
fTrackIndex = 0;
|
|
||||||
else {
|
|
||||||
fLocker.Unlock();
|
|
||||||
STRACE(("PlayList::GetNextTrack()=-1 (track index out of range)\n"));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
fTrackIndex++;
|
|
||||||
|
|
||||||
int16 value = fTrackList[fTrackIndex];
|
|
||||||
STRACE(("PlayList::GetNextTrack()=%d\n",value));
|
|
||||||
|
|
||||||
fLocker.Unlock();
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int16
|
|
||||||
PlayList::GetPreviousTrack()
|
|
||||||
{
|
|
||||||
fLocker.Lock();
|
|
||||||
|
|
||||||
if (fTrackCount < 1) {
|
|
||||||
fLocker.Unlock();
|
|
||||||
STRACE(("PlayList::GetPreviousTrack()=-1 (no tracks)\n"));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fTrackIndex == 0) {
|
|
||||||
if (fLoop)
|
|
||||||
fTrackIndex = (fTrackCount - fStartingTrack);
|
|
||||||
else {
|
|
||||||
fLocker.Unlock();
|
|
||||||
STRACE(("PlayList::GetPreviousTrack()=-1 (track index out of range)\n"));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
fTrackIndex--;
|
|
||||||
|
|
||||||
int16 value = fTrackList[fTrackIndex];
|
|
||||||
STRACE(("PlayList::GetPreviousTrack()=%d\n",value));
|
|
||||||
fLocker.Unlock();
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int16
|
|
||||||
PlayList::GetLastTrack()
|
|
||||||
{
|
|
||||||
fLocker.Lock();
|
|
||||||
|
|
||||||
if (fTrackCount < 1) {
|
|
||||||
fLocker.Unlock();
|
|
||||||
STRACE(("PlayList::GetLastTrack()=-1 (no tracks)\n"));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
fTrackIndex = fTrackCount - 1;
|
|
||||||
int16 value = fTrackList[fTrackIndex];
|
|
||||||
STRACE(("PlayList::GetLastTrack()=%d\n",value));
|
|
||||||
fLocker.Unlock();
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int16
|
|
||||||
PlayList::GetFirstTrack()
|
|
||||||
{
|
|
||||||
fLocker.Lock();
|
|
||||||
|
|
||||||
if (fTrackCount < 1) {
|
|
||||||
fLocker.Unlock();
|
|
||||||
STRACE(("PlayList::GetFirstTrack()=-1 (no tracks)\n"));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
fTrackIndex = 0;
|
|
||||||
int16 value = fTrackList[fTrackIndex];
|
|
||||||
STRACE(("PlayList::GetFirstTrack()=%d\n",value));
|
|
||||||
fLocker.Unlock();
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
PlayList::Randomize()
|
|
||||||
{
|
|
||||||
STRACE(("PlayList::Randomize()\n"));
|
|
||||||
|
|
||||||
// Reinitialize the count
|
|
||||||
for (int16 i = fStartingTrack; i <= fTrackCount; i++)
|
|
||||||
fTrackList[i - fStartingTrack] = i;
|
|
||||||
|
|
||||||
// There are probably *much* better ways to do this,
|
|
||||||
// but this is the only one I could think of. :(
|
|
||||||
|
|
||||||
int32 listcount = (fTrackCount - fStartingTrack);
|
|
||||||
int32 swapcount = listcount * 2;
|
|
||||||
|
|
||||||
int16 temp, first, second;
|
|
||||||
for (int32 i = 0; i < swapcount; i++) {
|
|
||||||
// repeatedly pick two elements at random and swap them
|
|
||||||
// This way we are sure to not have any duplicates and still have
|
|
||||||
// all tracks eventually be played.
|
|
||||||
|
|
||||||
first = (int16)(listcount * ((float)rand() / RAND_MAX));
|
|
||||||
second = (int16)(listcount * ((float)rand() / RAND_MAX));
|
|
||||||
|
|
||||||
temp = fTrackList[first];
|
|
||||||
fTrackList[first] = fTrackList[second];
|
|
||||||
fTrackList[second] = temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef DEBUG_PLAYLIST
|
|
||||||
for (int16 i = fStartingTrack; i <= fTrackCount; i++)
|
|
||||||
printf("\tSlot %d: track %d\n", i, fTrackList[i]);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
PlayList::Unrandomize()
|
|
||||||
{
|
|
||||||
STRACE(("PlayList::Unrandomize()\n"));
|
|
||||||
for (int16 i = fStartingTrack; i <= fTrackCount; i++)
|
|
||||||
fTrackList[i - fStartingTrack] = i;
|
|
||||||
}
|
|
|
@ -1,49 +0,0 @@
|
||||||
#ifndef PLAYLIST_H
|
|
||||||
#define PLAYLIST_H
|
|
||||||
|
|
||||||
#include <Locker.h>
|
|
||||||
#include <SupportDefs.h>
|
|
||||||
|
|
||||||
class PlayList {
|
|
||||||
public:
|
|
||||||
PlayList(int16 tracks = 0, int16 startingtrack = 1);
|
|
||||||
|
|
||||||
void SetTrackCount(const int16 &count);
|
|
||||||
int16 TrackCount() const { return fTrackCount; }
|
|
||||||
|
|
||||||
void SetStartingTrack(const int16 &start);
|
|
||||||
int16 StartingTrack() const { return fStartingTrack; }
|
|
||||||
|
|
||||||
void Rewind();
|
|
||||||
|
|
||||||
void SetShuffle(const bool &random);
|
|
||||||
bool IsShuffled() const { return fRandom; }
|
|
||||||
|
|
||||||
void SetLoop(const bool &loop);
|
|
||||||
bool IsLoop() const { return fLoop; }
|
|
||||||
|
|
||||||
void SetCurrentTrack(const int16 &track);
|
|
||||||
int16 GetCurrentTrack();
|
|
||||||
|
|
||||||
int16 GetNextTrack();
|
|
||||||
int16 GetPreviousTrack();
|
|
||||||
|
|
||||||
int16 GetFirstTrack();
|
|
||||||
int16 GetLastTrack();
|
|
||||||
|
|
||||||
private:
|
|
||||||
void Randomize();
|
|
||||||
void Unrandomize();
|
|
||||||
|
|
||||||
int16 fTrackCount;
|
|
||||||
int16 fTrackIndex;
|
|
||||||
int16 fStartingTrack;
|
|
||||||
int16 fTrackList[500]; // This should be big enough. :)
|
|
||||||
|
|
||||||
bool fRandom;
|
|
||||||
bool fLoop;
|
|
||||||
|
|
||||||
BLocker fLocker;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // PLAYLIST_H
|
|
|
@ -1,274 +0,0 @@
|
||||||
#include "TrackMenu.h"
|
|
||||||
|
|
||||||
#include <Font.h>
|
|
||||||
#include <Message.h>
|
|
||||||
#include <Region.h>
|
|
||||||
#include <String.h>
|
|
||||||
#include <Window.h>
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
|
|
||||||
TrackMenu::TrackMenu(const BRect &frame, const char *name, BMessage *msg,
|
|
||||||
const int32 &resize, const int32 &flags)
|
|
||||||
: BView(frame, name, resize, flags), BInvoker(msg, NULL),
|
|
||||||
fCurrentItem(-1),
|
|
||||||
fCount(0),
|
|
||||||
fIsTracking(false)
|
|
||||||
{
|
|
||||||
SetViewColor(20, 20, 20);
|
|
||||||
|
|
||||||
fItemRect.Set(1, 1, 1 + StringWidth("00") + 3, Bounds().bottom - 1);
|
|
||||||
|
|
||||||
BFont font;
|
|
||||||
font.SetSize(11);
|
|
||||||
font.SetSpacing(B_STRING_SPACING);
|
|
||||||
SetFont(&font);
|
|
||||||
|
|
||||||
font_height fh;
|
|
||||||
GetFontHeight(&fh);
|
|
||||||
|
|
||||||
fFontHeight = fh.ascent + fh.descent + fh.leading;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
TrackMenu::~TrackMenu()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TrackMenu::AttachedToWindow()
|
|
||||||
{
|
|
||||||
if (!Messenger().IsValid())
|
|
||||||
SetTarget(Window());
|
|
||||||
|
|
||||||
BView::AttachedToWindow();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TrackMenu::MessageReceived(BMessage *msg)
|
|
||||||
{
|
|
||||||
switch (msg->what) {
|
|
||||||
default:
|
|
||||||
BView::MessageReceived(msg);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TrackMenu::SetItemCount(const int32 &count)
|
|
||||||
{
|
|
||||||
if (count < 0) {
|
|
||||||
fCount = 0;
|
|
||||||
fCurrentItem = -1;
|
|
||||||
Invalidate();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
fCount = count;
|
|
||||||
|
|
||||||
if (fCurrentItem > fCount - 1)
|
|
||||||
fCurrentItem = fCount - 1;
|
|
||||||
else if(fCurrentItem < 0)
|
|
||||||
fCurrentItem = 0;
|
|
||||||
|
|
||||||
Invalidate();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TrackMenu::SetValue(const int32 &value)
|
|
||||||
{
|
|
||||||
if (value < 0 || value > fCount)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (value != Value()) {
|
|
||||||
fCurrentItem = value;
|
|
||||||
Invalidate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int32
|
|
||||||
TrackMenu::ItemAt(const BPoint &pt)
|
|
||||||
{
|
|
||||||
// TODO: Optimize. This is simple, but costly in performance
|
|
||||||
BRect r(fItemRect);
|
|
||||||
for (int32 i = 0; i < fCount; i++) {
|
|
||||||
if (r.Contains(pt))
|
|
||||||
return i;
|
|
||||||
r.OffsetBy(r.Width()+1,0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TrackMenu::MouseDown(BPoint point)
|
|
||||||
{
|
|
||||||
BPoint pt(point);
|
|
||||||
int32 saveditem = fCurrentItem;
|
|
||||||
int32 item = ItemAt(pt);
|
|
||||||
|
|
||||||
if (item >= 0) {
|
|
||||||
fCurrentItem = item;
|
|
||||||
Invalidate();
|
|
||||||
|
|
||||||
// Shamelessly stolen from BButton. :D
|
|
||||||
if (Window()->Flags() & B_ASYNCHRONOUS_CONTROLS) {
|
|
||||||
SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS);
|
|
||||||
fIsTracking = true;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
uint32 buttons;
|
|
||||||
|
|
||||||
do {
|
|
||||||
Window()->UpdateIfNeeded();
|
|
||||||
|
|
||||||
snooze(40000);
|
|
||||||
|
|
||||||
GetMouse(&pt, &buttons, true);
|
|
||||||
|
|
||||||
int32 mouseitem = ItemAt(pt);
|
|
||||||
if (mouseitem > -1) {
|
|
||||||
fCurrentItem = mouseitem;
|
|
||||||
Draw(Bounds());
|
|
||||||
}
|
|
||||||
|
|
||||||
} while (buttons != 0);
|
|
||||||
|
|
||||||
if (fCurrentItem != saveditem)
|
|
||||||
Invoke();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TrackMenu::MouseUp(BPoint pt)
|
|
||||||
{
|
|
||||||
if (!fIsTracking)
|
|
||||||
return;
|
|
||||||
|
|
||||||
int32 item = ItemAt(pt);
|
|
||||||
|
|
||||||
if (item >= 0)
|
|
||||||
Invoke();
|
|
||||||
|
|
||||||
fIsTracking = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TrackMenu::MouseMoved(BPoint pt, uint32 transit, const BMessage *msg)
|
|
||||||
{
|
|
||||||
if (!fIsTracking)
|
|
||||||
return;
|
|
||||||
|
|
||||||
int32 item = ItemAt(pt);
|
|
||||||
|
|
||||||
if (item >= 0) {
|
|
||||||
fCurrentItem = item;
|
|
||||||
Invalidate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TrackMenu::Draw(BRect update)
|
|
||||||
{
|
|
||||||
rgb_color dark = {20, 20, 20, 255};
|
|
||||||
rgb_color light = {200, 200, 200, 255};
|
|
||||||
BPoint pt1, pt2;
|
|
||||||
|
|
||||||
// Draw the frame
|
|
||||||
SetHighColor(dark);
|
|
||||||
pt1.Set(0, 0);
|
|
||||||
pt2 = Bounds().RightTop();
|
|
||||||
StrokeLine(pt1, pt2);
|
|
||||||
|
|
||||||
pt2.Set(0, Bounds().bottom);
|
|
||||||
StrokeLine(pt1, pt2);
|
|
||||||
|
|
||||||
SetHighColor(255,255,255);
|
|
||||||
pt1 = Bounds().RightBottom();
|
|
||||||
pt2.Set(Bounds().right, 1);
|
|
||||||
StrokeLine(pt1, pt2);
|
|
||||||
|
|
||||||
pt2.Set(1,Bounds().bottom);
|
|
||||||
StrokeLine(pt1, pt2);
|
|
||||||
|
|
||||||
// Draw the items
|
|
||||||
BRect r(fItemRect);
|
|
||||||
|
|
||||||
for (int32 i = 0; i < fCount; i++) {
|
|
||||||
// Draw the item's frame
|
|
||||||
if (i == fCurrentItem)
|
|
||||||
SetHighColor(dark);
|
|
||||||
else
|
|
||||||
SetHighColor(light);
|
|
||||||
|
|
||||||
pt1.Set(r.left, r.top);
|
|
||||||
pt2.Set(r.right, r.top);
|
|
||||||
StrokeLine(pt1, pt2);
|
|
||||||
|
|
||||||
pt2.Set(r.left, r.bottom);
|
|
||||||
StrokeLine(pt1, pt2);
|
|
||||||
|
|
||||||
if (i == fCurrentItem) {
|
|
||||||
SetHighColor(light);
|
|
||||||
pt1.Set(r.right, r.bottom);
|
|
||||||
pt2.Set(r.right, r.top + 1);
|
|
||||||
StrokeLine(pt1, pt2);
|
|
||||||
|
|
||||||
pt2.Set(r.left + 1, r.bottom);
|
|
||||||
StrokeLine(pt1, pt2);
|
|
||||||
|
|
||||||
SetHighColor(light);
|
|
||||||
FillRect(r.InsetByCopy(1, 1));
|
|
||||||
SetHighColor(dark);
|
|
||||||
}
|
|
||||||
else if (i == fCount - 1) {
|
|
||||||
SetHighColor(light);
|
|
||||||
pt1.Set(r.right, r.bottom);
|
|
||||||
pt2.Set(r.right, r.top + 1);
|
|
||||||
StrokeLine(pt1, pt2);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw the label, center justified
|
|
||||||
|
|
||||||
BString label;
|
|
||||||
label << (i + 1);
|
|
||||||
|
|
||||||
BPoint labelpt;
|
|
||||||
labelpt.x = r.left + (r.Width() - StringWidth(label.String())) / 2 + 2;
|
|
||||||
labelpt.y = r.bottom - (r.Height() - fFontHeight + 4) / 2;
|
|
||||||
|
|
||||||
if (i == fCurrentItem) {
|
|
||||||
SetHighColor(dark);
|
|
||||||
SetLowColor(light);
|
|
||||||
} else {
|
|
||||||
SetHighColor(light);
|
|
||||||
SetLowColor(dark);
|
|
||||||
}
|
|
||||||
DrawString(label.String(), labelpt);
|
|
||||||
|
|
||||||
// Setup for next iteration
|
|
||||||
r.OffsetBy(r.Width() + 1, 0);
|
|
||||||
|
|
||||||
if (r.left > Bounds().right - 2) {
|
|
||||||
ConstrainClippingRegion(NULL);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (r.right > Bounds().right - 2) {
|
|
||||||
r.right = Bounds().right - 2;
|
|
||||||
BRegion reg(r);
|
|
||||||
ConstrainClippingRegion(®);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
#ifndef TRACKMENU_H
|
|
||||||
#define TRACKMENU_H
|
|
||||||
|
|
||||||
#include <Invoker.h>
|
|
||||||
#include <View.h>
|
|
||||||
|
|
||||||
class TrackMenu : public BView, public BInvoker {
|
|
||||||
public:
|
|
||||||
TrackMenu(const BRect &frame, const char *name, BMessage *msg,
|
|
||||||
const int32 &resize = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
|
||||||
const int32 &flags = B_WILL_DRAW);
|
|
||||||
~TrackMenu();
|
|
||||||
|
|
||||||
void AttachedToWindow();
|
|
||||||
void MessageReceived(BMessage *msg);
|
|
||||||
void Draw(BRect update);
|
|
||||||
void MouseDown(BPoint pt);
|
|
||||||
void MouseUp(BPoint pt);
|
|
||||||
void MouseMoved(BPoint pt, uint32 transit, const BMessage *msg);
|
|
||||||
|
|
||||||
int32 CountItems() const { return fCount; }
|
|
||||||
void SetItemCount(const int32 &count);
|
|
||||||
|
|
||||||
int32 Value() const { return fCurrentItem; }
|
|
||||||
void SetValue(const int32 &value);
|
|
||||||
|
|
||||||
private:
|
|
||||||
int32 ItemAt(const BPoint &pt);
|
|
||||||
|
|
||||||
int32 fCurrentItem;
|
|
||||||
int32 fCount;
|
|
||||||
BRect fItemRect;
|
|
||||||
|
|
||||||
bool fIsTracking;
|
|
||||||
|
|
||||||
float fFontHeight;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // TRACKMENU_H
|
|
|
@ -1,166 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2006-2007, Haiku, Inc.
|
|
||||||
* Distributed under the terms of the MIT license.
|
|
||||||
*
|
|
||||||
* Author:
|
|
||||||
* DarkWyrm, bpmagic@columbus.rr.com
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "TwoStateDrawButton.h"
|
|
||||||
|
|
||||||
|
|
||||||
TwoStateDrawButton::TwoStateDrawButton(BRect frame, const char *name,
|
|
||||||
BBitmap *upone, BBitmap *downone, BBitmap *uptwo, BBitmap *downtwo,
|
|
||||||
BMessage *msg, const int32 &resize, const int32 &flags)
|
|
||||||
: BButton(frame, name, "", msg, resize, flags),
|
|
||||||
fUpOne(upone),
|
|
||||||
fDownOne(downone),
|
|
||||||
fUpTwo(uptwo),
|
|
||||||
fDownTwo(downtwo),
|
|
||||||
fDisabledOne(NULL),
|
|
||||||
fDisabledTwo(NULL),
|
|
||||||
fButtonState(true)
|
|
||||||
|
|
||||||
{
|
|
||||||
fButtonState = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
TwoStateDrawButton::~TwoStateDrawButton()
|
|
||||||
{
|
|
||||||
delete fUpOne;
|
|
||||||
delete fDownOne;
|
|
||||||
delete fUpTwo;
|
|
||||||
delete fDownTwo;
|
|
||||||
delete fDisabledOne;
|
|
||||||
delete fDisabledTwo;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TwoStateDrawButton::ResizeToPreferred()
|
|
||||||
{
|
|
||||||
if (fUpOne)
|
|
||||||
ResizeTo(fUpOne->Bounds().Width(), fUpOne->Bounds().Height());
|
|
||||||
else if (fDownOne)
|
|
||||||
ResizeTo(fDownOne->Bounds().Width(), fDownOne->Bounds().Height());
|
|
||||||
else if (fUpTwo)
|
|
||||||
ResizeTo(fUpTwo->Bounds().Width(),fUpTwo->Bounds().Height());
|
|
||||||
else if (fDownTwo)
|
|
||||||
ResizeTo(fDownTwo->Bounds().Width(), fDownTwo->Bounds().Height());
|
|
||||||
else if (fDisabledOne)
|
|
||||||
ResizeTo(fDisabledOne->Bounds().Width(), fDisabledOne->Bounds().Height());
|
|
||||||
else if(fDisabledTwo)
|
|
||||||
ResizeTo(fDisabledTwo->Bounds().Width(), fDisabledTwo->Bounds().Height());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TwoStateDrawButton::SetBitmaps(BBitmap *upone, BBitmap *downone, BBitmap *uptwo,
|
|
||||||
BBitmap *downtwo)
|
|
||||||
{
|
|
||||||
delete fUpOne;
|
|
||||||
delete fDownOne;
|
|
||||||
delete fUpTwo;
|
|
||||||
delete fDownTwo;
|
|
||||||
|
|
||||||
fUpOne = upone;
|
|
||||||
fDownOne = downone;
|
|
||||||
fUpTwo = uptwo;
|
|
||||||
fDownTwo = downtwo;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TwoStateDrawButton::SetBitmaps(const int32 state, BBitmap *up, BBitmap *down)
|
|
||||||
{
|
|
||||||
if (state == 0) {
|
|
||||||
delete fUpOne;
|
|
||||||
delete fDownOne;
|
|
||||||
fUpOne = up;
|
|
||||||
fDownOne = down;
|
|
||||||
} else {
|
|
||||||
delete fUpTwo;
|
|
||||||
delete fDownTwo;
|
|
||||||
fUpTwo = up;
|
|
||||||
fDownTwo = down;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TwoStateDrawButton::SetDisabled(BBitmap *disabledone, BBitmap *disabledtwo)
|
|
||||||
{
|
|
||||||
delete fDisabledOne;
|
|
||||||
delete fDisabledTwo;
|
|
||||||
|
|
||||||
fDisabledOne = disabledone;
|
|
||||||
fDisabledTwo = disabledtwo;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TwoStateDrawButton::MouseUp(BPoint pt)
|
|
||||||
{
|
|
||||||
BButton::MouseUp(pt);
|
|
||||||
fButtonState = fButtonState ? false : true;
|
|
||||||
Invalidate();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TwoStateDrawButton::SetState(int32 value)
|
|
||||||
{
|
|
||||||
if (fButtonState != value) {
|
|
||||||
fButtonState = (value == 0) ? false : true;
|
|
||||||
Invalidate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TwoStateDrawButton::Draw(BRect update)
|
|
||||||
{
|
|
||||||
if (fButtonState) {
|
|
||||||
if (!IsEnabled()) {
|
|
||||||
if (fDisabledTwo)
|
|
||||||
DrawBitmap(fDisabledTwo, BPoint(0,0));
|
|
||||||
else
|
|
||||||
StrokeRect(Bounds());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Value() == B_CONTROL_ON) {
|
|
||||||
if (fDownTwo)
|
|
||||||
DrawBitmap(fDownTwo, BPoint(0,0));
|
|
||||||
else
|
|
||||||
StrokeRect(Bounds());
|
|
||||||
} else {
|
|
||||||
if (fUpTwo)
|
|
||||||
DrawBitmap(fUpTwo, BPoint(0,0));
|
|
||||||
else
|
|
||||||
StrokeRect(Bounds());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!IsEnabled()) {
|
|
||||||
if (fDisabledOne)
|
|
||||||
DrawBitmap(fDisabledOne, BPoint(0,0));
|
|
||||||
else
|
|
||||||
StrokeRect(Bounds());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Value() == B_CONTROL_ON) {
|
|
||||||
if (fDownOne)
|
|
||||||
DrawBitmap(fDownOne, BPoint(0,0));
|
|
||||||
else
|
|
||||||
StrokeRect(Bounds());
|
|
||||||
} else {
|
|
||||||
if (fUpOne)
|
|
||||||
DrawBitmap(fUpOne, BPoint(0,0));
|
|
||||||
else
|
|
||||||
StrokeRect(Bounds());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,51 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2006-2007, Haiku, Inc.
|
|
||||||
* Distributed under the terms of the MIT license.
|
|
||||||
*
|
|
||||||
* Author:
|
|
||||||
* DarkWyrm <bpmagic@columbus.rr.com>
|
|
||||||
*/
|
|
||||||
#ifndef _TWOSTATE_DRAWBUTTON_H
|
|
||||||
#define _TWOSTATE_DRAWBUTTON_H
|
|
||||||
|
|
||||||
|
|
||||||
#include <Bitmap.h>
|
|
||||||
#include <Button.h>
|
|
||||||
#include <View.h>
|
|
||||||
#include <Window.h>
|
|
||||||
|
|
||||||
|
|
||||||
class TwoStateDrawButton : public BButton {
|
|
||||||
public:
|
|
||||||
TwoStateDrawButton(BRect frame, const char *name, BBitmap *upone,
|
|
||||||
BBitmap *downone, BBitmap *uptwo, BBitmap *downtwo,
|
|
||||||
BMessage *msg, const int32 &resize, const int32 &flags);
|
|
||||||
|
|
||||||
~TwoStateDrawButton();
|
|
||||||
|
|
||||||
void Draw(BRect update);
|
|
||||||
|
|
||||||
void SetBitmaps(BBitmap *upone, BBitmap *downone, BBitmap *uptwo,
|
|
||||||
BBitmap *downtwo);
|
|
||||||
|
|
||||||
void SetBitmaps(const int32 state, BBitmap *up, BBitmap *down);
|
|
||||||
void ResizeToPreferred();
|
|
||||||
void SetDisabled(BBitmap *disabledone, BBitmap *disabledtwo);
|
|
||||||
void MouseUp(BPoint pt);
|
|
||||||
|
|
||||||
int32 GetState() { return fButtonState ? 1 : 0; };
|
|
||||||
void SetState(int32 value);
|
|
||||||
|
|
||||||
private:
|
|
||||||
BBitmap *fUpOne,
|
|
||||||
*fDownOne,
|
|
||||||
*fUpTwo,
|
|
||||||
*fDownTwo,
|
|
||||||
*fDisabledOne,
|
|
||||||
*fDisabledTwo;
|
|
||||||
|
|
||||||
bool fButtonState;
|
|
||||||
// true if in state two
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // _TWOSTATE_DRAWBUTTON_H
|
|
|
@ -1,37 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2009, Haiku.
|
|
||||||
* Distributed under the terms of the MIT License.
|
|
||||||
*
|
|
||||||
* Authors:
|
|
||||||
* Stephan Aßmus, superstippi@gmx.de
|
|
||||||
* Jonas Sundström, jonas@kirilla.com
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "VolumeSlider.h"
|
|
||||||
|
|
||||||
|
|
||||||
VolumeSlider::VolumeSlider(BRect frame, const char* name, int32 minValue,
|
|
||||||
int32 maxValue, BMessage* message, BHandler* target)
|
|
||||||
:
|
|
||||||
BSlider(frame, name, NULL, message, minValue, maxValue)
|
|
||||||
{
|
|
||||||
SetTarget(target);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
VolumeSlider::~VolumeSlider()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
VolumeSlider::SetValue(int32 value)
|
|
||||||
{
|
|
||||||
if (value == Value())
|
|
||||||
return;
|
|
||||||
|
|
||||||
BSlider::SetValue(value);
|
|
||||||
Invoke();
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2009, Haiku.
|
|
||||||
* Distributed under the terms of the MIT License.
|
|
||||||
*
|
|
||||||
* Authors:
|
|
||||||
* Stephan Aßmus, superstippi@gmx.de
|
|
||||||
* Jonas Sundström, jonas@kirilla.com
|
|
||||||
*/
|
|
||||||
#ifndef VOLUME_SLIDER_H
|
|
||||||
#define VOLUME_SLIDER_H
|
|
||||||
|
|
||||||
|
|
||||||
#include <Slider.h>
|
|
||||||
|
|
||||||
|
|
||||||
class VolumeSlider : public BSlider {
|
|
||||||
public:
|
|
||||||
VolumeSlider(BRect frame, const char* name,
|
|
||||||
int32 minValue, int32 maxValue,
|
|
||||||
BMessage* message = NULL,
|
|
||||||
BHandler* target = NULL);
|
|
||||||
|
|
||||||
virtual ~VolumeSlider();
|
|
||||||
virtual void SetValue(int32 value);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // VOLUME_SLIDER_H
|
|
||||||
|
|
Loading…
Reference in New Issue