mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
UI: Fade PopupScreens out too.
This commit is contained in:
parent
073e056369
commit
09dac5dfa3
3 changed files with 30 additions and 22 deletions
|
@ -607,7 +607,6 @@ bool AddressPromptScreen::key(const KeyInput &key) {
|
||||||
} else if (key.keyCode == NKCODE_DEL) {
|
} else if (key.keyCode == NKCODE_DEL) {
|
||||||
BackspaceDigit();
|
BackspaceDigit();
|
||||||
} else if (key.keyCode == NKCODE_ENTER) {
|
} else if (key.keyCode == NKCODE_ENTER) {
|
||||||
OnCompleted(DR_OK);
|
|
||||||
TriggerFinish(DR_OK);
|
TriggerFinish(DR_OK);
|
||||||
} else {
|
} else {
|
||||||
return UIDialogScreen::key(key);
|
return UIDialogScreen::key(key);
|
||||||
|
|
|
@ -250,12 +250,26 @@ void PopupScreen::update() {
|
||||||
UIDialogScreen::update();
|
UIDialogScreen::update();
|
||||||
|
|
||||||
static const int FRAMES_LEAD_IN = 6;
|
static const int FRAMES_LEAD_IN = 6;
|
||||||
if (++frames_ < FRAMES_LEAD_IN) {
|
static const int FRAMES_LEAD_OUT = 4;
|
||||||
|
|
||||||
|
++frames_;
|
||||||
|
if (frames_ < FRAMES_LEAD_IN) {
|
||||||
float leadIn = bezierEaseInOut(frames_ * (1.0f / (float)FRAMES_LEAD_IN));
|
float leadIn = bezierEaseInOut(frames_ * (1.0f / (float)FRAMES_LEAD_IN));
|
||||||
alpha_ = leadIn;
|
alpha_ = leadIn;
|
||||||
scale_.x = 0.9f + leadIn * 0.1f;
|
scale_.x = 0.9f + leadIn * 0.1f;
|
||||||
scale_.y = 0.9f + leadIn * 0.1f;
|
scale_.y = 0.9f + leadIn * 0.1f;
|
||||||
translation_.y = -dp_yres * (1.0f - leadIn) * 0.5f;
|
translation_.y = -dp_yres * (1.0f - leadIn) * 0.5f;
|
||||||
|
} else if (finishFrame_ > 0) {
|
||||||
|
float leadOut = bezierEaseInOut((frames_ - finishFrame_) * (1.0f / (float)FRAMES_LEAD_OUT));
|
||||||
|
alpha_ = 1.0f - leadOut;
|
||||||
|
scale_.x = 0.9f + (1.0f - leadOut) * 0.1f;
|
||||||
|
scale_.y = 0.9f + (1.0f - leadOut) * 0.1f;
|
||||||
|
translation_.y = -dp_yres * leadOut * 0.5f;
|
||||||
|
|
||||||
|
if (frames_ >= finishFrame_ + FRAMES_LEAD_OUT) {
|
||||||
|
// Actual finish happens here.
|
||||||
|
screenManager()->finishDialog(this, finishResult_);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
alpha_ = 1.0f;
|
alpha_ = 1.0f;
|
||||||
scale_.x = 1.0f;
|
scale_.x = 1.0f;
|
||||||
|
@ -264,6 +278,13 @@ void PopupScreen::update() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PopupScreen::TriggerFinish(DialogResult result) {
|
||||||
|
finishFrame_ = frames_;
|
||||||
|
finishResult_ = result;
|
||||||
|
|
||||||
|
OnCompleted(result);
|
||||||
|
}
|
||||||
|
|
||||||
void PopupScreen::CreateViews() {
|
void PopupScreen::CreateViews() {
|
||||||
using namespace UI;
|
using namespace UI;
|
||||||
|
|
||||||
|
@ -299,14 +320,14 @@ void PopupScreen::CreateViews() {
|
||||||
// Adjust button order to the platform default.
|
// Adjust button order to the platform default.
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
defaultButton_ = buttonRow->Add(new Button(button1_, new LinearLayoutParams(1.0f, buttonMargins)));
|
defaultButton_ = buttonRow->Add(new Button(button1_, new LinearLayoutParams(1.0f, buttonMargins)));
|
||||||
defaultButton_->OnClick.Handle(this, &PopupScreen::OnOK);
|
defaultButton_->OnClick.Handle<UIScreen>(this, &UIScreen::OnOK);
|
||||||
if (!button2_.empty())
|
if (!button2_.empty())
|
||||||
buttonRow->Add(new Button(button2_, new LinearLayoutParams(1.0f, buttonMargins)))->OnClick.Handle(this, &PopupScreen::OnCancel);
|
buttonRow->Add(new Button(button2_, new LinearLayoutParams(1.0f, buttonMargins)))->OnClick.Handle<UIScreen>(this, &UIScreen::OnCancel);
|
||||||
#else
|
#else
|
||||||
if (!button2_.empty())
|
if (!button2_.empty())
|
||||||
buttonRow->Add(new Button(button2_, new LinearLayoutParams(1.0f)))->OnClick.Handle(this, &PopupScreen::OnCancel);
|
buttonRow->Add(new Button(button2_, new LinearLayoutParams(1.0f)))->OnClick.Handle<UIScreen>(this, &UIScreen::OnCancel);
|
||||||
defaultButton_ = buttonRow->Add(new Button(button1_, new LinearLayoutParams(1.0f)));
|
defaultButton_ = buttonRow->Add(new Button(button1_, new LinearLayoutParams(1.0f)));
|
||||||
defaultButton_->OnClick.Handle(this, &PopupScreen::OnOK);
|
defaultButton_->OnClick.Handle<UIScreen>(this, &UIScreen::OnOK);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
box_->Add(buttonRow);
|
box_->Add(buttonRow);
|
||||||
|
@ -330,18 +351,6 @@ void MessagePopupScreen::OnCompleted(DialogResult result) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UI::EventReturn PopupScreen::OnOK(UI::EventParams &e) {
|
|
||||||
OnCompleted(DR_OK);
|
|
||||||
TriggerFinish(DR_OK);
|
|
||||||
return UI::EVENT_DONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
UI::EventReturn PopupScreen::OnCancel(UI::EventParams &e) {
|
|
||||||
OnCompleted(DR_CANCEL);
|
|
||||||
TriggerFinish(DR_CANCEL);
|
|
||||||
return UI::EVENT_DONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ListPopupScreen::CreatePopupContents(UI::ViewGroup *parent) {
|
void ListPopupScreen::CreatePopupContents(UI::ViewGroup *parent) {
|
||||||
using namespace UI;
|
using namespace UI;
|
||||||
|
|
||||||
|
@ -355,7 +364,6 @@ UI::EventReturn ListPopupScreen::OnListChoice(UI::EventParams &e) {
|
||||||
if (callback_)
|
if (callback_)
|
||||||
callback_(adaptor_.GetSelected());
|
callback_(adaptor_.GetSelected());
|
||||||
TriggerFinish(DR_OK);
|
TriggerFinish(DR_OK);
|
||||||
OnCompleted(DR_OK);
|
|
||||||
OnChoice.Dispatch(e);
|
OnChoice.Dispatch(e);
|
||||||
return UI::EVENT_DONE;
|
return UI::EVENT_DONE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,6 +72,8 @@ public:
|
||||||
virtual bool touch(const TouchInput &touch) override;
|
virtual bool touch(const TouchInput &touch) override;
|
||||||
virtual bool key(const KeyInput &key) override;
|
virtual bool key(const KeyInput &key) override;
|
||||||
|
|
||||||
|
virtual void TriggerFinish(DialogResult result) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool FillVertical() const { return false; }
|
virtual bool FillVertical() const { return false; }
|
||||||
virtual UI::Size PopupWidth() const { return 550; }
|
virtual UI::Size PopupWidth() const { return 550; }
|
||||||
|
@ -81,9 +83,6 @@ protected:
|
||||||
virtual void update() override;
|
virtual void update() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UI::EventReturn OnOK(UI::EventParams &e);
|
|
||||||
UI::EventReturn OnCancel(UI::EventParams &e);
|
|
||||||
|
|
||||||
UI::ViewGroup *box_;
|
UI::ViewGroup *box_;
|
||||||
UI::Button *defaultButton_;
|
UI::Button *defaultButton_;
|
||||||
std::string title_;
|
std::string title_;
|
||||||
|
@ -91,6 +90,8 @@ private:
|
||||||
std::string button2_;
|
std::string button2_;
|
||||||
|
|
||||||
int frames_ = 0;
|
int frames_ = 0;
|
||||||
|
int finishFrame_ = 0;
|
||||||
|
DialogResult finishResult_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ListPopupScreen : public PopupScreen {
|
class ListPopupScreen : public PopupScreen {
|
||||||
|
|
Loading…
Add table
Reference in a new issue