Add ScreenStack::clear_screens()
This commit is contained in:
parent
a0dbf2b172
commit
1feefc5d9b
2 changed files with 15 additions and 1 deletions
|
@ -56,6 +56,10 @@ void ScreenStack::pop_screen() {
|
|||
actions.push_back(PendingAction(Action::POP_SCREEN));
|
||||
}
|
||||
|
||||
void ScreenStack::clear_screens() {
|
||||
actions.push_back(PendingAction(Action::CLEAR_SCREENS));
|
||||
}
|
||||
|
||||
ScreenStack::ScreenStack() : self_weak(), stack(), actions() {}
|
||||
|
||||
void ScreenStack::handle_pending_actions() {
|
||||
|
@ -74,6 +78,14 @@ void ScreenStack::handle_pending_actions() {
|
|||
}
|
||||
#endif // NDEBUG
|
||||
break;
|
||||
case Action::CLEAR_SCREENS:
|
||||
#ifndef NDEBUG
|
||||
if (stack.empty()) {
|
||||
std::cerr << "WARNING: Clearing an empty screen stack!\n";
|
||||
}
|
||||
#endif
|
||||
stack.clear();
|
||||
break;
|
||||
case Action::NOP:
|
||||
// Intentionally left blank.
|
||||
break;
|
||||
|
|
|
@ -37,7 +37,7 @@ class Screen {
|
|||
|
||||
class ScreenStack {
|
||||
private:
|
||||
enum Action { PUSH_SCREEN, POP_SCREEN, NOP };
|
||||
enum Action { PUSH_SCREEN, POP_SCREEN, CLEAR_SCREENS, NOP };
|
||||
|
||||
struct PendingAction {
|
||||
PendingAction();
|
||||
|
@ -80,6 +80,8 @@ class ScreenStack {
|
|||
|
||||
void pop_screen();
|
||||
|
||||
void clear_screens();
|
||||
|
||||
private:
|
||||
ScreenStack();
|
||||
|
||||
|
|
Loading…
Reference in a new issue