A few improvements to the new info line.

This commit is contained in:
Casey Langen 2016-07-03 11:49:57 -07:00
parent 1d1c3a18bd
commit 6d600dd2e0
5 changed files with 61 additions and 21 deletions

View File

@ -115,6 +115,27 @@ void LibraryLayout::ChangeMainLayout(std::shared_ptr<cursespp::LayoutBase> 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);

View File

@ -81,6 +81,8 @@ namespace musik {
void ShowTrackSearch();
void ChangeMainLayout(std::shared_ptr<cursespp::LayoutBase> newLayout);
void OnLayoutChanged();
void UpdateShortcutsWindow();
PlaybackService& playback;
musik::core::audio::ITransport& transport;

View File

@ -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<Entry>(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);
//}
}
}
}

View File

@ -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<std::shared_ptr<Entry> > EntryList;
EntryList entries;
std::string activeKey;
};
}
}

View File

@ -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() {