* Improvements to the transport look and feel, including blinking time

while paused, and space to pause/resume
* Better keynames for Track album/artist/genre (don't reuse ID keys)
* No flashing when switching between metadata category types
This commit is contained in:
casey 2016-05-22 00:05:41 -07:00
parent 191445d74f
commit bb1bc9c822
9 changed files with 72 additions and 9 deletions

View File

@ -53,6 +53,9 @@ void LibraryLayout::InitializeWindows() {
this->categoryList->SelectionChanged.connect( this->categoryList->SelectionChanged.connect(
this, &LibraryLayout::OnCategoryViewSelectionChanged); this, &LibraryLayout::OnCategoryViewSelectionChanged);
this->categoryList->Invalidated.connect(
this, &LibraryLayout::OnCategoryViewInvalidated);
this->Layout(); this->Layout();
} }
@ -61,8 +64,7 @@ void LibraryLayout::Show() {
this->categoryList->Requery(); this->categoryList->Requery();
} }
void LibraryLayout::OnCategoryViewSelectionChanged( void LibraryLayout::RequeryTrackList(ListWindow *view) {
ListWindow *view, size_t newIndex, size_t oldIndex) {
if (view == this->categoryList.get()) { if (view == this->categoryList.get()) {
DBID id = this->categoryList->GetSelectedId(); DBID id = this->categoryList->GetSelectedId();
if (id != -1) { if (id != -1) {
@ -71,6 +73,16 @@ void LibraryLayout::OnCategoryViewSelectionChanged(
} }
} }
void LibraryLayout::OnCategoryViewSelectionChanged(
ListWindow *view, size_t newIndex, size_t oldIndex) {
this->RequeryTrackList(view);
}
void LibraryLayout::OnCategoryViewInvalidated(
ListWindow *view, size_t selectedIndex) {
this->RequeryTrackList(view);
}
bool LibraryLayout::KeyPress(int64 ch) { bool LibraryLayout::KeyPress(int64 ch) {
std::string kn = keyname((int)ch); std::string kn = keyname((int)ch);
@ -90,6 +102,17 @@ bool LibraryLayout::KeyPress(int64 ch) {
this->categoryList->Requery(); this->categoryList->Requery();
return true; return true;
} }
else if (ch == ' ') {
/* copied from GlobalHotkeys. should probably be generalized
at some point. */
int state = this->transport.GetPlaybackState();
if (state == Transport::StatePaused) {
this->transport.Resume();
}
else if (state == Transport::StatePlaying) {
this->transport.Pause();
}
}
return LayoutBase::KeyPress(ch); return LayoutBase::KeyPress(ch);
} }

View File

@ -26,9 +26,14 @@ class LibraryLayout : public LayoutBase, public sigslot::has_slots<> {
private: private:
void InitializeWindows(); void InitializeWindows();
void RequeryTrackList(ListWindow *view);
void OnCategoryViewSelectionChanged( void OnCategoryViewSelectionChanged(
ListWindow *view, size_t newIndex, size_t oldIndex); ListWindow *view, size_t newIndex, size_t oldIndex);
void OnCategoryViewInvalidated(
ListWindow *view, size_t selectedIndex);
Transport& transport; Transport& transport;
LibraryPtr library; LibraryPtr library;
std::shared_ptr<CategoryListView> categoryList; std::shared_ptr<CategoryListView> categoryList;

View File

@ -57,7 +57,7 @@ void CategoryListView::SetFieldName(const std::string& fieldName) {
if (this->metadata) { if (this->metadata) {
this->metadata.reset(); this->metadata.reset();
this->OnAdapterChanged(); //this->OnAdapterChanged();
} }
this->Requery(); this->Requery();
@ -75,6 +75,7 @@ void CategoryListView::ProcessMessage(IWindowMessage &message) {
this->metadata = activeQuery->GetResult(); this->metadata = activeQuery->GetResult();
activeQuery.reset(); activeQuery.reset();
this->OnAdapterChanged(); this->OnAdapterChanged();
this->OnInvalidated();
} }
} }

View File

@ -11,17 +11,24 @@
#include <core/debug.h> #include <core/debug.h>
#include <core/library/track/LibraryTrack.h> #include <core/library/track/LibraryTrack.h>
#include <core/library/LocalLibraryConstants.h>
#include <core/playback/NonLibraryTrackHelper.h> #include <core/playback/NonLibraryTrackHelper.h>
#include <boost/format.hpp> #include <boost/format.hpp>
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <boost/chrono.hpp>
using musik::core::audio::Transport; using musik::core::audio::Transport;
using musik::core::TrackPtr; using musik::core::TrackPtr;
using musik::core::LibraryTrack; using musik::core::LibraryTrack;
using musik::core::NonLibraryTrackHelper; using musik::core::NonLibraryTrackHelper;
using musik::core::QueryPtr; using musik::core::QueryPtr;
using namespace musik::core::library::constants;
using namespace musik::box; using namespace musik::box;
using namespace boost::chrono;
#define REFRESH_TRANSPORT_READOUT 1001 #define REFRESH_TRANSPORT_READOUT 1001
#define REFRESH_INTERVAL_MS 1000 #define REFRESH_INTERVAL_MS 1000
@ -81,6 +88,7 @@ void TransportWindow::Update() {
this->Clear(); this->Clear();
WINDOW *c = this->GetContent(); WINDOW *c = this->GetContent();
bool paused = (transport->GetPlaybackState() == Transport::StatePaused);
int64 gb = COLOR_PAIR(BOX_COLOR_GREEN_ON_BLACK); int64 gb = COLOR_PAIR(BOX_COLOR_GREEN_ON_BLACK);
/* playing SONG TITLE from ALBUM NAME */ /* playing SONG TITLE from ALBUM NAME */
@ -88,11 +96,11 @@ void TransportWindow::Update() {
std::string title, album, duration; std::string title, album, duration;
if (this->currentTrack) { if (this->currentTrack) {
title = this->currentTrack->GetValue("title"); title = this->currentTrack->GetValue(Track::TITLE);
album = this->currentTrack->GetValue("album"); album = this->currentTrack->GetValue(Track::ALBUM);
duration = this->currentTrack->GetValue("duration"); duration = this->currentTrack->GetValue(Track::DURATION);
} }
title = title.size() ? title : "song title"; title = title.size() ? title : "song title";
album = album.size() ? album : "album name"; album = album.size() ? album : "album name";
duration = duration.size() ? duration : "0"; duration = duration.size() ? duration : "0";
@ -128,6 +136,17 @@ void TransportWindow::Update() {
/* time slider */ /* time slider */
int64 timerAttrs = 0;
if (paused) { /* blink the track if paused */
int64 now = duration_cast<seconds>(
system_clock::now().time_since_epoch()).count();
if (now % 2 == 0) {
timerAttrs = COLOR_PAIR(BOX_COLOR_BLACK_ON_BLACK);
}
}
transport->Position(); transport->Position();
int secondsCurrent = (int) round(transport->Position()); int secondsCurrent = (int) round(transport->Position());
@ -155,8 +174,11 @@ void TransportWindow::Update() {
timerTrack += (i == thumbOffset) ? "" : ""; timerTrack += (i == thumbOffset) ? "" : "";
} }
wprintw(c, "%s %s %s", wattron(c, timerAttrs); /* blink if paused */
currentTime.c_str(), wprintw(c, currentTime.c_str());
wattroff(c, timerAttrs);
wprintw(c, " %s %s",
timerTrack.c_str(), timerTrack.c_str(),
totalTime.c_str()); totalTime.c_str());

View File

@ -17,4 +17,5 @@ void Colors::Init() {
init_pair(BOX_COLOR_RED_ON_BLACK, COLOR_RED, COLOR_BLACK); init_pair(BOX_COLOR_RED_ON_BLACK, COLOR_RED, COLOR_BLACK);
init_pair(BOX_COLOR_RED_ON_GREY, COLOR_RED, COLOR_WHITE); init_pair(BOX_COLOR_RED_ON_GREY, COLOR_RED, COLOR_WHITE);
init_pair(BOX_COLOR_GREEN_ON_BLACK, COLOR_GREEN, COLOR_BLACK); init_pair(BOX_COLOR_GREEN_ON_BLACK, COLOR_GREEN, COLOR_BLACK);
init_pair(BOX_COLOR_BLACK_ON_BLACK, COLOR_BLACK, COLOR_BLACK);
} }

View File

@ -12,6 +12,7 @@
#define BOX_COLOR_RED_ON_BLACK 8 #define BOX_COLOR_RED_ON_BLACK 8
#define BOX_COLOR_RED_ON_GREY 9 #define BOX_COLOR_RED_ON_GREY 9
#define BOX_COLOR_GREEN_ON_BLACK 10 #define BOX_COLOR_GREEN_ON_BLACK 10
#define BOX_COLOR_BLACK_ON_BLACK 11
class Colors { class Colors {
private: private:

View File

@ -59,6 +59,10 @@ void ListWindow::ScrollUp(int delta) {
this->Repaint(); this->Repaint();
} }
void ListWindow::OnInvalidated() {
this->Invalidated(this, this->GetSelectedIndex());
}
void ListWindow::ScrollDown(int delta) { void ListWindow::ScrollDown(int delta) {
ScrollPos spos = this->GetScrollPosition(); ScrollPos spos = this->GetScrollPosition();
IScrollAdapter& adapter = this->GetScrollAdapter(); IScrollAdapter& adapter = this->GetScrollAdapter();

View File

@ -10,6 +10,7 @@ class ListWindow : public ScrollableWindow {
static size_t NO_SELECTION; static size_t NO_SELECTION;
sigslot::signal3<ListWindow*, size_t, size_t> SelectionChanged; sigslot::signal3<ListWindow*, size_t, size_t> SelectionChanged;
sigslot::signal2<ListWindow*, size_t> Invalidated;
ListWindow(IWindow *parent = NULL); ListWindow(IWindow *parent = NULL);
virtual ~ListWindow(); virtual ~ListWindow();
@ -28,6 +29,8 @@ class ListWindow : public ScrollableWindow {
virtual void SetSelectedIndex(size_t index); virtual void SetSelectedIndex(size_t index);
virtual void OnAdapterChanged(); virtual void OnAdapterChanged();
virtual void OnSelectionChanged(size_t newIndex, size_t oldIndex); virtual void OnSelectionChanged(size_t newIndex, size_t oldIndex);
virtual void OnInvalidated();
virtual IScrollAdapter::ScrollPosition& GetScrollPosition(); virtual IScrollAdapter::ScrollPosition& GetScrollPosition();
private: private:

View File

@ -236,5 +236,8 @@
<Filter Include="app\query"> <Filter Include="app\query">
<UniqueIdentifier>{5c751253-4250-4a81-8b5f-ca6244954d64}</UniqueIdentifier> <UniqueIdentifier>{5c751253-4250-4a81-8b5f-ca6244954d64}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="app\playback">
<UniqueIdentifier>{c1d1d375-e69f-4b98-b51b-24f76be0ee8e}</UniqueIdentifier>
</Filter>
</ItemGroup> </ItemGroup>
</Project> </Project>