mirror of
https://github.com/clangen/musikcube.git
synced 2025-03-29 19:20:28 +00:00
A few more prototype updates -- working transport buttons, fixed listview
styling, etc.
This commit is contained in:
parent
c71f5a5f10
commit
f7d660720c
@ -57,6 +57,7 @@ static ColumnRef sTitleColumn = ListView::Column::Create(_T("title"), 250);
|
||||
static ColumnRef sDurationColumn = ListView::Column::Create(_T("time"), 50, TextAlignment::TextAlignRight);
|
||||
static ColumnRef sAlbumColumn = ListView::Column::Create(_T("album"));
|
||||
static ColumnRef sArtistColumn = ListView::Column::Create(_T("artist"));
|
||||
static ColumnRef sEndColumn = ListView::Column::Create(_T(""), 35);
|
||||
|
||||
#define EDIT_VIEW_HEIGHT 22
|
||||
#define UPDATE_SEARCH_MESSAGE 1001
|
||||
@ -148,6 +149,8 @@ MainController::MainController(
|
||||
, playback(playback)
|
||||
, library(library)
|
||||
, trackListDirty(true) {
|
||||
|
||||
playback.PlaybackEvent.connect(this, &MainController::OnPlaybackStateChanged);
|
||||
library->QueryCompleted.connect(this, &MainController::OnLibraryQueryCompleted);
|
||||
|
||||
this->trackListQuery.reset(new SearchTrackListQuery(library, ""));
|
||||
@ -157,12 +160,23 @@ MainController::MainController(
|
||||
this->editView->Changed.connect(this, &MainController::OnSearchEditChanged);
|
||||
|
||||
this->trackListView = this->mainWindow.AddChild(new ListView());
|
||||
this->trackListView->EnableStripedBackground(true);
|
||||
this->trackListView->RowActivated.connect(this, &MainController::OnTrackListRowActivated);
|
||||
this->trackListView->AddColumn(sNumberColumn);
|
||||
this->trackListView->AddColumn(sTitleColumn);
|
||||
this->trackListView->AddColumn(sAlbumColumn);
|
||||
this->trackListView->AddColumn(sArtistColumn);
|
||||
this->trackListView->AddColumn(sDurationColumn);
|
||||
this->trackListView->AddColumn(sEndColumn);
|
||||
|
||||
this->prevButton = this->mainWindow.AddChild(new Button(_T("prev")));
|
||||
this->prevButton->Pressed.connect(this, &MainController::OnTransportButtonClicked);
|
||||
|
||||
this->pauseButton = this->mainWindow.AddChild(new Button(_T("play")));
|
||||
this->pauseButton->Pressed.connect(this, &MainController::OnTransportButtonClicked);
|
||||
|
||||
this->nextButton = this->mainWindow.AddChild(new Button(_T("next")));
|
||||
this->nextButton->Pressed.connect(this, &MainController::OnTransportButtonClicked);
|
||||
|
||||
this->trackListModel = TrackListModel::Create(this->playback);
|
||||
this->trackListView->SetModel(this->trackListModel);
|
||||
@ -175,6 +189,8 @@ MainController::MainController(
|
||||
MainController::~MainController() {
|
||||
}
|
||||
|
||||
#define /*button width */ BW(x) x->WindowSize().width;
|
||||
|
||||
void MainController::Layout() {
|
||||
auto size = this->mainWindow.ClientSize();
|
||||
if (size.height > 0) {
|
||||
@ -186,9 +202,21 @@ void MainController::Layout() {
|
||||
this->editView->MoveTo(editX, padding);
|
||||
this->editView->Resize(editCx, EDIT_VIEW_HEIGHT);
|
||||
|
||||
int buttonCy = this->prevButton->WindowSize().height;
|
||||
int buttonY = size.height - buttonCy - padding;
|
||||
int transportCy = padding + buttonCy + padding;
|
||||
int buttonX = padding;
|
||||
|
||||
this->prevButton->MoveTo(buttonX, buttonY);
|
||||
buttonX += padding + BW(this->prevButton);
|
||||
this->pauseButton->MoveTo(buttonX, buttonY);
|
||||
buttonX += padding + BW(this->pauseButton);
|
||||
this->nextButton->MoveTo(buttonX, buttonY);
|
||||
buttonX += padding + BW(this->nextButton);
|
||||
|
||||
int listY = padding + EDIT_VIEW_HEIGHT + padding;
|
||||
int tracksCx = size.width;
|
||||
int listCy = size.height - listY;
|
||||
int listCy = size.height - listY - transportCy;
|
||||
|
||||
this->trackListView->MoveTo(0, listY);
|
||||
this->trackListView->Resize(tracksCx, listCy);
|
||||
@ -233,3 +261,37 @@ void MainController::OnSearchEditChanged(win32cpp::EditView* editView) {
|
||||
queue.Debounce(Message::Create(this, UPDATE_SEARCH_MESSAGE, 0, 0), UPDATE_SEARCH_DEBOUNCE_MS);
|
||||
}
|
||||
}
|
||||
|
||||
void MainController::OnTransportButtonClicked(win32cpp::Button* button) {
|
||||
if (button == this->prevButton) {
|
||||
playback.Previous();
|
||||
}
|
||||
else if (button == this->pauseButton) {
|
||||
if (playback.GetPlaybackState() == musik::core::sdk::PlaybackStopped) {
|
||||
std::vector<int> selected = this->trackListView->SelectedRows();
|
||||
if (selected.size()) {
|
||||
this->OnTrackListRowActivated(this->trackListView, selected[0]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
playback.PauseOrResume();
|
||||
}
|
||||
}
|
||||
else if (button == this->nextButton) {
|
||||
playback.Next();
|
||||
}
|
||||
}
|
||||
|
||||
void MainController::OnPlaybackStateChanged(int state) {
|
||||
if (this->pauseButton) {
|
||||
switch (state) {
|
||||
case musik::core::sdk::PlaybackPaused:
|
||||
this->pauseButton->SetCaption(_T("resume")); break;
|
||||
case musik::core::sdk::PlaybackPlaying:
|
||||
this->pauseButton->SetCaption(_T("pause")); break;
|
||||
}
|
||||
|
||||
this->Layout();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include <glue/query/TrackListQueryBase.h>
|
||||
|
||||
#include <win32cpp/EditView.hpp>
|
||||
#include <win32cpp/Button.hpp>
|
||||
#include <win32cpp/ListView.hpp>
|
||||
|
||||
namespace musik { namespace win {
|
||||
@ -67,6 +68,8 @@ namespace musik { namespace win {
|
||||
void OnTrackListRowActivated(win32cpp::ListView* list, int index);
|
||||
void OnLibraryQueryCompleted(musik::core::IQueryPtr query);
|
||||
void OnSearchEditChanged(win32cpp::EditView* editView);
|
||||
void OnTransportButtonClicked(win32cpp::Button* button);
|
||||
void OnPlaybackStateChanged(int state);
|
||||
|
||||
void Layout();
|
||||
|
||||
@ -81,6 +84,9 @@ namespace musik { namespace win {
|
||||
|
||||
win32cpp::ListView* trackListView;
|
||||
win32cpp::EditView* editView;
|
||||
win32cpp::Button* prevButton;
|
||||
win32cpp::Button* nextButton;
|
||||
win32cpp::Button* pauseButton;
|
||||
|
||||
bool trackListDirty;
|
||||
};
|
||||
|
@ -111,7 +111,6 @@ LRESULT MainWindow::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) {
|
||||
this->queue->Dispatch();
|
||||
this->queue->Reset();
|
||||
this->queue->ScheduleNext();
|
||||
|
||||
return 0L;
|
||||
}
|
||||
}
|
||||
@ -120,10 +119,7 @@ LRESULT MainWindow::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) {
|
||||
this->queue = new Win32MessageQueue(this->Handle());
|
||||
}
|
||||
|
||||
if (this->queue) {
|
||||
this->queue->ScheduleNext();
|
||||
}
|
||||
|
||||
this->queue->ScheduleNext();
|
||||
return 0L;
|
||||
}
|
||||
|
||||
|
@ -8,31 +8,31 @@
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// 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
|
||||
// * 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.
|
||||
// * 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.
|
||||
// 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.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -384,7 +384,6 @@ Rect ListView::CellRect(int rowIndex, int columnIndex) const
|
||||
return cellRect;
|
||||
}
|
||||
|
||||
|
||||
Rect ListView::RowRect(int rowIndex) const
|
||||
{
|
||||
RECT result;
|
||||
@ -441,7 +440,7 @@ void ListView::DrawRow(DRAWITEMSTRUCT* itemInfo)
|
||||
renderParams.rect = this->CellRect(renderParams.rowIndex, (int) cellIndex);
|
||||
|
||||
// Allow the model to specify a custom cell renderer
|
||||
CellRendererRef cellRenderer =
|
||||
CellRendererRef cellRenderer =
|
||||
this->model->CellRenderer(renderParams.rowIndex, renderParams.column);
|
||||
|
||||
if ( ! cellRenderer)
|
||||
|
Loading…
x
Reference in New Issue
Block a user