From 755429df81b7ac77e299be3fd396b46c08a8dca0 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 26 Mar 2017 08:58:04 -0700 Subject: [PATCH] UI: Fix issues with insta-close pop ups. Not that these should happen, but at least should make sure they work. --- ext/native/ui/ui_screen.cpp | 11 ++++------- ext/native/ui/ui_screen.h | 7 ++++++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/ext/native/ui/ui_screen.cpp b/ext/native/ui/ui_screen.cpp index c2e788e990..21a0c37920 100644 --- a/ext/native/ui/ui_screen.cpp +++ b/ext/native/ui/ui_screen.cpp @@ -249,16 +249,10 @@ bool PopupScreen::key(const KeyInput &key) { void PopupScreen::update() { UIDialogScreen::update(); - static const int FRAMES_LEAD_IN = 6; - static const int FRAMES_LEAD_OUT = 4; - float animatePos = 1.0f; ++frames_; - if (frames_ < FRAMES_LEAD_IN) { - float leadIn = bezierEaseInOut(frames_ * (1.0f / (float)FRAMES_LEAD_IN)); - animatePos = leadIn; - } else if (finishFrame_ > 0) { + if (finishFrame_ >= 0) { float leadOut = bezierEaseInOut((frames_ - finishFrame_) * (1.0f / (float)FRAMES_LEAD_OUT)); animatePos = 1.0f - leadOut; @@ -266,6 +260,9 @@ void PopupScreen::update() { // Actual finish happens here. screenManager()->finishDialog(this, finishResult_); } + } else if (frames_ < FRAMES_LEAD_IN) { + float leadIn = bezierEaseInOut(frames_ * (1.0f / (float)FRAMES_LEAD_IN)); + animatePos = leadIn; } if (animatePos < 1.0f) { diff --git a/ext/native/ui/ui_screen.h b/ext/native/ui/ui_screen.h index c2f0275d66..cb894999f5 100644 --- a/ext/native/ui/ui_screen.h +++ b/ext/native/ui/ui_screen.h @@ -91,8 +91,13 @@ private: std::string button1_; std::string button2_; + enum { + FRAMES_LEAD_IN = 6, + FRAMES_LEAD_OUT = 4, + }; + int frames_ = 0; - int finishFrame_ = 0; + int finishFrame_ = -1; DialogResult finishResult_; bool hasPopupOrigin_ = false; Point popupOrigin_;