Use correct layer ordering when refocusing windows. Focused window gets an internal refresh event.

master
sigonasr2 1 year ago
parent b4b4d59a88
commit 623f0137ab
  1. 10
      FiestaOnlineEditor/FiestaOnlineEditor.cpp
  2. 3
      FiestaOnlineEditor/Window.cpp
  3. 2
      FiestaOnlineEditor/Window.h

@ -168,10 +168,15 @@ bool FiestaOnlineEditor::OnUserUpdate(float fElapsedTime){
if(!menuOpened){
if(!internalMouseFocus){
for(Window*w:windows){ //A second iteration through the windows because windows without focus should only have priority after a window with focus.
for(auto it=windows.begin();it!=windows.end();++it){ //A second iteration through the windows because windows without focus should only have priority after a window with focus.
Window*w=*it;
if(!w->IsFocusedWindow()){
if(w->IsInBounds(GetMousePos())){
w->InternalMouseFocus(this);
if(w->IsFocusedWindow()){//The focused window has changed!
windows.push_back(w);//HACK ALERT! Whenever we are iterating through the windows list we could potentially add an item to the end of it whenever it becomes focused to keep layering. Because of this we don't want to reallocate during another push_back. This ensures that will never occur.
it=windows.erase(it);
}
w->MouseFocus(this);
}
}
@ -194,7 +199,7 @@ bool FiestaOnlineEditor::OnUserUpdate(float fElapsedTime){
});
if(focusErased&&windows.size()>0){
Window::SetFocusedWindow(windows[0]);
Window::SetFocusedWindow(this,windows.back());
}
SetDrawTarget(nullptr);
@ -210,6 +215,7 @@ void FiestaOnlineEditor::CreateWindow(Window*window){
}
window->InternalRefresh(this);
windows.push_back(window);
windows.reserve(windows.size()+1);//HACK ALERT! Whenever we are iterating through the windows list we could potentially add an item to the end of it whenever it becomes focused to keep layering. Because of this we don't want to reallocate during another push_back. This ensures that will never occur.
}
int main()

@ -118,6 +118,7 @@ bool Window::IsClosed(){
return closed;
}
void Window::SetFocusedWindow(Window*w){
void Window::SetFocusedWindow(FiestaOnlineEditor*pge,Window*w){
focusedWindow=w;
w->InternalRefresh(pge);
}

@ -26,7 +26,7 @@ public:
void InternalRefresh(FiestaOnlineEditor*pge);
void Draw(FiestaOnlineEditor*pge);
bool IsFocusedWindow();
static void SetFocusedWindow(Window*w);
static void SetFocusedWindow(FiestaOnlineEditor*pge,Window*w);
void Cleanup();
bool IsInBounds(vf2d point);
void InternalMouseFocus(FiestaOnlineEditor*pge);

Loading…
Cancel
Save