mirror of
https://github.com/clangen/musikcube.git
synced 2025-02-11 09:40:26 +00:00
* 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:
parent
191445d74f
commit
bb1bc9c822
@ -53,6 +53,9 @@ void LibraryLayout::InitializeWindows() {
|
||||
this->categoryList->SelectionChanged.connect(
|
||||
this, &LibraryLayout::OnCategoryViewSelectionChanged);
|
||||
|
||||
this->categoryList->Invalidated.connect(
|
||||
this, &LibraryLayout::OnCategoryViewInvalidated);
|
||||
|
||||
this->Layout();
|
||||
}
|
||||
|
||||
@ -61,8 +64,7 @@ void LibraryLayout::Show() {
|
||||
this->categoryList->Requery();
|
||||
}
|
||||
|
||||
void LibraryLayout::OnCategoryViewSelectionChanged(
|
||||
ListWindow *view, size_t newIndex, size_t oldIndex) {
|
||||
void LibraryLayout::RequeryTrackList(ListWindow *view) {
|
||||
if (view == this->categoryList.get()) {
|
||||
DBID id = this->categoryList->GetSelectedId();
|
||||
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) {
|
||||
std::string kn = keyname((int)ch);
|
||||
|
||||
@ -90,6 +102,17 @@ bool LibraryLayout::KeyPress(int64 ch) {
|
||||
this->categoryList->Requery();
|
||||
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);
|
||||
}
|
@ -26,9 +26,14 @@ class LibraryLayout : public LayoutBase, public sigslot::has_slots<> {
|
||||
private:
|
||||
void InitializeWindows();
|
||||
|
||||
void RequeryTrackList(ListWindow *view);
|
||||
|
||||
void OnCategoryViewSelectionChanged(
|
||||
ListWindow *view, size_t newIndex, size_t oldIndex);
|
||||
|
||||
void OnCategoryViewInvalidated(
|
||||
ListWindow *view, size_t selectedIndex);
|
||||
|
||||
Transport& transport;
|
||||
LibraryPtr library;
|
||||
std::shared_ptr<CategoryListView> categoryList;
|
||||
|
@ -57,7 +57,7 @@ void CategoryListView::SetFieldName(const std::string& fieldName) {
|
||||
|
||||
if (this->metadata) {
|
||||
this->metadata.reset();
|
||||
this->OnAdapterChanged();
|
||||
//this->OnAdapterChanged();
|
||||
}
|
||||
|
||||
this->Requery();
|
||||
@ -75,6 +75,7 @@ void CategoryListView::ProcessMessage(IWindowMessage &message) {
|
||||
this->metadata = activeQuery->GetResult();
|
||||
activeQuery.reset();
|
||||
this->OnAdapterChanged();
|
||||
this->OnInvalidated();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,17 +11,24 @@
|
||||
|
||||
#include <core/debug.h>
|
||||
#include <core/library/track/LibraryTrack.h>
|
||||
#include <core/library/LocalLibraryConstants.h>
|
||||
#include <core/playback/NonLibraryTrackHelper.h>
|
||||
|
||||
#include <boost/format.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/chrono.hpp>
|
||||
|
||||
using musik::core::audio::Transport;
|
||||
using musik::core::TrackPtr;
|
||||
using musik::core::LibraryTrack;
|
||||
using musik::core::NonLibraryTrackHelper;
|
||||
using musik::core::QueryPtr;
|
||||
|
||||
using namespace musik::core::library::constants;
|
||||
using namespace musik::box;
|
||||
|
||||
using namespace boost::chrono;
|
||||
|
||||
#define REFRESH_TRANSPORT_READOUT 1001
|
||||
#define REFRESH_INTERVAL_MS 1000
|
||||
|
||||
@ -81,6 +88,7 @@ void TransportWindow::Update() {
|
||||
this->Clear();
|
||||
WINDOW *c = this->GetContent();
|
||||
|
||||
bool paused = (transport->GetPlaybackState() == Transport::StatePaused);
|
||||
int64 gb = COLOR_PAIR(BOX_COLOR_GREEN_ON_BLACK);
|
||||
|
||||
/* playing SONG TITLE from ALBUM NAME */
|
||||
@ -88,11 +96,11 @@ void TransportWindow::Update() {
|
||||
std::string title, album, duration;
|
||||
|
||||
if (this->currentTrack) {
|
||||
title = this->currentTrack->GetValue("title");
|
||||
album = this->currentTrack->GetValue("album");
|
||||
duration = this->currentTrack->GetValue("duration");
|
||||
title = this->currentTrack->GetValue(Track::TITLE);
|
||||
album = this->currentTrack->GetValue(Track::ALBUM);
|
||||
duration = this->currentTrack->GetValue(Track::DURATION);
|
||||
}
|
||||
|
||||
|
||||
title = title.size() ? title : "song title";
|
||||
album = album.size() ? album : "album name";
|
||||
duration = duration.size() ? duration : "0";
|
||||
@ -128,6 +136,17 @@ void TransportWindow::Update() {
|
||||
|
||||
/* 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();
|
||||
|
||||
int secondsCurrent = (int) round(transport->Position());
|
||||
@ -155,8 +174,11 @@ void TransportWindow::Update() {
|
||||
timerTrack += (i == thumbOffset) ? "■" : "─";
|
||||
}
|
||||
|
||||
wprintw(c, "%s %s %s",
|
||||
currentTime.c_str(),
|
||||
wattron(c, timerAttrs); /* blink if paused */
|
||||
wprintw(c, currentTime.c_str());
|
||||
wattroff(c, timerAttrs);
|
||||
|
||||
wprintw(c, " %s %s",
|
||||
timerTrack.c_str(),
|
||||
totalTime.c_str());
|
||||
|
||||
|
@ -17,4 +17,5 @@ void Colors::Init() {
|
||||
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_GREEN_ON_BLACK, COLOR_GREEN, COLOR_BLACK);
|
||||
init_pair(BOX_COLOR_BLACK_ON_BLACK, COLOR_BLACK, COLOR_BLACK);
|
||||
}
|
@ -12,6 +12,7 @@
|
||||
#define BOX_COLOR_RED_ON_BLACK 8
|
||||
#define BOX_COLOR_RED_ON_GREY 9
|
||||
#define BOX_COLOR_GREEN_ON_BLACK 10
|
||||
#define BOX_COLOR_BLACK_ON_BLACK 11
|
||||
|
||||
class Colors {
|
||||
private:
|
||||
|
@ -59,6 +59,10 @@ void ListWindow::ScrollUp(int delta) {
|
||||
this->Repaint();
|
||||
}
|
||||
|
||||
void ListWindow::OnInvalidated() {
|
||||
this->Invalidated(this, this->GetSelectedIndex());
|
||||
}
|
||||
|
||||
void ListWindow::ScrollDown(int delta) {
|
||||
ScrollPos spos = this->GetScrollPosition();
|
||||
IScrollAdapter& adapter = this->GetScrollAdapter();
|
||||
|
@ -10,6 +10,7 @@ class ListWindow : public ScrollableWindow {
|
||||
static size_t NO_SELECTION;
|
||||
|
||||
sigslot::signal3<ListWindow*, size_t, size_t> SelectionChanged;
|
||||
sigslot::signal2<ListWindow*, size_t> Invalidated;
|
||||
|
||||
ListWindow(IWindow *parent = NULL);
|
||||
virtual ~ListWindow();
|
||||
@ -28,6 +29,8 @@ class ListWindow : public ScrollableWindow {
|
||||
virtual void SetSelectedIndex(size_t index);
|
||||
virtual void OnAdapterChanged();
|
||||
virtual void OnSelectionChanged(size_t newIndex, size_t oldIndex);
|
||||
virtual void OnInvalidated();
|
||||
|
||||
virtual IScrollAdapter::ScrollPosition& GetScrollPosition();
|
||||
|
||||
private:
|
||||
|
@ -236,5 +236,8 @@
|
||||
<Filter Include="app\query">
|
||||
<UniqueIdentifier>{5c751253-4250-4a81-8b5f-ca6244954d64}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="app\playback">
|
||||
<UniqueIdentifier>{c1d1d375-e69f-4b98-b51b-24f76be0ee8e}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
</Project>
|
Loading…
x
Reference in New Issue
Block a user