diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-07-29 02:12:03 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-07-29 02:12:03 +1000 |
commit | 224ad2c2c07311475875d1d243354f8647112b45 (patch) | |
tree | c8247f22b4ddda345b7f35d7c6ead25d5e1f2791 /source/windowing | |
parent | 35fc2679dea7b625bf559c6855e101fc62e613f4 (diff) |
Reset script panes on character swap
Diffstat (limited to 'source/windowing')
-rw-r--r-- | source/windowing/StarPaneManager.cpp | 17 | ||||
-rw-r--r-- | source/windowing/StarPaneManager.hpp | 2 | ||||
-rw-r--r-- | source/windowing/StarWidget.cpp | 4 | ||||
-rw-r--r-- | source/windowing/StarWidget.hpp | 1 |
4 files changed, 24 insertions, 0 deletions
diff --git a/source/windowing/StarPaneManager.cpp b/source/windowing/StarPaneManager.cpp index f34c786..9dd7737 100644 --- a/source/windowing/StarPaneManager.cpp +++ b/source/windowing/StarPaneManager.cpp @@ -128,6 +128,23 @@ void PaneManager::setBackgroundWidget(WidgetPtr bg) { m_backgroundWidget = bg; } +void PaneManager::dismissWhere(function<bool(PanePtr const&)> func) { + if (!func) + return; + + for (auto& layerPair : m_displayedPanes) { + eraseWhere(layerPair.second, [&](auto& panePair) { + if (func(panePair.first)) { + panePair.first->dismissed(); + if (panePair.second) + panePair.second(panePair.first); + return true; + } + return false; + }); + } +} + PanePtr PaneManager::keyboardCapturedPane() const { for (auto const& layerPair : m_displayedPanes) { for (auto const& panePair : layerPair.second) { diff --git a/source/windowing/StarPaneManager.hpp b/source/windowing/StarPaneManager.hpp index 8adf772..e69f699 100644 --- a/source/windowing/StarPaneManager.hpp +++ b/source/windowing/StarPaneManager.hpp @@ -63,6 +63,8 @@ public: void setBackgroundWidget(WidgetPtr bg); + void dismissWhere(function<bool(PanePtr const&)> func); + // Returns the pane that has captured the keyboard, if any. PanePtr keyboardCapturedPane() const; // Returns true if the current pane that has captured the keyboard is diff --git a/source/windowing/StarWidget.cpp b/source/windowing/StarWidget.cpp index 48b945f..0287288 100644 --- a/source/windowing/StarWidget.cpp +++ b/source/windowing/StarWidget.cpp @@ -219,6 +219,10 @@ void Widget::hide() { m_visible = false; } +bool Widget::visibility() const { + return m_visible; +} + void Widget::toggleVisibility() { m_visible = !m_visible; } diff --git a/source/windowing/StarWidget.hpp b/source/windowing/StarWidget.hpp index f6e9928..1e78d74 100644 --- a/source/windowing/StarWidget.hpp +++ b/source/windowing/StarWidget.hpp @@ -58,6 +58,7 @@ public: virtual void show(); virtual void hide(); + virtual bool visibility() const; virtual void toggleVisibility(); virtual void setVisibility(bool visibility); |