Centralize retained dialog close bindings
This commit is contained in:
@@ -74,4 +74,12 @@ void bind_legacy_popup_close_destroys_overlay(
|
||||
};
|
||||
}
|
||||
|
||||
template <class ButtonT>
|
||||
void bind_legacy_click_destroys_node(ButtonT& button, Node& target) noexcept
|
||||
{
|
||||
button.on_click = [&target](Node*) {
|
||||
target.destroy();
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace pp::panopainter
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "pch.h"
|
||||
#include "log.h"
|
||||
#include "legacy_ui_overlay_services.h"
|
||||
#include "node_about.h"
|
||||
#include "layout.h"
|
||||
|
||||
@@ -16,7 +17,7 @@ void NodeAbout::init()
|
||||
SetPositioning(YGPositionTypeAbsolute);
|
||||
add_child_file("data/dialogs/about.xml", "about");
|
||||
btn_ok = find<NodeButton>("btn-ok");
|
||||
btn_ok->on_click = [&](Node*) { destroy(); };
|
||||
pp::panopainter::bind_legacy_click_destroys_node(*btn_ok, *this);
|
||||
}
|
||||
|
||||
kEventResult NodeAbout::handle_event(Event* e)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "pch.h"
|
||||
#include "log.h"
|
||||
#include "legacy_ui_overlay_services.h"
|
||||
#include "node_changelog.h"
|
||||
#include "layout.h"
|
||||
|
||||
@@ -16,7 +17,7 @@ void NodeChangelog::init()
|
||||
SetPositioning(YGPositionTypeAbsolute);
|
||||
add_child_file("data/dialogs/changelog.xml", "changelog");
|
||||
btn_ok = find<NodeButton>("btn-ok");
|
||||
btn_ok->on_click = [&](Node*) { destroy(); };
|
||||
pp::panopainter::bind_legacy_click_destroys_node(*btn_ok, *this);
|
||||
}
|
||||
|
||||
kEventResult NodeChangelog::handle_event(Event* e)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "pch.h"
|
||||
#include "log.h"
|
||||
#include "legacy_ui_overlay_services.h"
|
||||
#include "node_settings.h"
|
||||
#include "layout.h"
|
||||
|
||||
@@ -16,7 +17,7 @@ void NodeSettings::init()
|
||||
SetPositioning(YGPositionTypeAbsolute);
|
||||
add_child_file("data/dialogs/settings.xml", "settings");
|
||||
btnOk = find<NodeButton>("btn-ok");
|
||||
btnOk->on_click = [&](Node*) { destroy(); };
|
||||
pp::panopainter::bind_legacy_click_destroys_node(*btnOk, *this);
|
||||
}
|
||||
|
||||
kEventResult NodeSettings::handle_event(Event* e)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "pch.h"
|
||||
#include "log.h"
|
||||
#include "legacy_ui_overlay_services.h"
|
||||
#include "node_usermanual.h"
|
||||
#include "layout.h"
|
||||
|
||||
@@ -16,7 +17,7 @@ void NodeUserManual::init()
|
||||
SetPositioning(YGPositionTypeAbsolute);
|
||||
add_child_file("data/dialogs/usermanual.xml", "usermanual");
|
||||
btn_ok = find<NodeButton>("btn-ok");
|
||||
btn_ok->on_click = [&](Node*) { destroy(); };
|
||||
pp::panopainter::bind_legacy_click_destroys_node(*btn_ok, *this);
|
||||
}
|
||||
|
||||
kEventResult NodeUserManual::handle_event(Event* e)
|
||||
|
||||
Reference in New Issue
Block a user