mirror of
https://github.com/clangen/musikcube.git
synced 2025-01-05 21:55:24 +00:00
- Fixed scroll behavior to show one item above when jumping to search results and showing now playing
- Highlight CategoryListView rows with current playing info like we do in TrackListView
This commit is contained in:
parent
4d38d4f9ee
commit
250a265de4
@ -14,9 +14,6 @@
|
||||
<Filter Include="src\sdk">
|
||||
<UniqueIdentifier>{88841a57-b3cc-459c-bfb7-05b8a2baca03}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="src\db">
|
||||
<UniqueIdentifier>{9c63f496-9ae4-4032-8b1d-b1cdcd09a1d2}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="src\library">
|
||||
<UniqueIdentifier>{90ebbbb9-2451-414e-9b0c-20f40fdadd9f}</UniqueIdentifier>
|
||||
</Filter>
|
||||
@ -35,6 +32,9 @@
|
||||
<Filter Include="src\library\metadata">
|
||||
<UniqueIdentifier>{9f9ee41d-111b-4dab-8663-946253eeb46f}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="src\db">
|
||||
<UniqueIdentifier>{9c63f496-9ae4-4032-8b1d-b1cdcd09a1d2}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="pch.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);
|
||||
|
@ -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));
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -58,7 +58,9 @@ namespace musik {
|
||||
public:
|
||||
sigslot::signal3<SearchLayout*, std::string, DBID> 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(
|
||||
|
@ -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<int>(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<SingleLineEntry> entry(new SingleLineEntry(value));
|
||||
entry->SetAttrs(attrs);
|
||||
return entry;
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include <cursespp/ScrollAdapterBase.h>
|
||||
|
||||
#include <app/query/CategoryListViewQuery.h>
|
||||
#include <app/service/PlaybackService.h>
|
||||
|
||||
#include <core/library/IQuery.h>
|
||||
#include <core/library/ILibrary.h>
|
||||
@ -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<CategoryListViewQuery> activeQuery;
|
||||
|
||||
musik::core::TrackPtr playing;
|
||||
|
||||
std::string fieldName;
|
||||
std::shared_ptr<CategoryListViewQuery> activeQuery;
|
||||
CategoryListViewQuery::ResultList metadata;
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user