From 3eb803a4f34a56a0e23cc0dd43b16bf0f42c54c8 Mon Sep 17 00:00:00 2001 From: "bjorn.olievier" Date: Mon, 7 Apr 2008 21:47:18 +0000 Subject: [PATCH] Made volume slider work --- src/core/audio/Transport.h | 1 + src/cube/TransportController.cpp | 9 +++++++ src/cube/TransportController.hpp | 1 + src/cube/TransportView.cpp | 44 ++++++++++++++++---------------- 4 files changed, 33 insertions(+), 22 deletions(-) diff --git a/src/core/audio/Transport.h b/src/core/audio/Transport.h index 0d006d4dd..3b486051e 100644 --- a/src/core/audio/Transport.h +++ b/src/core/audio/Transport.h @@ -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; diff --git a/src/cube/TransportController.cpp b/src/cube/TransportController.cpp index b23a2e45f..ce97ebd4f 100644 --- a/src/cube/TransportController.cpp +++ b/src/cube/TransportController.cpp @@ -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); +} diff --git a/src/cube/TransportController.hpp b/src/cube/TransportController.hpp index c722d4eb2..0cc478ec0 100644 --- a/src/cube/TransportController.hpp +++ b/src/cube/TransportController.hpp @@ -63,6 +63,7 @@ protected: musik::core::audio::Transport transport; protected: void OnPlayPressed(); protected: void OnStopPressed(); +protected: void OnVolumeSliderChange(); }; ////////////////////////////////////////////////////////////////////////////// diff --git a/src/cube/TransportView.cpp b/src/cube/TransportView.cpp index fa3394f11..129cb846f 100644 --- a/src/cube/TransportView.cpp +++ b/src/cube/TransportView.cpp @@ -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();