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));
|
actions.push_back(PendingAction(Action::POP_SCREEN));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScreenStack::clear_screens() {
|
||||||
|
actions.push_back(PendingAction(Action::CLEAR_SCREENS));
|
||||||
|
}
|
||||||
|
|
||||||
ScreenStack::ScreenStack() : self_weak(), stack(), actions() {}
|
ScreenStack::ScreenStack() : self_weak(), stack(), actions() {}
|
||||||
|
|
||||||
void ScreenStack::handle_pending_actions() {
|
void ScreenStack::handle_pending_actions() {
|
||||||
|
@ -74,6 +78,14 @@ void ScreenStack::handle_pending_actions() {
|
||||||
}
|
}
|
||||||
#endif // NDEBUG
|
#endif // NDEBUG
|
||||||
break;
|
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:
|
case Action::NOP:
|
||||||
// Intentionally left blank.
|
// Intentionally left blank.
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -37,7 +37,7 @@ class Screen {
|
||||||
|
|
||||||
class ScreenStack {
|
class ScreenStack {
|
||||||
private:
|
private:
|
||||||
enum Action { PUSH_SCREEN, POP_SCREEN, NOP };
|
enum Action { PUSH_SCREEN, POP_SCREEN, CLEAR_SCREENS, NOP };
|
||||||
|
|
||||||
struct PendingAction {
|
struct PendingAction {
|
||||||
PendingAction();
|
PendingAction();
|
||||||
|
@ -80,6 +80,8 @@ class ScreenStack {
|
||||||
|
|
||||||
void pop_screen();
|
void pop_screen();
|
||||||
|
|
||||||
|
void clear_screens();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ScreenStack();
|
ScreenStack();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue