mirror of
https://github.com/clangen/musikcube.git
synced 2025-01-01 17:58:29 +00:00
Fixed: Bug reading from value "path" instead of URL() in tagreader.
Added: Open URL menu option (some window bug left though). Added: Documentation for some audioengine classes. Fixed: Some bugs in MultiLibraryList and PlaybackQueue.
This commit is contained in:
parent
605d66ae72
commit
12f9bcd774
@ -80,20 +80,20 @@ bool DSPEcho::ProcessBuffers(const IBuffer *inputBuffer,IBuffer *outputBuffer){
|
||||
long internalBufferSize(this->channels*this->bufferSampleSize);
|
||||
|
||||
long echo1distance(internalBufferSize-((long)(0.3*(double)this->sampleRate))*this->channels);
|
||||
long echo2distance(internalBufferSize-((long)(0.6*(double)this->sampleRate))*this->channels);
|
||||
long echo2distance(internalBufferSize-((long)(0.2*(double)this->sampleRate))*this->channels);
|
||||
|
||||
for(long i(0);i<bufferLength;++i){
|
||||
float inSample(inBuffer[i]);
|
||||
float outSample(inSample);
|
||||
//add a 0.5 of 0.3 seconds away
|
||||
outSample += 0.5f*this->internalBuffer[(this->bufferPosition+echo1distance)%internalBufferSize];
|
||||
//outSample += 0.5f*this->internalBuffer[(this->bufferPosition+echo1distance)%internalBufferSize];
|
||||
//add a 0.2 of 0.6 seconds away
|
||||
outSample += 0.2f*this->internalBuffer[(this->bufferPosition+echo2distance)%internalBufferSize];
|
||||
|
||||
// set the out buffer
|
||||
outBuffer[i] = outSample;
|
||||
// Save the insample to internal buffer
|
||||
this->internalBuffer[this->bufferPosition] = inSample;
|
||||
this->internalBuffer[this->bufferPosition] = outSample;
|
||||
this->bufferPosition = (this->bufferPosition+1)%internalBufferSize;
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,7 @@ bool TagReaderTaglib::GetOGGTag(musik::core::ITrack *track){
|
||||
|
||||
|
||||
bool TagReaderTaglib::GetGenericTag(musik::core::ITrack *track){
|
||||
TagLib::FileRef oFile(track->GetValue("path"));
|
||||
TagLib::FileRef oFile(track->URL());
|
||||
if(!oFile.isNull()){
|
||||
TagLib::Tag *tag = oFile.tag();
|
||||
TagLib::AudioProperties *oAudioProperties = oFile.audioProperties();
|
||||
@ -178,7 +178,7 @@ bool TagReaderTaglib::GetID3v2Tag(musik::core::ITrack *track){
|
||||
TagLib::ID3v2::FrameFactory::instance()->setDefaultTextEncoding(TagLib::String::UTF8);
|
||||
#endif
|
||||
|
||||
TagLib::MPEG::File oFile(track->GetValue("path"));
|
||||
TagLib::MPEG::File oFile(track->URL());
|
||||
TagLib::ID3v2::Tag *oTagv2 = oFile.ID3v2Tag();
|
||||
if(oTagv2){
|
||||
|
||||
|
@ -123,17 +123,11 @@ void GenericTrack::SetThumbnail(const char *data,long size){
|
||||
}
|
||||
|
||||
const utfchar* GenericTrack::URI(){
|
||||
if(!this->uri.empty()){
|
||||
return this->uri.c_str();
|
||||
}
|
||||
return NULL;
|
||||
return this->uri.c_str();
|
||||
}
|
||||
|
||||
const utfchar* GenericTrack::URL(){
|
||||
if(!this->uri.empty()){
|
||||
return this->uri.c_str();
|
||||
}
|
||||
return NULL;
|
||||
return this->uri.c_str();
|
||||
}
|
||||
|
||||
Track::MetadataIteratorRange GenericTrack::GetValues(const char* metakey){
|
||||
|
@ -246,7 +246,7 @@ void PlaybackQueue::GetAllTrackMetadata(TrackPtr track){
|
||||
this->metadataQuery.Clear();
|
||||
this->metadataQuery.RequestAllMetakeys();
|
||||
this->metadataQuery.RequestTrack(track);
|
||||
LibraryPtr library = this->currentTrack->Library();
|
||||
LibraryPtr library = track->Library();
|
||||
if(library){
|
||||
library->AddQuery(this->metadataQuery,musik::core::Query::Wait|musik::core::Query::AutoCallback|musik::core::Query::UnCanceable|musik::core::Query::Prioritize);
|
||||
}
|
||||
|
@ -35,6 +35,10 @@
|
||||
|
||||
using namespace musik::core::audio;
|
||||
|
||||
//////////////////////////////////////////
|
||||
///\brief
|
||||
///Constructor
|
||||
//////////////////////////////////////////
|
||||
Buffer::Buffer(void)
|
||||
:buffer(NULL)
|
||||
,sampleSize(0)
|
||||
@ -44,45 +48,91 @@ Buffer::Buffer(void)
|
||||
{
|
||||
}
|
||||
|
||||
//////////////////////////////////////////
|
||||
///\brief
|
||||
///Destructor
|
||||
//////////////////////////////////////////
|
||||
Buffer::~Buffer(void)
|
||||
{
|
||||
delete this->buffer;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////
|
||||
///\brief
|
||||
///Create a new Buffer
|
||||
//////////////////////////////////////////
|
||||
BufferPtr Buffer::Create(){
|
||||
return BufferPtr(new Buffer());
|
||||
}
|
||||
|
||||
//////////////////////////////////////////
|
||||
///\brief
|
||||
///Get the samplerate of the buffer
|
||||
//////////////////////////////////////////
|
||||
long Buffer::SampleRate() const{
|
||||
return this->sampleRate;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////
|
||||
///\brief
|
||||
///Set the buffers samplerate
|
||||
//////////////////////////////////////////
|
||||
void Buffer::SetSampleRate(long sampleRate){
|
||||
this->sampleRate = sampleRate;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////
|
||||
///\brief
|
||||
///Get the number of channels of the buffer
|
||||
//////////////////////////////////////////
|
||||
int Buffer::Channels() const{
|
||||
return this->channels;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////
|
||||
///\brief
|
||||
///Set the number of channels of the buffer
|
||||
//////////////////////////////////////////
|
||||
void Buffer::SetChannels(int channels){
|
||||
this->channels = channels;
|
||||
this->ResizeBuffer();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////
|
||||
///\brief
|
||||
///Get the pointer to the real buffer.
|
||||
///
|
||||
///The pointer may change when you set any of the buffers
|
||||
///properties like samplerate, samples and channels
|
||||
//////////////////////////////////////////
|
||||
float* Buffer::BufferPointer() const{
|
||||
return this->buffer;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////
|
||||
///\brief
|
||||
///Get the number of samples in the buffer
|
||||
///
|
||||
///To clairify, one sample = one sample for each channel
|
||||
///and that means that one sample = sizeof(float)*channels bytes big
|
||||
//////////////////////////////////////////
|
||||
long Buffer::Samples() const{
|
||||
return this->sampleSize;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////
|
||||
///\brief
|
||||
///Set the number of samples in the buffer
|
||||
//////////////////////////////////////////
|
||||
void Buffer::SetSamples(long samples){
|
||||
this->sampleSize = samples;
|
||||
this->ResizeBuffer();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////
|
||||
///\brief
|
||||
///Copies all the formats from one buffer to another
|
||||
//////////////////////////////////////////
|
||||
void Buffer::CopyFormat(BufferPtr fromBuffer){
|
||||
this->sampleSize = fromBuffer->Samples();
|
||||
this->channels = fromBuffer->Channels();
|
||||
@ -90,6 +140,10 @@ void Buffer::CopyFormat(BufferPtr fromBuffer){
|
||||
this->ResizeBuffer();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////
|
||||
///\brief
|
||||
///Resize the internal buffer to match the formats
|
||||
//////////////////////////////////////////
|
||||
void Buffer::ResizeBuffer(){
|
||||
long requiredBufferSize( this->sampleSize * this->channels );
|
||||
if(requiredBufferSize>this->internalBufferSize){
|
||||
@ -105,14 +159,26 @@ void Buffer::ResizeBuffer(){
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////
|
||||
///\brief
|
||||
///How many bytes does this object take
|
||||
//////////////////////////////////////////
|
||||
long Buffer::Bytes() const{
|
||||
return this->internalBufferSize*sizeof(float);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////
|
||||
///\brief
|
||||
///What position in a track is this buffer (in seconds)
|
||||
//////////////////////////////////////////
|
||||
double Buffer::Position() const{
|
||||
return this->position;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////
|
||||
///\brief
|
||||
///Append another buffer to this one
|
||||
//////////////////////////////////////////
|
||||
bool Buffer::Append(BufferPtr appendBuffer){
|
||||
if(this->SampleRate()==appendBuffer->SampleRate() && this->Channels()==appendBuffer->Channels()){
|
||||
long newBufferSize = (this->Samples()+appendBuffer->Samples())*this->channels;
|
||||
|
@ -45,7 +45,12 @@ class Buffer;
|
||||
class Stream;
|
||||
typedef boost::shared_ptr<Buffer> BufferPtr;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////
|
||||
///\brief
|
||||
///Buffer is the ony implementation of the IBuffer and is used
|
||||
///in the audioengine to pass along the raw audio data
|
||||
//////////////////////////////////////////
|
||||
class Buffer : public IBuffer {
|
||||
public:
|
||||
static BufferPtr Create();
|
||||
|
@ -40,11 +40,45 @@
|
||||
namespace musik { namespace core { namespace audio {
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////
|
||||
///\brief
|
||||
///The main interface for a analyzer plugin
|
||||
///
|
||||
///A analyzer plugin will be executed from the Indexer
|
||||
///after all tags has been read. The plugin will first be
|
||||
///called with the Start method, and if that method returns true
|
||||
///a audio::Stream will be opened and the whole track will be
|
||||
///decoded and passed on to the Analyze method (or until the Analyze method
|
||||
///returns false). Finally the End method will be called where the
|
||||
///the plugin can make changes to the tracks metadata.
|
||||
//////////////////////////////////////////
|
||||
class IAnalyzer {
|
||||
public:
|
||||
//////////////////////////////////////////
|
||||
///\brief
|
||||
///Destroy the object
|
||||
//////////////////////////////////////////
|
||||
virtual void Destroy() = 0;
|
||||
|
||||
//////////////////////////////////////////
|
||||
///\brief
|
||||
///Start analyzing the track. Returns true if
|
||||
///the analyzing should continue.
|
||||
//////////////////////////////////////////
|
||||
virtual bool Start(musik::core::ITrack *track) = 0;
|
||||
|
||||
//////////////////////////////////////////
|
||||
///\brief
|
||||
///Analyze a buffer
|
||||
//////////////////////////////////////////
|
||||
virtual bool Analyze(musik::core::ITrack *track,IBuffer *buffer) = 0;
|
||||
|
||||
//////////////////////////////////////////
|
||||
///\brief
|
||||
///Called when the whole track has been analyzed.
|
||||
///If this call makes changes to the track it should
|
||||
///return true.
|
||||
//////////////////////////////////////////
|
||||
virtual bool End(musik::core::ITrack *track) = 0;
|
||||
};
|
||||
|
||||
|
@ -40,13 +40,59 @@ namespace musik { namespace core { namespace audio {
|
||||
|
||||
class IBuffer {
|
||||
public:
|
||||
|
||||
//////////////////////////////////////////
|
||||
///\brief
|
||||
///Get the samplerate of the buffer
|
||||
//////////////////////////////////////////
|
||||
virtual long SampleRate() const = 0;
|
||||
|
||||
//////////////////////////////////////////
|
||||
///\brief
|
||||
///Set the buffers samplerate
|
||||
//////////////////////////////////////////
|
||||
virtual void SetSampleRate(long sampleRate) = 0;
|
||||
|
||||
//////////////////////////////////////////
|
||||
///\brief
|
||||
///Get the number of channels of the buffer
|
||||
//////////////////////////////////////////
|
||||
virtual int Channels() const = 0;
|
||||
|
||||
//////////////////////////////////////////
|
||||
///\brief
|
||||
///Set the number of channels of the buffer
|
||||
//////////////////////////////////////////
|
||||
virtual void SetChannels(int channels) = 0;
|
||||
|
||||
//////////////////////////////////////////
|
||||
///\brief
|
||||
///Get the pointer to the real buffer.
|
||||
///
|
||||
///The pointer may change when you set any of the buffers
|
||||
///properties like samplerate, samples and channels
|
||||
//////////////////////////////////////////
|
||||
virtual float* BufferPointer() const = 0;
|
||||
|
||||
//////////////////////////////////////////
|
||||
///\brief
|
||||
///Get the number of samples in the buffer
|
||||
///
|
||||
///To clairify, one sample = one sample for each channel
|
||||
///and that means that one sample = sizeof(float)*channels bytes big
|
||||
//////////////////////////////////////////
|
||||
virtual long Samples() const = 0;
|
||||
|
||||
//////////////////////////////////////////
|
||||
///\brief
|
||||
///Set the number of samples in the buffer
|
||||
//////////////////////////////////////////
|
||||
virtual void SetSamples(long samples) = 0;
|
||||
|
||||
//////////////////////////////////////////
|
||||
///\brief
|
||||
///How many bytes does this object take
|
||||
//////////////////////////////////////////
|
||||
virtual long Bytes() const = 0;
|
||||
};
|
||||
|
||||
|
@ -39,9 +39,31 @@
|
||||
namespace musik { namespace core { namespace audio {
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////
|
||||
///\brief
|
||||
///Main interface for dsp plugins.
|
||||
///Each instance equals a track.
|
||||
//////////////////////////////////////////
|
||||
class IDSP {
|
||||
public:
|
||||
//////////////////////////////////////////
|
||||
///\brief
|
||||
///Destroy this object
|
||||
//////////////////////////////////////////
|
||||
virtual void Destroy() = 0;
|
||||
|
||||
//////////////////////////////////////////
|
||||
///\brief
|
||||
///Process the buffer through the dsp plugin
|
||||
///
|
||||
///\param inputBuffer
|
||||
///Buffer to process
|
||||
///
|
||||
///\param outputBuffer
|
||||
///Empty buffer that you can write the processed inputBuffer to
|
||||
///
|
||||
///\return true if the buffer has been processed to the new outputBuffer.
|
||||
//////////////////////////////////////////
|
||||
virtual bool ProcessBuffers(const IBuffer *inputBuffer,IBuffer *outputBuffer) = 0;
|
||||
};
|
||||
|
||||
|
@ -39,10 +39,30 @@
|
||||
namespace musik { namespace core { namespace audio {
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////
|
||||
///\brief
|
||||
///Interface for decoder plugins to be able to create
|
||||
///instances of IDecoder
|
||||
//////////////////////////////////////////
|
||||
class IDecoderFactory{
|
||||
public:
|
||||
//////////////////////////////////////////
|
||||
///\brief
|
||||
///Create a instance of the decoder
|
||||
//////////////////////////////////////////
|
||||
virtual IDecoder* CreateDecoder() = 0;
|
||||
|
||||
//////////////////////////////////////////
|
||||
///\brief
|
||||
///Destroy the object
|
||||
//////////////////////////////////////////
|
||||
virtual void Destroy() = 0;
|
||||
|
||||
//////////////////////////////////////////
|
||||
///\brief
|
||||
///Can this plugin handle this kind of filetype?
|
||||
///The "type" can either be a file extension or a mimetype
|
||||
//////////////////////////////////////////
|
||||
virtual bool CanHandle(const utfchar* type) const = 0;
|
||||
|
||||
};
|
||||
|
@ -54,9 +54,22 @@ class IOutput{
|
||||
//////////////////////////////////////////
|
||||
virtual void Destroy() = 0;
|
||||
|
||||
//virtual void Initialize(IPlayer *player) = 0;
|
||||
//////////////////////////////////////////
|
||||
///\brief
|
||||
///Pause the current output
|
||||
//////////////////////////////////////////
|
||||
virtual void Pause() = 0;
|
||||
|
||||
//////////////////////////////////////////
|
||||
///\brief
|
||||
///resume a paused output
|
||||
//////////////////////////////////////////
|
||||
virtual void Resume() = 0;
|
||||
|
||||
//////////////////////////////////////////
|
||||
///\brief
|
||||
///Set the volume on this output
|
||||
//////////////////////////////////////////
|
||||
virtual void SetVolume(double volume) = 0;
|
||||
|
||||
//////////////////////////////////////////
|
||||
@ -64,7 +77,17 @@ class IOutput{
|
||||
///Clear internal buffers. Used when setting new position in a stream
|
||||
//////////////////////////////////////////
|
||||
virtual void ClearBuffers() = 0;
|
||||
|
||||
//////////////////////////////////////////
|
||||
///\brief
|
||||
///Release all buffers that has already passed through the output.
|
||||
//////////////////////////////////////////
|
||||
virtual void ReleaseBuffers() = 0;
|
||||
|
||||
//////////////////////////////////////////
|
||||
///\brief
|
||||
///Play this buffer
|
||||
//////////////////////////////////////////
|
||||
virtual bool PlayBuffer(IBuffer *buffer,IPlayer *player) = 0;
|
||||
|
||||
};
|
||||
|
@ -39,9 +39,23 @@
|
||||
namespace musik { namespace core { namespace audio {
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////
|
||||
///\brief
|
||||
///Interface for the audio::Player to make IOuput plugins be able to make callbacks
|
||||
//////////////////////////////////////////
|
||||
class IPlayer{
|
||||
public:
|
||||
//////////////////////////////////////////
|
||||
///\brief
|
||||
///Release the specific buffer from the output
|
||||
//////////////////////////////////////////
|
||||
virtual void ReleaseBuffer(IBuffer *buffer) = 0;
|
||||
|
||||
//////////////////////////////////////////
|
||||
///\brief
|
||||
///Notifies the Player that there may be buffer
|
||||
///ready to be released in the output plugin.
|
||||
//////////////////////////////////////////
|
||||
virtual void Notify() = 0;
|
||||
};
|
||||
|
||||
|
@ -110,10 +110,10 @@ musik::core::TrackPtr MultiLibraryList::TrackWithMetadata(long position){
|
||||
///Get the current track
|
||||
//////////////////////////////////////////
|
||||
musik::core::TrackPtr MultiLibraryList::CurrentTrack(){
|
||||
if(this->currentPosition==-1 && this->Size()>0){
|
||||
/* if(this->currentPosition==-1 && this->Size()>0){
|
||||
this->SetPosition(0);
|
||||
}
|
||||
|
||||
*/
|
||||
return (*this)[this->currentPosition];
|
||||
}
|
||||
|
||||
@ -271,6 +271,9 @@ bool MultiLibraryList::operator +=(musik::core::TrackPtr track){
|
||||
}
|
||||
|
||||
this->tracklist.push_back(track->Copy());
|
||||
|
||||
this->TracklistChanged(false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,8 @@
|
||||
#include <cube/MainMenuController.hpp>
|
||||
#include <cube/dialog/AddLibraryController.hpp>
|
||||
#include <cube/dialog/HelpAboutController.hpp>
|
||||
#include <cube/dialog/OpenURLController.hpp>
|
||||
|
||||
#include <win32cpp/Application.hpp>
|
||||
#include <win32cpp/TopLevelWindow.hpp>
|
||||
#include <boost/format.hpp>
|
||||
@ -74,7 +76,8 @@ void MainMenuController::ConnectMenuHandlers()
|
||||
this->helpAbout->Activated.connect(this, &MainMenuController::OnHelpAbout);
|
||||
this->fileAddLibraryLocal->Activated.connect(this,&MainMenuController::OnAddLibraryLocal);
|
||||
this->fileAddLibraryRemote->Activated.connect(this,&MainMenuController::OnAddLibraryRemote);
|
||||
this->fileNewPlaylist->Activated.connect(this,&MainMenuController::OnNewPlaylist);
|
||||
// this->fileNewPlaylist->Activated.connect(this,&MainMenuController::OnNewPlaylist);
|
||||
this->fileOpenURL->Activated.connect(this,&MainMenuController::OnOpenURL);
|
||||
}
|
||||
|
||||
void MainMenuController::OnFileExit(MenuItemRef menuItem)
|
||||
@ -113,48 +116,22 @@ void MainMenuController::OnHelpAbout(MenuItemRef menuItem)
|
||||
aboutDialog.ShowModal(&this->mainWindow);
|
||||
|
||||
return;
|
||||
|
||||
// randomize the contribuitors' names
|
||||
std::vector<uistring> names;
|
||||
names.push_back(_T(" - avatar\n"));
|
||||
names.push_back(_T(" - bjorn\n"));
|
||||
names.push_back(_T(" - doep\n"));
|
||||
names.push_back(_T(" - naaina\n"));
|
||||
names.push_back(_T(" - Jooles\n"));
|
||||
|
||||
std::random_shuffle(names.begin(), names.end());
|
||||
|
||||
uistring randomNames;
|
||||
for (std::vector<uistring>::iterator it = names.begin(); it != names.end(); it++)
|
||||
{
|
||||
randomNames += *it;
|
||||
}
|
||||
|
||||
uistring message =
|
||||
_T("mC2 are copyright (c) mC2 Team 2007-2008\n")
|
||||
_T("win32cpp are copyright (c) Casey Langen 2007-2008\n\n")
|
||||
_T("Credits:\n")
|
||||
_T("%1%\n")
|
||||
_T("mC2 wouldn't be possible without these file projects:\n")
|
||||
_T(" - tuniac (http://tuniac.sf.net)\n")
|
||||
_T(" - boost (http://www.boost.org)\n")
|
||||
_T(" - sqlite3 (http://www.sqlite.org)\n")
|
||||
_T(" - taglib (http://developer.kde.org/~wheeler/taglib)\n\n")
|
||||
_T("Version 2 developer milestone 1");
|
||||
|
||||
message = (boost::wformat(message.c_str()) % randomNames).str();
|
||||
|
||||
::MessageBox(
|
||||
this->mainWindow.Handle(),
|
||||
message.c_str(),
|
||||
_T("mC2 - About"),
|
||||
MB_ICONINFORMATION | MB_OK);
|
||||
}
|
||||
|
||||
void MainMenuController::OnNewPlaylist(MenuItemRef menuItem){
|
||||
musik::core::MessageQueue::SendMessage("NewPlaylist");
|
||||
}
|
||||
|
||||
void MainMenuController::OnOpenURL(MenuItemRef menuItem){
|
||||
win32cpp::TopLevelWindow popupDialog(_(_T("Open URL")));
|
||||
popupDialog.SetMinimumSize(Size(300, 150));
|
||||
|
||||
dialog::OpenURLController openURL(popupDialog);
|
||||
|
||||
popupDialog.ShowModal(TopLevelWindow::FindFromAncestor(&this->mainWindow));
|
||||
|
||||
}
|
||||
|
||||
|
||||
MenuRef MainMenuController::CreateMenu()
|
||||
{
|
||||
@ -180,7 +157,9 @@ MenuRef MainMenuController::CreateMenu()
|
||||
this->fileAddLibraryRemote = addLibrarySubmenu->Items().Append(MenuItem::Create(_(_T("&Remote library"))));
|
||||
addLibraryMenu->SetSubMenu(addLibrarySubmenu);
|
||||
|
||||
this->fileNewPlaylist = fileItems.Append(MenuItem::Create(_(_T("&New Playlist"))));
|
||||
//this->fileNewPlaylist = fileItems.Append(MenuItem::Create(_(_T("&New Playlist"))));
|
||||
|
||||
this->fileOpenURL = fileItems.Append(MenuItem::Create(_(_T("Open &URL"))));
|
||||
|
||||
this->fileExit = fileItems.Append(MenuItem::Create(_(_T("E&xit"))));
|
||||
|
||||
|
@ -73,12 +73,14 @@ class MainMenuController: public EventHandler
|
||||
void OnAddLibraryLocal(MenuItemRef menuItem);
|
||||
void OnAddLibraryRemote(MenuItemRef menuItem);
|
||||
void OnNewPlaylist(MenuItemRef menuItem);
|
||||
void OnOpenURL(MenuItemRef menuItem);
|
||||
|
||||
private:
|
||||
TopLevelWindow& mainWindow;
|
||||
MenuRef mainMenu, fileMenu, helpMenu;
|
||||
MenuItemRef file, view, audio, tags, help;
|
||||
MenuItemRef fileExit, helpAbout, fileAddLibraryRemote, fileAddLibraryLocal, fileNewPlaylist;
|
||||
MenuItemRef fileExit, fileAddLibraryRemote, fileAddLibraryLocal, fileNewPlaylist, fileOpenFile, fileAppendFile, fileOpenURL;
|
||||
MenuItemRef helpAbout;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -514,6 +514,26 @@
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="OpenURL"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\dialog\OpenURLController.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\dialog\OpenURLController.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\dialog\OpenURLView.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\dialog\OpenURLView.hpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="support"
|
||||
|
89
src/cube/dialog/OpenURLController.cpp
Normal file
89
src/cube/dialog/OpenURLController.cpp
Normal file
@ -0,0 +1,89 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// License Agreement:
|
||||
//
|
||||
// The following are Copyright © 2009, Daniel Önnerby
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * 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.
|
||||
//
|
||||
// * Neither the name of the author nor the names of other contributors may
|
||||
// be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 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.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "pch.hpp"
|
||||
|
||||
#include <core/PlaybackQueue.h>
|
||||
#include <core/TrackFactory.h>
|
||||
|
||||
#include <cube/dialog/OpenURLController.hpp>
|
||||
|
||||
#include <win32cpp/Window.hpp>
|
||||
#include <win32cpp/Button.hpp>
|
||||
#include <win32cpp/EditView.hpp>
|
||||
#include <win32cpp/RedrawLock.hpp>
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
using namespace musik::cube::dialog;
|
||||
using namespace win32cpp;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
OpenURLController::OpenURLController(win32cpp::TopLevelWindow &mainWindow)
|
||||
:mainWindow(mainWindow)
|
||||
{
|
||||
this->view = new OpenURLView();
|
||||
this->mainWindow.AddChild(this->view);
|
||||
this->mainWindow.Resized.connect(this,&OpenURLController::OnResize);
|
||||
|
||||
this->view->Handle()
|
||||
? this->OnViewCreated(this->view)
|
||||
: this->view->Created.connect(this, &OpenURLController::OnViewCreated);
|
||||
|
||||
}
|
||||
|
||||
OpenURLController::~OpenURLController(){
|
||||
}
|
||||
|
||||
void OpenURLController::OnViewCreated(Window* window)
|
||||
{
|
||||
this->view->cancelButton->Pressed.connect(this,&OpenURLController::OnCancel);
|
||||
this->view->okButton->Pressed.connect(this,&OpenURLController::OnOK);
|
||||
}
|
||||
|
||||
void OpenURLController::OnCancel(win32cpp::Button* button){
|
||||
this->mainWindow.Close();
|
||||
}
|
||||
|
||||
void OpenURLController::OnOK(win32cpp::Button* button){
|
||||
(*musik::core::PlaybackQueue::Instance().NowPlayingTracklist()) += musik::core::TrackFactory::CreateTrack( this->view->url->Caption().c_str() );
|
||||
this->mainWindow.Close();
|
||||
}
|
||||
|
||||
void OpenURLController::OnResize(win32cpp::Window* window, win32cpp::Size size){
|
||||
win32cpp::RedrawLock redrawLock(this->view);
|
||||
this->view->Resize(this->mainWindow.ClientSize());
|
||||
}
|
77
src/cube/dialog/OpenURLController.hpp
Normal file
77
src/cube/dialog/OpenURLController.hpp
Normal file
@ -0,0 +1,77 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// License Agreement:
|
||||
//
|
||||
// The following are Copyright © 2009, Daniel Önnerby
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * 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.
|
||||
//
|
||||
// * Neither the name of the author nor the names of other contributors may
|
||||
// be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 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.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Forward declare
|
||||
namespace win32cpp{
|
||||
class Window;
|
||||
class Button;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <win32cpp/Types.hpp>
|
||||
#include <win32cpp/TopLevelWindow.hpp>
|
||||
|
||||
#include <cube/dialog/OpenURLView.hpp>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace musik { namespace cube { namespace dialog{
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class OpenURLController : public win32cpp::EventHandler{
|
||||
|
||||
public:
|
||||
OpenURLController(win32cpp::TopLevelWindow &mainWindow);
|
||||
~OpenURLController();
|
||||
|
||||
private:
|
||||
void OnViewCreated(win32cpp::Window* window);
|
||||
void OnCancel(win32cpp::Button* button);
|
||||
void OnOK(win32cpp::Button* button);
|
||||
void OnResize(win32cpp::Window* window, win32cpp::Size size);
|
||||
|
||||
win32cpp::TopLevelWindow &mainWindow;
|
||||
|
||||
OpenURLView *view;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
} } } // musik::cube::dialog
|
85
src/cube/dialog/OpenURLView.cpp
Normal file
85
src/cube/dialog/OpenURLView.cpp
Normal file
@ -0,0 +1,85 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// License Agreement:
|
||||
//
|
||||
// The following are Copyright © 2009, Daniel Önnerby
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * 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.
|
||||
//
|
||||
// * Neither the name of the author nor the names of other contributors may
|
||||
// be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 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.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "pch.hpp"
|
||||
#include <cube/dialog/OpenURLView.hpp>
|
||||
|
||||
#include <win32cpp/Label.hpp>
|
||||
#include <win32cpp/Button.hpp>
|
||||
#include <win32cpp/LinearLayout.hpp>
|
||||
#include <win32cpp/EditView.hpp>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
using namespace musik::cube::dialog;
|
||||
using namespace win32cpp;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
OpenURLView::OpenURLView()
|
||||
: Frame(NULL,WindowPadding(6))
|
||||
{
|
||||
}
|
||||
|
||||
void OpenURLView::OnCreated()
|
||||
{
|
||||
FontRef boldFont(Font::Create());
|
||||
boldFont->SetBold(true);
|
||||
|
||||
// Top Row layout
|
||||
LinearLayout* rowLayout = new LinearLayout(VerticalLayout,win32cpp::LayoutFillFill);
|
||||
|
||||
LinearLayout* firstRow = new LinearLayout(HorizontalLayout,win32cpp::LayoutFillFill);
|
||||
Label *label = firstRow->AddChild(new Label(_T("URL:") ));
|
||||
label->SetFont(boldFont);
|
||||
this->url = firstRow->AddChild(new EditView(_T("url"),win32cpp::LayoutFillFill ));
|
||||
rowLayout->AddChild(firstRow);
|
||||
|
||||
// Last rows column layout
|
||||
LinearLayout* bottomButtonLayout = new LinearLayout(HorizontalLayout);
|
||||
this->cancelButton = bottomButtonLayout->AddChild(new Button(_T("Cancel")));
|
||||
this->okButton = bottomButtonLayout->AddChild(new Button(_T("OK")));
|
||||
// this->cancelButton->Resize(60,20);
|
||||
// this->okButton->Resize(60,20);
|
||||
rowLayout->AddChild(bottomButtonLayout);
|
||||
bottomButtonLayout->SetLayoutAlignment(LayoutAlignRight);
|
||||
|
||||
this->AddChild(rowLayout);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
69
src/cube/dialog/OpenURLView.hpp
Normal file
69
src/cube/dialog/OpenURLView.hpp
Normal file
@ -0,0 +1,69 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// License Agreement:
|
||||
//
|
||||
// The following are Copyright © 2009, Daniel Önnerby
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * 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.
|
||||
//
|
||||
// * Neither the name of the author nor the names of other contributors may
|
||||
// be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 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.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#pragma once
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Forward declare
|
||||
namespace win32cpp{
|
||||
class Button;
|
||||
class EditView;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <win32cpp/Frame.hpp>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace musik { namespace cube { namespace dialog {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// forward
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class OpenURLView: public win32cpp::Frame{
|
||||
public:
|
||||
OpenURLView();
|
||||
|
||||
virtual void OnCreated();
|
||||
|
||||
win32cpp::Button *okButton, *cancelButton;
|
||||
win32cpp::EditView *url;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
} } } // musik::cube::dialog
|
||||
|
Loading…
Reference in New Issue
Block a user