UI: Rework Document close handling again

This commit is contained in:
Luke Street
2026-05-02 12:10:14 -06:00
parent 6f20f4d629
commit f148e0ebc1
12 changed files with 76 additions and 104 deletions
+5 -10
View File
@@ -35,7 +35,6 @@ Document::Document(const Rml::String& source) : mDocument(load_document(source))
listen(Rml::EventId::Mouseover, blockUnlessVisible, true);
listen(Rml::EventId::Click, blockUnlessVisible, true);
listen(Rml::EventId::Scroll, blockUnlessVisible, true);
listen(Rml::EventId::Focus, blockUnlessVisible, true);
listen(Rml::EventId::Keydown, [this](Rml::Event& event) {
const auto cmd = map_nav_event(event);
@@ -65,10 +64,13 @@ void Document::show() {
}
}
void Document::hide() {
void Document::hide(bool close) {
if (mDocument != nullptr) {
mDocument->Hide();
}
if (close) {
mClosed = true;
}
}
void Document::update() {}
@@ -89,13 +91,6 @@ void Document::listen(Rml::Element* element, Rml::EventId event,
std::make_unique<ScopedEventListener>(element, event, std::move(callback), capture));
}
bool Document::can_destroy() const {
if (mDocument == nullptr) {
return true;
}
return *mDocument->GetProperty(Rml::PropertyId::Visibility) == Rml::Style::Visibility::Hidden;
}
bool Document::visible() const {
if (mDocument == nullptr) {
return false;
@@ -105,7 +100,7 @@ bool Document::visible() const {
bool Document::handle_nav_command(Rml::Event& event, NavCommand cmd) {
if (cmd == NavCommand::Menu) {
toggle_top_document();
toggle();
return true;
}
return false;