mirror of
https://github.com/clangen/musikcube.git
synced 2025-01-16 04:14:05 +00:00
Stumbled upon a super old bug -- if the command bar is focused and then
you click to focus a widget, the command bar stays in a psuedo-focused state where it still accepts inputs but draws as unfocused. This change should fix this, but I have concerns about what types of weird edge cases this may present.
This commit is contained in:
parent
66ee389ee6
commit
1b8cd6bb7f
@ -346,7 +346,7 @@ IWindowPtr LibraryLayout::GetFocus() {
|
||||
auto result = this->visibleLayout->GetFocus();
|
||||
|
||||
if (!result) {
|
||||
this->visibleLayout->SetFocusIndex(0);
|
||||
this->visibleLayout->SetFocusIndex(0, false);
|
||||
result = this->visibleLayout->GetFocus();
|
||||
}
|
||||
|
||||
|
@ -60,8 +60,7 @@ static void last(ILayout* layout, int last) {
|
||||
}
|
||||
|
||||
AppLayout::AppLayout(cursespp::App& app)
|
||||
: shortcutsFocused(false)
|
||||
, topLevelLayout(nullptr)
|
||||
: topLevelLayout(nullptr)
|
||||
, LayoutBase() {
|
||||
this->Initialize();
|
||||
this->EnableDemoModeIfNecessary();
|
||||
@ -79,7 +78,6 @@ void AppLayout::OnLayout() {
|
||||
--cy;
|
||||
#endif
|
||||
|
||||
bool sf = this->shortcutsFocused;
|
||||
int mainCyOffset = this->autoHideCommandBar ? 0 : 1;
|
||||
|
||||
if (this->layout) {
|
||||
@ -92,7 +90,7 @@ void AppLayout::OnLayout() {
|
||||
0, Screen::GetHeight() - 1, Screen::GetWidth(), 1);
|
||||
|
||||
if (this->autoHideCommandBar) {
|
||||
if (sf) {
|
||||
if (this->shortcuts->IsFocused()) {
|
||||
this->shortcuts->Show();
|
||||
this->shortcuts->BringToTop();
|
||||
}
|
||||
@ -125,7 +123,7 @@ void AppLayout::SetPadding(size_t t, size_t l, size_t b, size_t r) {
|
||||
}
|
||||
|
||||
cursespp::IWindowPtr AppLayout::GetFocus() {
|
||||
if (this->shortcutsFocused) {
|
||||
if (this->shortcuts->IsFocused()) {
|
||||
return this->shortcuts;
|
||||
}
|
||||
if (this->layout) {
|
||||
@ -135,7 +133,7 @@ cursespp::IWindowPtr AppLayout::GetFocus() {
|
||||
}
|
||||
|
||||
IWindowPtr AppLayout::FocusNext() {
|
||||
if (this->shortcutsFocused) {
|
||||
if (this->shortcuts->IsFocused()) {
|
||||
return this->BlurShortcuts();
|
||||
}
|
||||
else if (this->layout) {
|
||||
@ -145,7 +143,7 @@ IWindowPtr AppLayout::FocusNext() {
|
||||
}
|
||||
|
||||
IWindowPtr AppLayout::FocusPrev() {
|
||||
if (this->shortcutsFocused) {
|
||||
if (this->shortcuts->IsFocused()) {
|
||||
return this->BlurShortcuts();
|
||||
}
|
||||
else if (this->layout) {
|
||||
@ -190,7 +188,6 @@ void AppLayout::SetLayout(std::shared_ptr<cursespp::LayoutBase> layout) {
|
||||
}
|
||||
|
||||
cursespp::IWindowPtr AppLayout::BlurShortcuts() {
|
||||
this->shortcutsFocused = false;
|
||||
this->shortcuts->Hide();
|
||||
this->shortcuts->Blur();
|
||||
|
||||
@ -226,21 +223,21 @@ void AppLayout::FocusShortcuts() {
|
||||
bool AppLayout::KeyPress(const std::string& key) {
|
||||
/* otherwise, see if the user is monkeying around with the
|
||||
shortcut bar focus... */
|
||||
auto shortcutsFocused = this->shortcuts->IsFocused();
|
||||
if (key == "^[" ||
|
||||
(key == "KEY_ENTER" && this->shortcutsFocused) ||
|
||||
(key == "KEY_UP" && this->shortcutsFocused))
|
||||
(key == "KEY_ENTER" && shortcutsFocused) ||
|
||||
(key == "KEY_UP" && shortcutsFocused))
|
||||
{
|
||||
this->shortcutsFocused = !this->shortcutsFocused;
|
||||
if (this->shortcutsFocused) {
|
||||
this->FocusShortcuts();
|
||||
if (shortcutsFocused) {
|
||||
this->BlurShortcuts();
|
||||
}
|
||||
else {
|
||||
this->BlurShortcuts();
|
||||
this->FocusShortcuts();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this->shortcutsFocused) {
|
||||
if (shortcutsFocused) {
|
||||
if (key == "KEY_DOWN" || key == "KEY_LEFT" ||
|
||||
key == "KEY_UP" || key == "KEY_RIGHT")
|
||||
{
|
||||
|
@ -467,12 +467,14 @@ int LayoutBase::GetFocusIndex() {
|
||||
return this->focused;
|
||||
}
|
||||
|
||||
void LayoutBase::SetFocusIndex(int index) {
|
||||
void LayoutBase::SetFocusIndex(int index, bool applyFocus) {
|
||||
if (!this->focusable.size()) {
|
||||
this->IndexFocusables();
|
||||
}
|
||||
this->focused = index;
|
||||
this->EnsureValidFocus();
|
||||
if (applyFocus) {
|
||||
this->EnsureValidFocus();
|
||||
}
|
||||
}
|
||||
|
||||
int LayoutBase::GetFocusableCount() {
|
||||
|
@ -138,10 +138,10 @@ bool ShortcutsWindow::KeyPress(const std::string& key) {
|
||||
/* replace the original key we cached when we were forcused originally
|
||||
to "commit" the operation, as it'll be swapped back when we lose focus */
|
||||
this->originalKey = this->activeKey;
|
||||
|
||||
if (this->changedCallback) {
|
||||
this->changedCallback(this->activeKey);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -82,7 +82,6 @@ namespace cursespp {
|
||||
cursespp::IWindowPtr lastFocus;
|
||||
ITopLevelLayout* topLevelLayout;
|
||||
size_t paddingT{0}, paddingL{0}, paddingB{0}, paddingR{0};
|
||||
bool shortcutsFocused;
|
||||
bool autoHideCommandBar{ false };
|
||||
};
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ namespace cursespp {
|
||||
virtual int GetFocusIndex() = 0;
|
||||
|
||||
virtual bool SetFocus(IWindowPtr window) = 0;
|
||||
virtual void SetFocusIndex(int index) = 0;
|
||||
virtual void SetFocusIndex(int index, bool applyFocus = true) = 0;
|
||||
|
||||
virtual int GetFocusableCount() = 0;
|
||||
virtual IWindowPtr GetFocusableAt(int index) = 0;
|
||||
|
@ -77,7 +77,7 @@ namespace cursespp {
|
||||
virtual bool SetFocus(IWindowPtr window);
|
||||
|
||||
virtual int GetFocusIndex();
|
||||
virtual void SetFocusIndex(int index);
|
||||
virtual void SetFocusIndex(int index, bool applyFocus = true);
|
||||
|
||||
virtual int GetFocusableCount();
|
||||
virtual IWindowPtr GetFocusableAt(int index);
|
||||
|
Loading…
Reference in New Issue
Block a user