diff --git a/src/core/core.vcxproj.filters b/src/core/core.vcxproj.filters index be1a7bf00..be31c45c5 100755 --- a/src/core/core.vcxproj.filters +++ b/src/core/core.vcxproj.filters @@ -14,9 +14,6 @@ {88841a57-b3cc-459c-bfb7-05b8a2baca03} - - {9c63f496-9ae4-4032-8b1d-b1cdcd09a1d2} - {90ebbbb9-2451-414e-9b0c-20f40fdadd9f} @@ -35,6 +32,9 @@ {9f9ee41d-111b-4dab-8663-946253eeb46f} + + {9c63f496-9ae4-4032-8b1d-b1cdcd09a1d2} + diff --git a/src/musikbox/app/layout/BrowseLayout.cpp b/src/musikbox/app/layout/BrowseLayout.cpp index f8d365843..fed257a70 100755 --- a/src/musikbox/app/layout/BrowseLayout.cpp +++ b/src/musikbox/app/layout/BrowseLayout.cpp @@ -84,7 +84,7 @@ void BrowseLayout::Layout() { } void BrowseLayout::InitializeWindows() { - this->categoryList.reset(new CategoryListView(this->library, DEFAULT_CATEGORY)); + this->categoryList.reset(new CategoryListView(this->playback, this->library, DEFAULT_CATEGORY)); this->trackList.reset(new TrackListView(this->playback, this->library)); this->AddWindow(this->categoryList); diff --git a/src/musikbox/app/layout/LibraryLayout.cpp b/src/musikbox/app/layout/LibraryLayout.cpp index 3ae05c920..e9bfbd74a 100755 --- a/src/musikbox/app/layout/LibraryLayout.cpp +++ b/src/musikbox/app/layout/LibraryLayout.cpp @@ -129,7 +129,7 @@ void LibraryLayout::InitializeWindows() { this->browseLayout.reset(new BrowseLayout(this->playback, this->library)); this->nowPlayingLayout.reset(new NowPlayingLayout(this->playback, this->library)); - this->searchLayout.reset(new SearchLayout(this->library)); + this->searchLayout.reset(new SearchLayout(this->playback, this->library)); this->searchLayout->SearchResultSelected.connect(this, &LibraryLayout::OnSearchResultSelected); this->transportView.reset(new TransportWindow(this->playback)); diff --git a/src/musikbox/app/layout/NowPlayingLayout.cpp b/src/musikbox/app/layout/NowPlayingLayout.cpp index 92fd1431b..c6ea89f38 100755 --- a/src/musikbox/app/layout/NowPlayingLayout.cpp +++ b/src/musikbox/app/layout/NowPlayingLayout.cpp @@ -101,7 +101,7 @@ void NowPlayingLayout::OnTrackListRequeried() { if (playback.Count()) { size_t index = playback.GetIndex(); this->trackList->SetSelectedIndex(index); - this->trackList->ScrollTo(index); + this->trackList->ScrollTo(index == 0 ? index : index - 1); } } diff --git a/src/musikbox/app/layout/SearchLayout.cpp b/src/musikbox/app/layout/SearchLayout.cpp index 11f04252c..cdacd7bab 100755 --- a/src/musikbox/app/layout/SearchLayout.cpp +++ b/src/musikbox/app/layout/SearchLayout.cpp @@ -50,10 +50,10 @@ using namespace cursespp; #define SEARCH_HEIGHT 3 -SearchLayout::SearchLayout(LibraryPtr library) +SearchLayout::SearchLayout(PlaybackService& playback, LibraryPtr library) : LayoutBase() { this->library = library; - this->InitializeWindows(); + this->InitializeWindows(playback); } SearchLayout::~SearchLayout() { @@ -86,11 +86,11 @@ void SearchLayout::Layout() { } #define CREATE_CATEGORY(view, type, order) \ - view.reset(new CategoryListView(this->library, type)); \ + view.reset(new CategoryListView(playback, this->library, type)); \ this->AddWindow(view); \ view->SetFocusOrder(order); -void SearchLayout::InitializeWindows() { +void SearchLayout::InitializeWindows(PlaybackService& playback) { this->input.reset(new cursespp::TextInput()); this->input->TextChanged.connect(this, &SearchLayout::OnInputChanged); this->input->SetContentColor(BOX_COLOR_WHITE_ON_BLACK); diff --git a/src/musikbox/app/layout/SearchLayout.h b/src/musikbox/app/layout/SearchLayout.h index 76fab2cfe..33498f0ac 100755 --- a/src/musikbox/app/layout/SearchLayout.h +++ b/src/musikbox/app/layout/SearchLayout.h @@ -58,7 +58,9 @@ namespace musik { public: sigslot::signal3 SearchResultSelected; - SearchLayout(musik::core::LibraryPtr library); + SearchLayout( + PlaybackService& playback, + musik::core::LibraryPtr library); virtual ~SearchLayout(); @@ -67,7 +69,7 @@ namespace musik { virtual bool KeyPress(const std::string& key); private: - void InitializeWindows(); + void InitializeWindows(PlaybackService& playback); void Requery(const std::string& value = ""); void OnInputChanged( diff --git a/src/musikbox/app/window/CategoryListView.cpp b/src/musikbox/app/window/CategoryListView.cpp index 8a01fbfd5..2a75b97c9 100755 --- a/src/musikbox/app/window/CategoryListView.cpp +++ b/src/musikbox/app/window/CategoryListView.cpp @@ -47,6 +47,7 @@ #include "CategoryListView.h" using musik::core::LibraryPtr; +using musik::core::audio::ITransport; using musik::core::IQuery; using namespace musik::core::library::constants; using namespace musik::box; @@ -54,14 +55,24 @@ using cursespp::SingleLineEntry; #define WINDOW_MESSAGE_QUERY_COMPLETED 1002 -CategoryListView::CategoryListView(LibraryPtr library, const std::string& fieldName) -: ListWindow(NULL) { +CategoryListView::CategoryListView( + PlaybackService& playback, + LibraryPtr library, + const std::string& fieldName) +: ListWindow(NULL) +, playback(playback) { this->SetContentColor(BOX_COLOR_WHITE_ON_BLACK); this->selectAfterQuery = 0; this->library = library; this->library->QueryCompleted.connect(this, &CategoryListView::OnQueryCompleted); this->fieldName = fieldName; this->adapter = new Adapter(*this); + this->playback.TrackChanged.connect(this, &CategoryListView::OnTrackChanged); + + size_t index = playback.GetIndex(); + if (index != (size_t) -1) { + this->playing = playback.GetTrackAtIndex(index); + } } CategoryListView::~CategoryListView() { @@ -106,6 +117,11 @@ std::string CategoryListView::GetFieldName() { return this->fieldName; } +void CategoryListView::OnTrackChanged(size_t index, musik::core::TrackPtr track) { + this->playing = track; + this->OnAdapterChanged(); +} + void CategoryListView::SetFieldName(const std::string& fieldName) { if (this->fieldName != fieldName) { this->fieldName = fieldName; @@ -145,7 +161,10 @@ void CategoryListView::ProcessMessage(IMessage &message) { int selectedIndex = static_cast(message.UserData1()); if (selectedIndex >= 0) { this->SetSelectedIndex(selectedIndex); - this->ScrollTo(selectedIndex); + + /* scroll down just a bit more to reveal the item above so + there's indication the user can scroll. */ + this->ScrollTo(selectedIndex == 0 ? selectedIndex : selectedIndex - 1); } this->OnAdapterChanged(); @@ -168,9 +187,26 @@ size_t CategoryListView::Adapter::GetEntryCount() { IScrollAdapter::EntryPtr CategoryListView::Adapter::GetEntry(size_t index) { std::string value = parent.metadata->at(index)->displayValue; + + bool playing = + parent.playing && + parent.playing->GetValue(parent.fieldName.c_str()) == value; + + bool selected = index == parent.GetSelectedIndex(); + + int64 attrs = selected ? COLOR_PAIR(BOX_COLOR_BLACK_ON_GREEN) : -1LL; + + if (playing) { + if (selected) { + attrs = COLOR_PAIR(BOX_COLOR_BLACK_ON_YELLOW); + } + else { + attrs = COLOR_PAIR(BOX_COLOR_YELLOW_ON_BLACK) | A_BOLD; + } + } + text::Ellipsize(value, this->GetWidth()); - int64 attrs = (index == parent.GetSelectedIndex()) ? COLOR_PAIR(BOX_COLOR_BLACK_ON_GREEN) : -1LL; std::shared_ptr entry(new SingleLineEntry(value)); entry->SetAttrs(attrs); return entry; diff --git a/src/musikbox/app/window/CategoryListView.h b/src/musikbox/app/window/CategoryListView.h index 784e74dc3..162e45def 100755 --- a/src/musikbox/app/window/CategoryListView.h +++ b/src/musikbox/app/window/CategoryListView.h @@ -40,6 +40,7 @@ #include #include +#include #include #include @@ -62,7 +63,11 @@ namespace musik { public sigslot::has_slots<> { public: - CategoryListView(LibraryPtr library, const std::string& fieldName); + CategoryListView( + PlaybackService& playback, + LibraryPtr library, + const std::string& fieldName); + virtual ~CategoryListView(); void RequeryWithField( @@ -99,13 +104,19 @@ namespace musik { }; private: + void OnTrackChanged(size_t index, musik::core::TrackPtr track); + + PlaybackService& playback; LibraryPtr library; Adapter *adapter; - DBID selectAfterQuery; + boost::mutex queryMutex; + DBID selectAfterQuery; + std::shared_ptr activeQuery; + + musik::core::TrackPtr playing; std::string fieldName; - std::shared_ptr activeQuery; CategoryListViewQuery::ResultList metadata; }; }