mirror of
https://github.com/clangen/musikcube.git
synced 2024-10-02 04:52:32 +00:00
Scary experimental changes to the way focus is tracked to reduce
spaghetti code and fix weird focus bugs with the transport.
This commit is contained in:
parent
76d40a4d42
commit
22900b2c83
@ -306,7 +306,6 @@ IWindowPtr LibraryLayout::FocusNext() {
|
|||||||
return this->transportView;
|
return this->transportView;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->transportView->Blur();
|
|
||||||
return this->visibleLayout->FocusFirst();
|
return this->visibleLayout->FocusFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,7 +318,6 @@ IWindowPtr LibraryLayout::FocusPrev() {
|
|||||||
return this->transportView;
|
return this->transportView;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->transportView->Blur();
|
|
||||||
return this->visibleLayout->FocusLast();
|
return this->visibleLayout->FocusLast();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -452,12 +450,10 @@ bool LibraryLayout::KeyPress(const std::string& key) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (this->GetFocus() == this->transportView && Hotkeys::Is(Hotkeys::Up, key)) {
|
else if (this->GetFocus() == this->transportView && Hotkeys::Is(Hotkeys::Up, key)) {
|
||||||
this->transportView->Blur();
|
|
||||||
this->visibleLayout->FocusLast();
|
this->visibleLayout->FocusLast();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (this->GetFocus() == this->transportView && Hotkeys::Is(Hotkeys::Down, key)) {
|
else if (this->GetFocus() == this->transportView && Hotkeys::Is(Hotkeys::Down, key)) {
|
||||||
this->transportView->Blur();
|
|
||||||
this->visibleLayout->FocusFirst();
|
this->visibleLayout->FocusFirst();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -360,7 +360,6 @@ void TransportWindow::SetFocus(FocusTarget target) {
|
|||||||
|
|
||||||
if (this->focus == FocusNone) {
|
if (this->focus == FocusNone) {
|
||||||
this->lastFocus = last;
|
this->lastFocus = last;
|
||||||
this->Blur();
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this->Focus();
|
this->Focus();
|
||||||
|
@ -449,10 +449,6 @@ process:
|
|||||||
|
|
||||||
void App::UpdateFocusedWindow(IWindowPtr window) {
|
void App::UpdateFocusedWindow(IWindowPtr window) {
|
||||||
if (this->state.focused != window) {
|
if (this->state.focused != window) {
|
||||||
if (this->state.focused) {
|
|
||||||
this->state.focused->Blur();
|
|
||||||
}
|
|
||||||
|
|
||||||
this->state.focused = window;
|
this->state.focused = window;
|
||||||
this->state.input = dynamic_cast<IInput*>(window.get());
|
this->state.input = dynamic_cast<IInput*>(window.get());
|
||||||
this->state.keyHandler = dynamic_cast<IKeyHandler*>(window.get());
|
this->state.keyHandler = dynamic_cast<IKeyHandler*>(window.get());
|
||||||
|
@ -203,11 +203,6 @@ void AppLayout::FocusShortcuts() {
|
|||||||
|
|
||||||
if (this->layout) {
|
if (this->layout) {
|
||||||
this->lastFocus = this->layout->GetFocus();
|
this->lastFocus = this->layout->GetFocus();
|
||||||
|
|
||||||
if (this->lastFocus) {
|
|
||||||
this->lastFocus->Blur();
|
|
||||||
}
|
|
||||||
|
|
||||||
this->layout->SetFocus(IWindowPtr());
|
this->layout->SetFocus(IWindowPtr());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,14 +67,9 @@ bool sortByFocusOrder(IWindowPtr a, IWindowPtr b) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline IWindowPtr adjustFocus(IWindowPtr oldFocus, IWindowPtr newFocus) {
|
static inline IWindowPtr adjustFocus(IWindowPtr oldFocus, IWindowPtr newFocus) {
|
||||||
if (oldFocus) {
|
|
||||||
oldFocus->Blur();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newFocus) {
|
if (newFocus) {
|
||||||
newFocus->Focus();
|
newFocus->Focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
return newFocus;
|
return newFocus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,6 +52,7 @@ static int NEXT_ID = 0;
|
|||||||
static bool drawPending = false;
|
static bool drawPending = false;
|
||||||
static bool freeze = false;
|
static bool freeze = false;
|
||||||
static Window* top = nullptr;
|
static Window* top = nullptr;
|
||||||
|
static Window* focused = nullptr;
|
||||||
|
|
||||||
static MessageQueue messageQueue;
|
static MessageQueue messageQueue;
|
||||||
static std::shared_ptr<INavigationKeys> keys;
|
static std::shared_ptr<INavigationKeys> keys;
|
||||||
@ -147,6 +148,12 @@ Window::Window(IWindow *parent) {
|
|||||||
|
|
||||||
Window::~Window() {
|
Window::~Window() {
|
||||||
messageQueue.Remove(this);
|
messageQueue.Remove(this);
|
||||||
|
if (::top == this) {
|
||||||
|
::top = nullptr;
|
||||||
|
}
|
||||||
|
if (::focused == this) {
|
||||||
|
::focused = nullptr;
|
||||||
|
}
|
||||||
this->Destroy();
|
this->Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -807,6 +814,10 @@ bool Window::IsParentVisible() {
|
|||||||
|
|
||||||
void Window::Focus() {
|
void Window::Focus() {
|
||||||
if (!this->isFocused) {
|
if (!this->isFocused) {
|
||||||
|
if (::focused && ::focused != this) {
|
||||||
|
::focused->Blur();
|
||||||
|
}
|
||||||
|
::focused = this;
|
||||||
this->isFocused = true;
|
this->isFocused = true;
|
||||||
this->isDirty = true;
|
this->isDirty = true;
|
||||||
this->OnFocusChanged(true);
|
this->OnFocusChanged(true);
|
||||||
@ -817,6 +828,9 @@ void Window::Focus() {
|
|||||||
|
|
||||||
void Window::Blur() {
|
void Window::Blur() {
|
||||||
if (this->isFocused) {
|
if (this->isFocused) {
|
||||||
|
if (::focused == this) {
|
||||||
|
::focused = nullptr;
|
||||||
|
}
|
||||||
this->isFocused = false;
|
this->isFocused = false;
|
||||||
this->isDirty = true;
|
this->isDirty = true;
|
||||||
this->OnFocusChanged(false);
|
this->OnFocusChanged(false);
|
||||||
|
Loading…
Reference in New Issue
Block a user