mirror of
https://github.com/clangen/musikcube.git
synced 2024-10-02 04:52:32 +00:00
Fixed a bug that could cause focus to get completely lost if the
transport is focused while switching between main views.
This commit is contained in:
parent
e3536d188d
commit
b71d5768de
@ -277,7 +277,14 @@ IWindowPtr LibraryLayout::GetFocus() {
|
||||
return this->transportView;
|
||||
}
|
||||
|
||||
return this->visibleLayout->GetFocus();
|
||||
auto result = this->visibleLayout->GetFocus();
|
||||
|
||||
if (!result) {
|
||||
this->visibleLayout->SetFocusIndex(0);
|
||||
result = this->visibleLayout->GetFocus();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool LibraryLayout::SetFocus(cursespp::IWindowPtr window) {
|
||||
|
@ -47,6 +47,8 @@
|
||||
#include <app/layout/SettingsLayout.h>
|
||||
#include <app/util/Hotkeys.h>
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "SettingsLayout.h"
|
||||
#include "MainLayout.h"
|
||||
|
||||
@ -57,6 +59,7 @@ using namespace musik::core::runtime;
|
||||
using namespace cursespp;
|
||||
|
||||
static UpdateCheck updateCheck;
|
||||
static std::map<ILayout*, int> lastFocusMap;
|
||||
|
||||
#define ENABLE_DEMO_MODE 0
|
||||
|
||||
@ -65,6 +68,15 @@ static std::string lastKey;
|
||||
static int lastKeyRepeat = 0;
|
||||
#endif
|
||||
|
||||
static int last(ILayout* layout) {
|
||||
auto it = lastFocusMap.find(layout);
|
||||
return (it == lastFocusMap.end()) ? 0 : it->second;
|
||||
}
|
||||
|
||||
static void last(ILayout* layout, int last) {
|
||||
lastFocusMap[layout] = last;
|
||||
}
|
||||
|
||||
static void updateSyncingText(TextLabel* label, int updates) {
|
||||
try {
|
||||
if (updates <= 0) {
|
||||
@ -206,6 +218,8 @@ void MainLayout::SetMainLayout(std::shared_ptr<cursespp::LayoutBase> layout) {
|
||||
}
|
||||
|
||||
this->RemoveWindow(this->layout);
|
||||
last(this->layout.get(), this->layout->GetFocusIndex());
|
||||
this->layout->SetFocusIndex(-1);
|
||||
this->layout->Hide();
|
||||
}
|
||||
|
||||
@ -226,6 +240,7 @@ void MainLayout::SetMainLayout(std::shared_ptr<cursespp::LayoutBase> layout) {
|
||||
|
||||
this->AddWindow(this->layout);
|
||||
this->layout->SetFocusOrder(0);
|
||||
this->layout->SetFocusIndex(last(this->layout.get()));
|
||||
this->Layout();
|
||||
}
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ void NowPlayingLayout::OnLayout() {
|
||||
this->GetWidth(),
|
||||
this->GetHeight());
|
||||
|
||||
this->trackListView->SetFocusOrder(1);
|
||||
this->trackListView->SetFocusOrder(0);
|
||||
}
|
||||
|
||||
void NowPlayingLayout::InitializeWindows() {
|
||||
|
Loading…
Reference in New Issue
Block a user