Help dialog from other dialog: preserve z order
This commit is contained in:
@@ -537,8 +537,7 @@ void cDialog::run(std::function<void(cDialog&)> onopen){
|
||||
winLastY = parentPos.y + (int(parentSz.y) - winRect.height()) / 2;
|
||||
win.setPosition({winLastX, winLastY});
|
||||
draw();
|
||||
makeFrontWindow(parent ? parent-> win : mainPtr());
|
||||
makeFrontWindow(win);
|
||||
stackWindowsCorrectly();
|
||||
// This is a loose modal session, as it doesn't prevent you from clicking away,
|
||||
// but it does prevent editing other dialogs, and it also keeps this window on top
|
||||
// even when it loses focus.
|
||||
@@ -554,7 +553,7 @@ void cDialog::run(std::function<void(cDialog&)> onopen){
|
||||
while(pollEvent(parentWin, currentEvent));
|
||||
set_cursor(former_curs);
|
||||
topWindow = formerTop;
|
||||
makeFrontWindow(*parentWin);
|
||||
stackWindowsCorrectly();
|
||||
}
|
||||
|
||||
void cDialog::runWithHelp(short help1, short help2, bool help_forced) {
|
||||
@@ -630,6 +629,20 @@ void cDialog::handleTab(bool reverse) {
|
||||
}
|
||||
}
|
||||
|
||||
void cDialog::stackWindowsCorrectly() {
|
||||
// Put all dialogs in correct z order:
|
||||
std::vector<sf::RenderWindow*> dialog_stack;
|
||||
cDialog* next = this;
|
||||
while(next != nullptr){
|
||||
dialog_stack.push_back(&(next->win));
|
||||
next = next->parent;
|
||||
}
|
||||
makeFrontWindow(mainPtr());
|
||||
for(int i = dialog_stack.size() - 1; i >= 0; --i){
|
||||
makeFrontWindow(*(dialog_stack[i]));
|
||||
}
|
||||
}
|
||||
|
||||
// This method handles one event received by the dialog.
|
||||
void cDialog::handle_one_event(const sf::Event& currentEvent, cFramerateLimiter& fps_limiter) {
|
||||
using Key = sf::Keyboard::Key;
|
||||
@@ -754,17 +767,7 @@ void cDialog::handle_one_event(const sf::Event& currentEvent, cFramerateLimiter&
|
||||
if(onGainedFocus){
|
||||
onGainedFocus(win);
|
||||
}
|
||||
|
||||
// Put all dialogs in correct z order:
|
||||
std::vector<sf::RenderWindow*> dialog_stack;
|
||||
cDialog* next = this;
|
||||
while(next != nullptr){
|
||||
dialog_stack.push_back(&(next->win));
|
||||
next = next->parent;
|
||||
}
|
||||
for(int i = dialog_stack.size() - 1; i >= 0; --i){
|
||||
makeFrontWindow(*(dialog_stack[i]));
|
||||
}
|
||||
stackWindowsCorrectly();
|
||||
}
|
||||
BOOST_FALLTHROUGH;
|
||||
case sf::Event::MouseMoved:{
|
||||
|
@@ -82,6 +82,7 @@ public:
|
||||
static void (*redraw_everything)();
|
||||
static std::function<void(sf::RenderWindow& win)> onLostFocus;
|
||||
static std::function<void(sf::RenderWindow& win)> onGainedFocus;
|
||||
void stackWindowsCorrectly();
|
||||
/// Performs essential startup initialization. Generally should not be called directly.
|
||||
static void init();
|
||||
static bool wasInitCalled() { return initCalled; };
|
||||
|
Reference in New Issue
Block a user