mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-02-12 09:38:20 +00:00
Merge pull request #9476 from unknownbrackets/ui-transform
UI: Make popups transition their button
This commit is contained in:
commit
41a3370035
@ -266,6 +266,8 @@ UI::EventReturn ControlMappingScreen::OnAutoConfigure(UI::EventParams ¶ms) {
|
||||
}
|
||||
I18NCategory *km = GetI18NCategory("KeyMapping");
|
||||
ListPopupScreen *autoConfList = new ListPopupScreen(km->T("Autoconfigure for device"), items, -1);
|
||||
if (params.v)
|
||||
autoConfList->SetPopupOrigin(params.v);
|
||||
screenManager()->push(autoConfList);
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
@ -287,6 +287,8 @@ UI::EventReturn LogConfigScreen::OnLogLevel(UI::EventParams &e) {
|
||||
|
||||
auto logLevelScreen = new LogLevelScreen(dev->T("Log Level"));
|
||||
logLevelScreen->OnChoice.Handle(this, &LogConfigScreen::OnLogLevelChange);
|
||||
if (e.v)
|
||||
logLevelScreen->SetPopupOrigin(e.v);
|
||||
screenManager()->push(logLevelScreen);
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
@ -294,7 +296,7 @@ UI::EventReturn LogConfigScreen::OnLogLevel(UI::EventParams &e) {
|
||||
LogLevelScreen::LogLevelScreen(const std::string &title) : ListPopupScreen(title) {
|
||||
int NUMLOGLEVEL = 6;
|
||||
std::vector<std::string> list;
|
||||
for(int i = 0; i < NUMLOGLEVEL; ++i) {
|
||||
for (int i = 0; i < NUMLOGLEVEL; ++i) {
|
||||
list.push_back(logLevelList[i]);
|
||||
}
|
||||
adaptor_ = UI::StringVectorListAdaptor(list, -1);
|
||||
@ -552,7 +554,7 @@ void AddressPromptScreen::CreatePopupContents(UI::ViewGroup *parent) {
|
||||
|
||||
void AddressPromptScreen::OnCompleted(DialogResult result) {
|
||||
if (result == DR_OK) {
|
||||
UI::EventParams e;
|
||||
UI::EventParams e{};
|
||||
e.v = root_;
|
||||
e.a = addr_;
|
||||
OnChoice.Trigger(e);
|
||||
@ -655,7 +657,7 @@ void JitCompareScreen::CreateViews() {
|
||||
blockAddr_->OnTextChange.Handle(this, &JitCompareScreen::OnAddressChange);
|
||||
blockStats_ = leftColumn->Add(new TextView(""));
|
||||
|
||||
EventParams ignore = {0};
|
||||
EventParams ignore{};
|
||||
OnCurrentBlock(ignore);
|
||||
}
|
||||
|
||||
|
@ -792,7 +792,10 @@ void EmuScreen::CreateViews() {
|
||||
|
||||
UI::EventReturn EmuScreen::OnDevTools(UI::EventParams ¶ms) {
|
||||
releaseButtons();
|
||||
screenManager()->push(new DevMenu());
|
||||
DevMenu *devMenu = new DevMenu();
|
||||
if (params.v)
|
||||
devMenu->SetPopupOrigin(params.v);
|
||||
screenManager()->push(devMenu);
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
||||
|
@ -1101,6 +1101,8 @@ UI::EventReturn GameSettingsScreen::OnLanguage(UI::EventParams &e) {
|
||||
I18NCategory *dev = GetI18NCategory("Developer");
|
||||
auto langScreen = new NewLanguageScreen(dev->T("Language"));
|
||||
langScreen->OnChoice.Handle(this, &GameSettingsScreen::OnLanguageChange);
|
||||
if (e.v)
|
||||
langScreen->SetPopupOrigin(e.v);
|
||||
screenManager()->push(langScreen);
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
@ -1118,6 +1120,8 @@ UI::EventReturn GameSettingsScreen::OnPostProcShader(UI::EventParams &e) {
|
||||
I18NCategory *gr = GetI18NCategory("Graphics");
|
||||
auto procScreen = new PostProcScreen(gr->T("Postprocessing Shader"));
|
||||
procScreen->OnChoice.Handle(this, &GameSettingsScreen::OnPostProcShaderChange);
|
||||
if (e.v)
|
||||
procScreen->SetPopupOrigin(e.v);
|
||||
screenManager()->push(procScreen);
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
@ -150,14 +150,14 @@ public:
|
||||
private:
|
||||
void TriggerOnHoldClick() {
|
||||
holdStart_ = 0.0;
|
||||
UI::EventParams e;
|
||||
UI::EventParams e{};
|
||||
e.v = this;
|
||||
e.s = gamePath_;
|
||||
down_ = false;
|
||||
OnHoldClick.Trigger(e);
|
||||
}
|
||||
void TriggerOnHighlight(int focusFlags) {
|
||||
UI::EventParams e;
|
||||
UI::EventParams e{};
|
||||
e.v = this;
|
||||
e.s = gamePath_;
|
||||
e.a = focusFlags;
|
||||
|
@ -242,7 +242,7 @@ static void AfterSaveStateAction(bool status, const std::string &message, void *
|
||||
UI::EventReturn SaveSlotView::OnLoadState(UI::EventParams &e) {
|
||||
g_Config.iCurrentStateSlot = slot_;
|
||||
SaveState::LoadSlot(gamePath_, slot_, &AfterSaveStateAction);
|
||||
UI::EventParams e2;
|
||||
UI::EventParams e2{};
|
||||
e2.v = this;
|
||||
OnStateLoaded.Trigger(e2);
|
||||
return UI::EVENT_DONE;
|
||||
@ -251,14 +251,14 @@ UI::EventReturn SaveSlotView::OnLoadState(UI::EventParams &e) {
|
||||
UI::EventReturn SaveSlotView::OnSaveState(UI::EventParams &e) {
|
||||
g_Config.iCurrentStateSlot = slot_;
|
||||
SaveState::SaveSlot(gamePath_, slot_, &AfterSaveStateAction);
|
||||
UI::EventParams e2;
|
||||
UI::EventParams e2{};
|
||||
e2.v = this;
|
||||
OnStateSaved.Trigger(e2);
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
||||
UI::EventReturn SaveSlotView::OnScreenshotClick(UI::EventParams &e) {
|
||||
UI::EventParams e2;
|
||||
UI::EventParams e2{};
|
||||
e2.v = this;
|
||||
OnScreenshotClicked.Trigger(e2);
|
||||
return UI::EVENT_DONE;
|
||||
|
@ -119,7 +119,7 @@ EventReturn RatingChoice::OnChoiceClick(EventParams &e) {
|
||||
}
|
||||
}
|
||||
|
||||
EventParams e2;
|
||||
EventParams e2{};
|
||||
e2.v = e.v;
|
||||
e2.a = *value_;
|
||||
// Dispatch immediately (we're already on the UI thread as we're in an event handler).
|
||||
|
@ -330,7 +330,8 @@ void SavedataBrowser::Refresh() {
|
||||
|
||||
UI::EventReturn SavedataBrowser::SavedataButtonClick(UI::EventParams &e) {
|
||||
SavedataButton *button = static_cast<SavedataButton *>(e.v);
|
||||
UI::EventParams e2;
|
||||
UI::EventParams e2{};
|
||||
e2.v = e.v;
|
||||
e2.s = button->GamePath();
|
||||
// Insta-update - here we know we are already on the right thread.
|
||||
OnChoice.Trigger(e2);
|
||||
@ -378,7 +379,11 @@ void SavedataScreen::CreateViews() {
|
||||
|
||||
UI::EventReturn SavedataScreen::OnSavedataButtonClick(UI::EventParams &e) {
|
||||
GameInfo *ginfo = g_gameInfoCache->GetInfo(screenManager()->getDrawContext(), e.s, 0);
|
||||
screenManager()->push(new SavedataPopupScreen(e.s, ginfo->GetTitle()));
|
||||
SavedataPopupScreen *popupScreen = new SavedataPopupScreen(e.s, ginfo->GetTitle());
|
||||
if (e.v) {
|
||||
popupScreen->SetPopupOrigin(e.v);
|
||||
}
|
||||
screenManager()->push(popupScreen);
|
||||
// the game path: e.s;
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
@ -313,7 +313,8 @@ UI::EventReturn ProductView::OnLaunchClick(UI::EventParams &e) {
|
||||
path = ReplaceAll(path, "\\", "/");
|
||||
#endif
|
||||
|
||||
UI::EventParams e2;
|
||||
UI::EventParams e2{};
|
||||
e2.v = e.v;
|
||||
e2.s = path;
|
||||
// Insta-update - here we know we are already on the right thread.
|
||||
OnClickLaunch.Trigger(e2);
|
||||
|
@ -237,7 +237,7 @@ bool PopupScreen::touch(const TouchInput &touch) {
|
||||
bool PopupScreen::key(const KeyInput &key) {
|
||||
if (key.flags & KEY_DOWN) {
|
||||
if (key.keyCode == NKCODE_ENTER && defaultButton_) {
|
||||
UI::EventParams e;
|
||||
UI::EventParams e{};
|
||||
defaultButton_->OnClick.Trigger(e);
|
||||
return true;
|
||||
}
|
||||
@ -252,32 +252,51 @@ void PopupScreen::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));
|
||||
alpha_ = leadIn;
|
||||
scale_.x = 0.9f + leadIn * 0.1f;
|
||||
scale_.y = 0.9f + leadIn * 0.1f;
|
||||
translation_.y = -dp_yres * (1.0f - leadIn) * 0.5f;
|
||||
animatePos = leadIn;
|
||||
} 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;
|
||||
animatePos = 1.0f - leadOut;
|
||||
|
||||
if (frames_ >= finishFrame_ + FRAMES_LEAD_OUT) {
|
||||
// Actual finish happens here.
|
||||
screenManager()->finishDialog(this, finishResult_);
|
||||
}
|
||||
}
|
||||
|
||||
if (animatePos < 1.0f) {
|
||||
alpha_ = animatePos;
|
||||
scale_.x = 0.9f + animatePos * 0.1f;
|
||||
scale_.y = 0.9f + animatePos * 0.1f;
|
||||
|
||||
if (hasPopupOrigin_) {
|
||||
float xoff = popupOrigin_.x - dp_xres / 2;
|
||||
float yoff = popupOrigin_.y - dp_yres / 2;
|
||||
|
||||
// Pull toward the origin a bit.
|
||||
translation_.x = xoff * (1.0f - animatePos) * 0.2f;
|
||||
translation_.y = yoff * (1.0f - animatePos) * 0.2f;
|
||||
} else {
|
||||
translation_.y = -dp_yres * (1.0f - animatePos) * 0.2f;
|
||||
}
|
||||
} else {
|
||||
alpha_ = 1.0f;
|
||||
scale_.x = 1.0f;
|
||||
scale_.y = 1.0f;
|
||||
translation_.x = 0.0f;
|
||||
translation_.y = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
void PopupScreen::SetPopupOrigin(const UI::View *view) {
|
||||
hasPopupOrigin_ = true;
|
||||
popupOrigin_ = view->GetBounds().Center();
|
||||
}
|
||||
|
||||
void PopupScreen::TriggerFinish(DialogResult result) {
|
||||
finishFrame_ = frames_;
|
||||
finishResult_ = result;
|
||||
@ -391,6 +410,8 @@ UI::EventReturn PopupMultiChoice::HandleClick(UI::EventParams &e) {
|
||||
ListPopupScreen *popupScreen = new ListPopupScreen(ChopTitle(text_), choices, *value_ - minVal_,
|
||||
std::bind(&PopupMultiChoice::ChoiceCallback, this, std::placeholders::_1));
|
||||
popupScreen->SetHiddenChoices(hidden_);
|
||||
if (e.v)
|
||||
popupScreen->SetPopupOrigin(e.v);
|
||||
screenManager_->push(popupScreen);
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
@ -414,7 +435,7 @@ void PopupMultiChoice::ChoiceCallback(int num) {
|
||||
*value_ = num + minVal_;
|
||||
UpdateText();
|
||||
|
||||
UI::EventParams e;
|
||||
UI::EventParams e{};
|
||||
e.v = this;
|
||||
e.a = num;
|
||||
OnChoice.Trigger(e);
|
||||
@ -470,6 +491,8 @@ EventReturn PopupSliderChoice::HandleClick(EventParams &e) {
|
||||
|
||||
SliderPopupScreen *popupScreen = new SliderPopupScreen(value_, minValue_, maxValue_, ChopTitle(text_), step_, units_);
|
||||
popupScreen->OnChange.Handle(this, &PopupSliderChoice::HandleChange);
|
||||
if (e.v)
|
||||
popupScreen->SetPopupOrigin(e.v);
|
||||
screenManager_->push(popupScreen);
|
||||
return EVENT_DONE;
|
||||
}
|
||||
@ -512,6 +535,8 @@ EventReturn PopupSliderChoiceFloat::HandleClick(EventParams &e) {
|
||||
|
||||
SliderFloatPopupScreen *popupScreen = new SliderFloatPopupScreen(value_, minValue_, maxValue_, ChopTitle(text_), step_, units_);
|
||||
popupScreen->OnChange.Handle(this, &PopupSliderChoiceFloat::HandleChange);
|
||||
if (e.v)
|
||||
popupScreen->SetPopupOrigin(e.v);
|
||||
screenManager_->push(popupScreen);
|
||||
return EVENT_DONE;
|
||||
}
|
||||
@ -691,8 +716,8 @@ EventReturn SliderFloatPopupScreen::OnTextChange(EventParams ¶ms) {
|
||||
void SliderPopupScreen::OnCompleted(DialogResult result) {
|
||||
if (result == DR_OK) {
|
||||
*value_ = sliderValue_;
|
||||
EventParams e;
|
||||
e.v = 0;
|
||||
EventParams e{};
|
||||
e.v = nullptr;
|
||||
e.a = *value_;
|
||||
OnChange.Trigger(e);
|
||||
}
|
||||
@ -701,8 +726,8 @@ void SliderPopupScreen::OnCompleted(DialogResult result) {
|
||||
void SliderFloatPopupScreen::OnCompleted(DialogResult result) {
|
||||
if (result == DR_OK) {
|
||||
*value_ = sliderValue_;
|
||||
EventParams e;
|
||||
e.v = 0;
|
||||
EventParams e{};
|
||||
e.v = nullptr;
|
||||
e.a = (int)*value_;
|
||||
e.f = *value_;
|
||||
OnChange.Trigger(e);
|
||||
@ -719,6 +744,8 @@ EventReturn PopupTextInputChoice::HandleClick(EventParams &e) {
|
||||
|
||||
TextEditPopupScreen *popupScreen = new TextEditPopupScreen(value_, placeHolder_, ChopTitle(text_), maxLen_);
|
||||
popupScreen->OnChange.Handle(this, &PopupTextInputChoice::HandleChange);
|
||||
if (e.v)
|
||||
popupScreen->SetPopupOrigin(e.v);
|
||||
screenManager_->push(popupScreen);
|
||||
return EVENT_DONE;
|
||||
}
|
||||
@ -765,7 +792,7 @@ void TextEditPopupScreen::CreatePopupContents(UI::ViewGroup *parent) {
|
||||
void TextEditPopupScreen::OnCompleted(DialogResult result) {
|
||||
if (result == DR_OK) {
|
||||
*value_ = edit_->GetText();
|
||||
EventParams e;
|
||||
EventParams e{};
|
||||
e.v = edit_;
|
||||
OnChange.Trigger(e);
|
||||
}
|
||||
|
@ -74,6 +74,8 @@ public:
|
||||
|
||||
virtual void TriggerFinish(DialogResult result) override;
|
||||
|
||||
void SetPopupOrigin(const UI::View *view);
|
||||
|
||||
protected:
|
||||
virtual bool FillVertical() const { return false; }
|
||||
virtual UI::Size PopupWidth() const { return 550; }
|
||||
@ -92,6 +94,8 @@ private:
|
||||
int frames_ = 0;
|
||||
int finishFrame_ = 0;
|
||||
DialogResult finishResult_;
|
||||
bool hasPopupOrigin_ = false;
|
||||
Point popupOrigin_;
|
||||
};
|
||||
|
||||
class ListPopupScreen : public PopupScreen {
|
||||
|
@ -234,7 +234,7 @@ bool View::SetFocus() {
|
||||
}
|
||||
|
||||
void Clickable::Click() {
|
||||
UI::EventParams e;
|
||||
UI::EventParams e{};
|
||||
e.v = this;
|
||||
OnClick.Trigger(e);
|
||||
};
|
||||
@ -874,7 +874,8 @@ bool TextEdit::Key(const KeyInput &input) {
|
||||
break;
|
||||
case NKCODE_ENTER:
|
||||
{
|
||||
EventParams e;
|
||||
EventParams e{};
|
||||
e.v = this;
|
||||
e.s = text_;
|
||||
OnEnter.Trigger(e);
|
||||
break;
|
||||
@ -955,7 +956,7 @@ bool TextEdit::Key(const KeyInput &input) {
|
||||
}
|
||||
|
||||
if (textChanged) {
|
||||
UI::EventParams e;
|
||||
UI::EventParams e{};
|
||||
e.v = this;
|
||||
OnTextChange.Trigger(e);
|
||||
}
|
||||
@ -1071,7 +1072,7 @@ void Slider::Touch(const TouchInput &input) {
|
||||
float relativeX = (input.x - (bounds_.x + paddingLeft_)) / (bounds_.w - paddingLeft_ - paddingRight_);
|
||||
*value_ = floorf(relativeX * (maxValue_ - minValue_) + minValue_ + 0.5f);
|
||||
Clamp();
|
||||
EventParams params;
|
||||
EventParams params{};
|
||||
params.v = this;
|
||||
params.a = (uint32_t)(*value_);
|
||||
params.f = (float)(*value_);
|
||||
@ -1183,7 +1184,7 @@ void SliderFloat::Touch(const TouchInput &input) {
|
||||
float relativeX = (input.x - (bounds_.x + paddingLeft_)) / (bounds_.w - paddingLeft_ - paddingRight_);
|
||||
*value_ = (relativeX * (maxValue_ - minValue_) + minValue_);
|
||||
Clamp();
|
||||
EventParams params;
|
||||
EventParams params{};
|
||||
params.v = this;
|
||||
params.a = (uint32_t)(*value_);
|
||||
params.f = (float)(*value_);
|
||||
|
@ -1212,7 +1212,7 @@ EventReturn ChoiceStrip::OnChoiceClick(EventParams &e) {
|
||||
}
|
||||
}
|
||||
|
||||
EventParams e2;
|
||||
EventParams e2{};
|
||||
e2.v = views_[selected_];
|
||||
e2.a = selected_;
|
||||
// Set to 1 to indicate an explicit click.
|
||||
@ -1232,7 +1232,7 @@ void ChoiceStrip::SetSelection(int sel) {
|
||||
newChoice->Press();
|
||||
|
||||
if (topTabs_ && prevSelected != selected_) {
|
||||
EventParams e;
|
||||
EventParams e{};
|
||||
e.v = views_[selected_];
|
||||
e.a = selected_;
|
||||
// Set to 0 to indicate a selection change (not a click.)
|
||||
@ -1305,8 +1305,8 @@ void ListView::Measure(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert)
|
||||
}
|
||||
|
||||
EventReturn ListView::OnItemCallback(int num, EventParams &e) {
|
||||
EventParams ev;
|
||||
ev.v = 0;
|
||||
EventParams ev{};
|
||||
ev.v = nullptr;
|
||||
ev.a = num;
|
||||
adaptor_->SetSelected(num);
|
||||
View *focused = GetFocusedView();
|
||||
|
Loading…
x
Reference in New Issue
Block a user