From 6d600dd2e01c7ca993d77aec2f984b2cf28f1963 Mon Sep 17 00:00:00 2001 From: Casey Langen Date: Sun, 3 Jul 2016 11:49:57 -0700 Subject: [PATCH] A few improvements to the new info line. --- src/musikbox/app/layout/LibraryLayout.cpp | 22 +++++++++++++++ src/musikbox/app/layout/LibraryLayout.h | 2 ++ src/musikbox/app/window/ShortcutsWindow.cpp | 30 +++++++++------------ src/musikbox/app/window/ShortcutsWindow.h | 11 +++++--- src/musikbox/cursespp/Window.cpp | 17 ++++++++++++ 5 files changed, 61 insertions(+), 21 deletions(-) diff --git a/src/musikbox/app/layout/LibraryLayout.cpp b/src/musikbox/app/layout/LibraryLayout.cpp index 0eb6037d9..0c6b5448c 100755 --- a/src/musikbox/app/layout/LibraryLayout.cpp +++ b/src/musikbox/app/layout/LibraryLayout.cpp @@ -115,6 +115,27 @@ void LibraryLayout::ChangeMainLayout(std::shared_ptr newLa if (this->IsVisible()) { this->BringToTop(); } + + this->OnLayoutChanged(); + } +} + +void LibraryLayout::OnLayoutChanged() { + this->UpdateShortcutsWindow(); +} + +void LibraryLayout::UpdateShortcutsWindow() { + if (this->visibleLayout == this->browseLayout) { + this->shortcuts->SetActive("ALT+b"); + } + else if (this->visibleLayout == nowPlayingLayout) { + this->shortcuts->SetActive("ALT+p"); + } + else if (this->visibleLayout == searchLayout) { + this->shortcuts->SetActive("ALT+f"); + } + else if (this->visibleLayout == trackSearch) { + this->shortcuts->SetActive("ALT+t"); } } @@ -151,6 +172,7 @@ void LibraryLayout::InitializeWindows() { this->shortcuts->AddShortcut("ALT+t", "tracks"); this->shortcuts->AddShortcut("ALT+p", "play queue"); this->shortcuts->AddShortcut("ALT+s", "settings"); + this->UpdateShortcutsWindow(); this->AddWindow(this->transportView); this->AddWindow(this->shortcuts); diff --git a/src/musikbox/app/layout/LibraryLayout.h b/src/musikbox/app/layout/LibraryLayout.h index 78d073701..c33c1eb52 100755 --- a/src/musikbox/app/layout/LibraryLayout.h +++ b/src/musikbox/app/layout/LibraryLayout.h @@ -81,6 +81,8 @@ namespace musik { void ShowTrackSearch(); void ChangeMainLayout(std::shared_ptr newLayout); + void OnLayoutChanged(); + void UpdateShortcutsWindow(); PlaybackService& playback; musik::core::audio::ITransport& transport; diff --git a/src/musikbox/app/window/ShortcutsWindow.cpp b/src/musikbox/app/window/ShortcutsWindow.cpp index 08fcda04d..f65c82865 100755 --- a/src/musikbox/app/window/ShortcutsWindow.cpp +++ b/src/musikbox/app/window/ShortcutsWindow.cpp @@ -44,6 +44,7 @@ using namespace musik::box; ShortcutsWindow::ShortcutsWindow() : Window(nullptr) { this->SetFrameVisible(false); + this->SetContentColor(CURSESPP_SELECTED_LIST_ITEM); } ShortcutsWindow::~ShortcutsWindow() { @@ -55,37 +56,30 @@ void ShortcutsWindow::AddShortcut( { this->entries.push_back( std::shared_ptr(new Entry(key, description))); + + this->Repaint(); } -void ShortcutsWindow::Show() { - Window::Show(); - this->Redraw(); -} +void ShortcutsWindow::Repaint() { + Window::Repaint(); -void ShortcutsWindow::Redraw() { - std::string value; + this->Clear(); - int64 active = COLOR_PAIR(CURSESPP_HIGHLIGHTED_SELECTED_LIST_ITEM); + int64 normalAttrs = COLOR_PAIR(CURSESPP_HIGHLIGHTED_SELECTED_LIST_ITEM); + int64 activeAttrs = COLOR_PAIR(CURSESPP_HIGHLIGHTED_LIST_ITEM); WINDOW* c = this->GetContent(); - werase(c); - wbkgd(c, COLOR_PAIR(CURSESPP_SELECTED_LIST_ITEM)); for (size_t i = 0; i < this->entries.size(); i++) { auto e = this->entries[i]; + int64 keyAttrs = (e->key == this->activeKey) ? activeAttrs : normalAttrs; wprintw(c, " "); - wattron(c, active); + wattron(c, keyAttrs); wprintw(c, " %s ", e->key.c_str()); - wattroff(c, active); + wattroff(c, keyAttrs); wprintw(c, " %s ", e->description.c_str()); - - //if (i != this->entries.size() - 1) { - // //wattron(c, separator); - // wprintw(c, " ▪ "); - // //wattroff(c, separator); - //} } -} \ No newline at end of file +} diff --git a/src/musikbox/app/window/ShortcutsWindow.h b/src/musikbox/app/window/ShortcutsWindow.h index 089cd30fc..baf9ad8b9 100755 --- a/src/musikbox/app/window/ShortcutsWindow.h +++ b/src/musikbox/app/window/ShortcutsWindow.h @@ -49,13 +49,17 @@ namespace musik { virtual ~ShortcutsWindow(); void AddShortcut( - const std::string& key, + const std::string& key, const std::string& description); - virtual void Show(); + void SetActive(const std::string& key) { + this->activeKey = key; + this->Repaint(); + } + + virtual void Repaint(); private: - void Redraw(); struct Entry { Entry(const std::string& key, const std::string& desc) { @@ -70,6 +74,7 @@ namespace musik { typedef std::vector > EntryList; EntryList entries; + std::string activeKey; }; } } diff --git a/src/musikbox/cursespp/Window.cpp b/src/musikbox/cursespp/Window.cpp index eb8c10309..7fa51432b 100755 --- a/src/musikbox/cursespp/Window.cpp +++ b/src/musikbox/cursespp/Window.cpp @@ -436,6 +436,23 @@ IWindow* Window::GetParent() const { void Window::Clear() { werase(this->content); + wmove(this->content, 0, 0); + + if (this->content == this->frame) { + if (this->contentColor != -1) { + wbkgd(this->frame, COLOR_PAIR(this->contentColor)); + } + else { + wbkgd(this->frame, COLOR_PAIR(this->frameColor)); + } + } + else { + wbkgd(this->frame, COLOR_PAIR(this->frameColor)); + + if (this->content != this->frame) { + wbkgd(this->content, COLOR_PAIR(this->contentColor)); + } + } } void Window::Repaint() {