Added the shortcuts to a couple more screens.

This commit is contained in:
casey 2016-07-03 01:50:28 -07:00
parent 12bc61a21a
commit cb4e3af1cb
7 changed files with 60 additions and 52 deletions

View File

@ -67,10 +67,16 @@ ConsoleLayout::ConsoleLayout(ITransport& transport, LibraryPtr library)
this->resources.reset(new ResourcesWindow(this));
this->commands.reset(new cursespp::TextInput());
this->shortcuts.reset(new ShortcutsWindow());
this->shortcuts->AddShortcut("ALT+s", "settings");
this->shortcuts->AddShortcut("ALT+a", "library");
this->shortcuts->AddShortcut("CTRL+d", "quit");
this->AddWindow(this->commands);
this->AddWindow(this->logs);
this->AddWindow(this->output);
this->AddWindow(this->resources);
this->AddWindow(this->shortcuts);
this->commands->EnterPressed.connect(this, &ConsoleLayout::OnEnterPressed);
@ -84,48 +90,30 @@ ConsoleLayout::~ConsoleLayout() {
}
void ConsoleLayout::Layout() {
/* this layout */
this->MoveAndResize(
0,
0,
Screen::GetWidth(),
Screen::GetHeight());
int cx = (int) Screen::GetWidth();
int cy = (int) Screen::GetHeight();
/* this layout */
this->MoveAndResize(0, 0, cx, cy);
this->SetFrameVisible(false);
/* top left */
this->output->MoveAndResize(
0,
0,
Screen::GetWidth() / 2,
Screen::GetHeight() - 3);
/* shortcuts at the bottom */
this->shortcuts->MoveAndResize(0, cy - 1, cx, 1);
/* top left */
this->output->MoveAndResize(0, 0, cx / 2, cy - 4);
this->output->SetFocusOrder(1);
/* bottom left */
this->commands->MoveAndResize(
0,
Screen::GetHeight() - 3,
Screen::GetWidth() / 2,
3);
this->commands->MoveAndResize(0, cy - 4, cx / 2, 3);
this->commands->SetFocusOrder(0);
/* top right */
this->logs->MoveAndResize(
Screen::GetWidth() / 2,
0,
Screen::GetWidth() / 2,
Screen::GetHeight() - 3);
this->logs->MoveAndResize(cx / 2, 0, cx / 2, cy - 4);
this->logs->SetFocusOrder(2);
/* bottom right */
this->resources->MoveAndResize(
Screen::GetWidth() / 2,
Screen::GetHeight() - 3,
Screen::GetWidth() / 2,
3);
this->resources->MoveAndResize(cx / 2, cy - 4, cx / 2, 3);
}
void ConsoleLayout::OnEnterPressed(TextInput *input) {

View File

@ -41,6 +41,7 @@
#include <app/window/OutputWindow.h>
#include <app/window/TransportWindow.h>
#include <app/window/ResourcesWindow.h>
#include <app/window/ShortcutsWindow.h>
#include <vector>
@ -81,6 +82,7 @@ namespace musik {
std::shared_ptr<cursespp::TextInput> commands;
std::shared_ptr<OutputWindow> output;
std::shared_ptr<ResourcesWindow> resources;
std::shared_ptr<ShortcutsWindow> shortcuts;
musik::core::audio::ITransport& transport;
musik::core::LibraryPtr library;
};

View File

@ -91,7 +91,7 @@ void IndexerLayout::Layout() {
this->MoveAndResize(x, y, cx, cy);
this->title->MoveAndResize(0, 0, cx, LABEL_HEIGHT);
this->shortcuts->MoveAndResize(1, cy - 1, cx - 2, LABEL_HEIGHT);
this->shortcuts->MoveAndResize(0, cy - 1, cx, LABEL_HEIGHT);
int startY = BOTTOM(this->title) + 1;
int leftX = 0;
@ -183,8 +183,9 @@ void IndexerLayout::InitializeWindows() {
this->removeCheckbox->SetFocusOrder(3);
this->shortcuts.reset(new ShortcutsWindow());
this->shortcuts->AddShortcut("M-`", "console");
this->shortcuts->AddShortcut("M-a", "console");
this->shortcuts->AddShortcut("ALT+a", "library");
this->shortcuts->AddShortcut("ALT+`", "console");
this->shortcuts->AddShortcut("CTRL+d", "quit");
this->AddWindow(this->title);
this->AddWindow(this->browseLabel);

View File

@ -46,11 +46,8 @@
using namespace musik::core::library::constants;
#ifdef WIN32
#define TRANSPORT_HEIGHT 3
#else
#define TRANSPORT_HEIGHT 2
#endif
#define TRANSPORT_HEIGHT 3
#define SHORTCUTS_HEIGHT 1
using namespace musik::core;
using namespace musik::core::audio;
@ -76,21 +73,25 @@ void LibraryLayout::Layout() {
this->MoveAndResize(x, y, cx, cy);
this->browseLayout->MoveAndResize(x, y, cx, cy - TRANSPORT_HEIGHT);
int mainHeight = cy - TRANSPORT_HEIGHT - SHORTCUTS_HEIGHT;
this->browseLayout->MoveAndResize(x, y, cx, mainHeight);
this->browseLayout->Layout();
this->nowPlayingLayout->MoveAndResize(x, y, cx, cy - TRANSPORT_HEIGHT);
this->nowPlayingLayout->MoveAndResize(x, y, cx, mainHeight);
this->nowPlayingLayout->Layout();
this->searchLayout->MoveAndResize(x, y, cx, cy - TRANSPORT_HEIGHT);
this->searchLayout->MoveAndResize(x, y, cx, mainHeight);
this->searchLayout->Layout();
this->trackSearch->MoveAndResize(x, y, cx, cy - TRANSPORT_HEIGHT);
this->trackSearch->MoveAndResize(x, y, cx, mainHeight);
this->trackSearch->Layout();
this->shortcuts->MoveAndResize(0, cy - 1, cx, 1);
this->transportView->MoveAndResize(
1,
cy - TRANSPORT_HEIGHT,
mainHeight,
cx - 2,
TRANSPORT_HEIGHT);
@ -144,7 +145,15 @@ void LibraryLayout::InitializeWindows() {
this->transportView.reset(new TransportWindow(this->playback));
this->shortcuts.reset(new ShortcutsWindow());
this->shortcuts->AddShortcut("ALT+b", "browse");
this->shortcuts->AddShortcut("ALT+f", "filter");
this->shortcuts->AddShortcut("ALT+t", "tracks");
this->shortcuts->AddShortcut("ALT+n", "playing");
this->shortcuts->AddShortcut("ALT+s", "settings");
this->AddWindow(this->transportView);
this->AddWindow(this->shortcuts);
this->Layout();
}

View File

@ -42,6 +42,7 @@
#include <app/layout/SearchLayout.h>
#include <app/layout/TrackSearchLayout.h>
#include <app/window/TransportWindow.h>
#include <app/window/ShortcutsWindow.h>
#include <app/service/PlaybackService.h>
#include <core/library/ILibrary.h>
@ -90,6 +91,7 @@ namespace musik {
std::shared_ptr<SearchLayout> searchLayout;
std::shared_ptr<TrackSearchLayout> trackSearch;
std::shared_ptr<cursespp::LayoutBase> visibleLayout;
std::shared_ptr<ShortcutsWindow> shortcuts;
};
}
}

View File

@ -64,25 +64,29 @@ void ShortcutsWindow::Show() {
void ShortcutsWindow::Redraw() {
std::string value;
int64 active = COLOR_PAIR(CURSESPP_TEXT_ACTIVE);
int64 active = COLOR_PAIR(CURSESPP_HIGHLIGHTED_SELECTED_LIST_ITEM);
int64 separator = COLOR_PAIR(CURSESPP_TEXT_SEPARATOR);
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];
wprintw(c, " ");
wattron(c, active);
wprintw(c, e->key.c_str());
wprintw(c, " %s ", e->key.c_str());
wattroff(c, active);
wprintw(c, " %s", e->description.c_str());
wprintw(c, " %s ", e->description.c_str());
if (i != this->entries.size() - 1) {
wattron(c, separator);
wprintw(c, "");
wattroff(c, separator);
}
//if (i != this->entries.size() - 1) {
// //wattron(c, separator);
// wprintw(c, " ▪ ");
// //wattroff(c, separator);
//}
}
}

View File

@ -175,13 +175,15 @@ static std::string formatWithoutAlbum(TrackPtr track, size_t width) {
text::AlignLeft,
ARTIST_COL_WIDTH);
size_t titleWidth =
int titleWidth =
width -
TRACK_COL_WIDTH -
DURATION_COL_WIDTH -
ARTIST_COL_WIDTH -
(3 * 3); /* 3 = spacing */
titleWidth = std::max(0, titleWidth);
std::string title = text::Align(
track->GetValue(constants::Track::TITLE),
text::AlignLeft,