Made volume slider work

This commit is contained in:
bjorn.olievier 2008-04-07 21:47:18 +00:00
parent b976747024
commit 3eb803a4f3
4 changed files with 33 additions and 22 deletions

View File

@ -60,6 +60,7 @@ public: void Start(const utfstring path);
public: void Stop(size_t idx);
public: void ChangeVolume(float volume);
public: float Volume() const { return currVolume; };
public: size_t NumOfStreams() const;
public: AudioStreamOverview StreamsOverview() const;

View File

@ -62,6 +62,10 @@ void TransportController::OnViewCreated()
this->transportView.stopButton->Pressed.connect(
this, &TransportController::OnStopPressed);
this->transportView.volumeSlider->Repositioned.connect(
this, &TransportController::OnVolumeSliderChange);
this->transportView.volumeSlider->SetPosition(transport.Volume()*100);
}
void TransportController::OnViewResized(Size size)
@ -77,3 +81,8 @@ void TransportController::OnStopPressed()
{
transport.Stop(0);
}
void TransportController::OnVolumeSliderChange()
{
transport.ChangeVolume(transportView.volumeSlider->Position()/100.0f);
}

View File

@ -63,6 +63,7 @@ protected: musik::core::audio::Transport transport;
protected: void OnPlayPressed();
protected: void OnStopPressed();
protected: void OnVolumeSliderChange();
};
//////////////////////////////////////////////////////////////////////////////

View File

@ -71,29 +71,29 @@ void TransportView::OnCreated()
this->stopButton->Resize(50, 28);
this->nextButton->Resize(50, 28);
// now playingbox
FontRef boldFont(new win32cpp::Font());
boldFont->SetBold(true);
//
BoxLayout* nowPlayingBox = new BoxLayout(BoxHorizontal);
Frame* nowPlayingFrame = topRowBox->AddChild(
new Frame(nowPlayingBox, FramePadding(6, 0, 0, 0)));
//
nowPlayingBox->AddChild(new Label(_T("Now playing ")));
this->titleLabel = nowPlayingBox->AddChild(new Label(_T("Song Title")));
nowPlayingBox->AddChild(new Label(_T(" by ")));
this->artistLabel = nowPlayingBox->AddChild(new Label(_T("Artist Name")));
//
this->titleLabel->SetFont(boldFont);
this->artistLabel->SetFont(boldFont);
nowPlayingBox->SetSpacing(0);
nowPlayingBox->ResizeToMinimumSize();
//
topRowBox->SetChildFill(nowPlayingFrame);
topRowBox->SetFlexibleChild(nowPlayingFrame);
// now playingbox
FontRef boldFont(new win32cpp::Font());
boldFont->SetBold(true);
//
BoxLayout* nowPlayingBox = new BoxLayout(BoxHorizontal);
Frame* nowPlayingFrame = topRowBox->AddChild(
new Frame(nowPlayingBox, FramePadding(6, 0, 0, 0)));
//
nowPlayingBox->AddChild(new Label(_T("Now playing ")));
this->titleLabel = nowPlayingBox->AddChild(new Label(_T("Song Title")));
nowPlayingBox->AddChild(new Label(_T(" by ")));
this->artistLabel = nowPlayingBox->AddChild(new Label(_T("Artist Name")));
//
this->titleLabel->SetFont(boldFont);
this->artistLabel->SetFont(boldFont);
nowPlayingBox->SetSpacing(0);
nowPlayingBox->ResizeToMinimumSize();
//
topRowBox->SetChildFill(nowPlayingFrame);
topRowBox->SetFlexibleChild(nowPlayingFrame);
this->playbackSlider = topRowBox->AddChild(new Trackbar());
this->playbackSlider->Resize(100, 28);
this->volumeSlider = topRowBox->AddChild(new Trackbar());
this->volumeSlider->Resize(100, 28);
// bottom row ----------
BoxLayout* playbackBox = new BoxLayout();