- Removed IMessageTarget::IsAcceptingMessages()

- Fixed up some more hotkeys to improve app behavior
This commit is contained in:
casey 2016-07-06 21:57:05 -07:00
parent e3281d5506
commit e20d13d334
10 changed files with 46 additions and 17 deletions

View File

@ -148,11 +148,15 @@ void LibraryLayout::ShowBrowse() {
}
void LibraryLayout::ShowSearch() {
this->ChangeMainLayout(this->searchLayout);
this->visibleLayout == this->searchLayout
? this->searchLayout->FocusInput()
: this->ChangeMainLayout(this->searchLayout);
}
void LibraryLayout::ShowTrackSearch() {
this->ChangeMainLayout(this->trackSearch);
this->visibleLayout == this->trackSearch
? this->trackSearch->FocusInput()
: this->ChangeMainLayout(this->trackSearch);
}
void LibraryLayout::InitializeWindows() {
@ -226,6 +230,14 @@ bool LibraryLayout::KeyPress(const std::string& key) {
this->ShowTrackSearch();
return true;
}
else if (key == "KEY_LEFT") {
this->FocusPrev();
return true;
}
else if (key == "KEY_RIGHT") {
this->FocusNext();
return true;
}
/* forward to the visible layout */
else if (this->visibleLayout && this->visibleLayout->KeyPress(key)) {
return true;

View File

@ -127,6 +127,10 @@ void SearchLayout::Requery() {
this->genres->Requery(value);
}
void SearchLayout::FocusInput() {
this->SetFocus(this->input);
}
void SearchLayout::OnInputChanged(cursespp::TextInput* sender, std::string value) {
if (this->IsVisible()) {
this->Requery();
@ -166,5 +170,10 @@ bool SearchLayout::KeyPress(const std::string& key) {
}
}
if (key == "KEY_DOWN") {
this->FocusNext();
return true;
}
return LayoutBase::KeyPress(key);
}

View File

@ -69,6 +69,8 @@ namespace musik {
virtual void OnVisibilityChanged(bool visible);
virtual bool KeyPress(const std::string& key);
void FocusInput();
private:
void InitializeWindows(PlaybackService& playback);
void Requery();

View File

@ -69,7 +69,6 @@ TrackSearchLayout::TrackSearchLayout(
}
TrackSearchLayout::~TrackSearchLayout() {
}
void TrackSearchLayout::Layout() {
@ -93,6 +92,7 @@ void TrackSearchLayout::Layout() {
void TrackSearchLayout::InitializeWindows() {
this->input.reset(new cursespp::TextInput());
this->input->TextChanged.connect(this, &TrackSearchLayout::OnInputChanged);
this->input->EnterPressed.connect(this, &TrackSearchLayout::OnEnterPressed);
this->input->SetFocusOrder(0);
this->AddWindow(this->input);
@ -116,6 +116,10 @@ void TrackSearchLayout::OnVisibilityChanged(bool visible) {
}
}
void TrackSearchLayout::FocusInput() {
this->SetFocus(this->input);
}
void TrackSearchLayout::Requery() {
const std::string& filter = this->input->GetText();
this->trackList->Requery(std::shared_ptr<TrackListQueryBase>(
@ -136,11 +140,21 @@ void TrackSearchLayout::OnInputChanged(cursespp::TextInput* sender, std::string
}
}
void TrackSearchLayout::OnEnterPressed(cursespp::TextInput* sender) {
if (this->trackList->GetTrackList()->Count()) {
playback::Play(this->trackList, this->playback, this->GetFocus());
}
}
bool TrackSearchLayout::KeyPress(const std::string& key) {
if (key == "^M") { /* enter. play the selection */
playback::Play(this->trackList, this->playback, this->GetFocus());
return true;
}
else if (key == "KEY_DOWN") {
this->FocusNext();
return true;
}
return LayoutBase::KeyPress(key);
}

View File

@ -64,6 +64,8 @@ namespace musik {
virtual void OnVisibilityChanged(bool visible);
virtual bool KeyPress(const std::string& key);
void FocusInput();
protected:
virtual void ProcessMessage(cursespp::IMessage &message);
@ -75,6 +77,8 @@ namespace musik {
cursespp::TextInput* sender,
std::string value);
void OnEnterPressed(cursespp::TextInput* sender);
PlaybackService& playback;
musik::core::LibraryPtr library;
std::shared_ptr<TrackListView> trackList;

View File

@ -64,7 +64,6 @@ namespace musik {
musik::core::LibraryPtr library,
musik::core::audio::ITransport& transport);
virtual bool IsAcceptingMessages() { return true; }
virtual void ProcessMessage(cursespp::IMessage &message);
musik::core::audio::ITransport& GetTransport() { return this->transport; }

View File

@ -40,7 +40,6 @@ namespace cursespp {
class IMessageTarget {
public:
virtual ~IMessageTarget() { }
virtual bool IsAcceptingMessages() = 0;
virtual void ProcessMessage(IMessage &message) = 0;
};
}

View File

@ -70,13 +70,8 @@ void MessageQueue::Dispatch() {
EnqueuedMessage *m = (*it);
if (now >= m->time) {
if (m->message.get()->Target()->IsAcceptingMessages()) {
toDispatch.push_back(m);
it = this->queue.erase(it);
}
else {
it++;
}
toDispatch.push_back(m);
it = this->queue.erase(it);
}
else {
done = true;

View File

@ -101,10 +101,6 @@ void Window::ProcessMessage(IMessage &message) {
}
bool Window::IsAcceptingMessages() {
return true;
}
bool Window::IsVisible() {
return this->isVisible;
}

View File

@ -76,7 +76,6 @@ namespace cursespp {
virtual void SendToBottom();
virtual void ProcessMessage(IMessage &message);
virtual bool IsAcceptingMessages();
virtual WINDOW* GetFrame() const;
virtual WINDOW* GetContent() const;