mirror of
https://github.com/clangen/musikcube.git
synced 2025-04-16 14:42:41 +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();
|
auto result = this->visibleLayout->GetFocus();
|
||||||
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
this->visibleLayout->SetFocusIndex(0);
|
this->visibleLayout->SetFocusIndex(0, false);
|
||||||
result = this->visibleLayout->GetFocus();
|
result = this->visibleLayout->GetFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,8 +60,7 @@ static void last(ILayout* layout, int last) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AppLayout::AppLayout(cursespp::App& app)
|
AppLayout::AppLayout(cursespp::App& app)
|
||||||
: shortcutsFocused(false)
|
: topLevelLayout(nullptr)
|
||||||
, topLevelLayout(nullptr)
|
|
||||||
, LayoutBase() {
|
, LayoutBase() {
|
||||||
this->Initialize();
|
this->Initialize();
|
||||||
this->EnableDemoModeIfNecessary();
|
this->EnableDemoModeIfNecessary();
|
||||||
@ -79,7 +78,6 @@ void AppLayout::OnLayout() {
|
|||||||
--cy;
|
--cy;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool sf = this->shortcutsFocused;
|
|
||||||
int mainCyOffset = this->autoHideCommandBar ? 0 : 1;
|
int mainCyOffset = this->autoHideCommandBar ? 0 : 1;
|
||||||
|
|
||||||
if (this->layout) {
|
if (this->layout) {
|
||||||
@ -92,7 +90,7 @@ void AppLayout::OnLayout() {
|
|||||||
0, Screen::GetHeight() - 1, Screen::GetWidth(), 1);
|
0, Screen::GetHeight() - 1, Screen::GetWidth(), 1);
|
||||||
|
|
||||||
if (this->autoHideCommandBar) {
|
if (this->autoHideCommandBar) {
|
||||||
if (sf) {
|
if (this->shortcuts->IsFocused()) {
|
||||||
this->shortcuts->Show();
|
this->shortcuts->Show();
|
||||||
this->shortcuts->BringToTop();
|
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() {
|
cursespp::IWindowPtr AppLayout::GetFocus() {
|
||||||
if (this->shortcutsFocused) {
|
if (this->shortcuts->IsFocused()) {
|
||||||
return this->shortcuts;
|
return this->shortcuts;
|
||||||
}
|
}
|
||||||
if (this->layout) {
|
if (this->layout) {
|
||||||
@ -135,7 +133,7 @@ cursespp::IWindowPtr AppLayout::GetFocus() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
IWindowPtr AppLayout::FocusNext() {
|
IWindowPtr AppLayout::FocusNext() {
|
||||||
if (this->shortcutsFocused) {
|
if (this->shortcuts->IsFocused()) {
|
||||||
return this->BlurShortcuts();
|
return this->BlurShortcuts();
|
||||||
}
|
}
|
||||||
else if (this->layout) {
|
else if (this->layout) {
|
||||||
@ -145,7 +143,7 @@ IWindowPtr AppLayout::FocusNext() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
IWindowPtr AppLayout::FocusPrev() {
|
IWindowPtr AppLayout::FocusPrev() {
|
||||||
if (this->shortcutsFocused) {
|
if (this->shortcuts->IsFocused()) {
|
||||||
return this->BlurShortcuts();
|
return this->BlurShortcuts();
|
||||||
}
|
}
|
||||||
else if (this->layout) {
|
else if (this->layout) {
|
||||||
@ -190,7 +188,6 @@ void AppLayout::SetLayout(std::shared_ptr<cursespp::LayoutBase> layout) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cursespp::IWindowPtr AppLayout::BlurShortcuts() {
|
cursespp::IWindowPtr AppLayout::BlurShortcuts() {
|
||||||
this->shortcutsFocused = false;
|
|
||||||
this->shortcuts->Hide();
|
this->shortcuts->Hide();
|
||||||
this->shortcuts->Blur();
|
this->shortcuts->Blur();
|
||||||
|
|
||||||
@ -226,21 +223,21 @@ void AppLayout::FocusShortcuts() {
|
|||||||
bool AppLayout::KeyPress(const std::string& key) {
|
bool AppLayout::KeyPress(const std::string& key) {
|
||||||
/* otherwise, see if the user is monkeying around with the
|
/* otherwise, see if the user is monkeying around with the
|
||||||
shortcut bar focus... */
|
shortcut bar focus... */
|
||||||
|
auto shortcutsFocused = this->shortcuts->IsFocused();
|
||||||
if (key == "^[" ||
|
if (key == "^[" ||
|
||||||
(key == "KEY_ENTER" && this->shortcutsFocused) ||
|
(key == "KEY_ENTER" && shortcutsFocused) ||
|
||||||
(key == "KEY_UP" && this->shortcutsFocused))
|
(key == "KEY_UP" && shortcutsFocused))
|
||||||
{
|
{
|
||||||
this->shortcutsFocused = !this->shortcutsFocused;
|
if (shortcutsFocused) {
|
||||||
if (this->shortcutsFocused) {
|
this->BlurShortcuts();
|
||||||
this->FocusShortcuts();
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this->BlurShortcuts();
|
this->FocusShortcuts();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->shortcutsFocused) {
|
if (shortcutsFocused) {
|
||||||
if (key == "KEY_DOWN" || key == "KEY_LEFT" ||
|
if (key == "KEY_DOWN" || key == "KEY_LEFT" ||
|
||||||
key == "KEY_UP" || key == "KEY_RIGHT")
|
key == "KEY_UP" || key == "KEY_RIGHT")
|
||||||
{
|
{
|
||||||
|
@ -467,13 +467,15 @@ int LayoutBase::GetFocusIndex() {
|
|||||||
return this->focused;
|
return this->focused;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayoutBase::SetFocusIndex(int index) {
|
void LayoutBase::SetFocusIndex(int index, bool applyFocus) {
|
||||||
if (!this->focusable.size()) {
|
if (!this->focusable.size()) {
|
||||||
this->IndexFocusables();
|
this->IndexFocusables();
|
||||||
}
|
}
|
||||||
this->focused = index;
|
this->focused = index;
|
||||||
|
if (applyFocus) {
|
||||||
this->EnsureValidFocus();
|
this->EnsureValidFocus();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int LayoutBase::GetFocusableCount() {
|
int LayoutBase::GetFocusableCount() {
|
||||||
return (int) this->focusable.size();
|
return (int) this->focusable.size();
|
||||||
|
@ -138,10 +138,10 @@ bool ShortcutsWindow::KeyPress(const std::string& key) {
|
|||||||
/* replace the original key we cached when we were forcused originally
|
/* 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 */
|
to "commit" the operation, as it'll be swapped back when we lose focus */
|
||||||
this->originalKey = this->activeKey;
|
this->originalKey = this->activeKey;
|
||||||
|
|
||||||
if (this->changedCallback) {
|
if (this->changedCallback) {
|
||||||
this->changedCallback(this->activeKey);
|
this->changedCallback(this->activeKey);
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,6 @@ namespace cursespp {
|
|||||||
cursespp::IWindowPtr lastFocus;
|
cursespp::IWindowPtr lastFocus;
|
||||||
ITopLevelLayout* topLevelLayout;
|
ITopLevelLayout* topLevelLayout;
|
||||||
size_t paddingT{0}, paddingL{0}, paddingB{0}, paddingR{0};
|
size_t paddingT{0}, paddingL{0}, paddingB{0}, paddingR{0};
|
||||||
bool shortcutsFocused;
|
|
||||||
bool autoHideCommandBar{ false };
|
bool autoHideCommandBar{ false };
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ namespace cursespp {
|
|||||||
virtual int GetFocusIndex() = 0;
|
virtual int GetFocusIndex() = 0;
|
||||||
|
|
||||||
virtual bool SetFocus(IWindowPtr window) = 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 int GetFocusableCount() = 0;
|
||||||
virtual IWindowPtr GetFocusableAt(int index) = 0;
|
virtual IWindowPtr GetFocusableAt(int index) = 0;
|
||||||
|
@ -77,7 +77,7 @@ namespace cursespp {
|
|||||||
virtual bool SetFocus(IWindowPtr window);
|
virtual bool SetFocus(IWindowPtr window);
|
||||||
|
|
||||||
virtual int GetFocusIndex();
|
virtual int GetFocusIndex();
|
||||||
virtual void SetFocusIndex(int index);
|
virtual void SetFocusIndex(int index, bool applyFocus = true);
|
||||||
|
|
||||||
virtual int GetFocusableCount();
|
virtual int GetFocusableCount();
|
||||||
virtual IWindowPtr GetFocusableAt(int index);
|
virtual IWindowPtr GetFocusableAt(int index);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user