diff --git a/Common/UI/UIScreen.cpp b/Common/UI/UIScreen.cpp index 63b743d33a..d1623101d0 100644 --- a/Common/UI/UIScreen.cpp +++ b/Common/UI/UIScreen.cpp @@ -20,12 +20,17 @@ static const bool ClickDebug = false; UIScreen::UIScreen() : Screen() { + lastVertical_ = UseVerticalLayout(); } UIScreen::~UIScreen() { delete root_; } +bool UIScreen::UseVerticalLayout() const { + return dp_yres > dp_xres * 1.1f; +} + void UIScreen::DoRecreateViews() { if (recreateViews_) { std::lock_guard guard(screenManager()->inputLock_); @@ -60,6 +65,12 @@ void UIScreen::DoRecreateViews() { } void UIScreen::update() { + bool vertical = UseVerticalLayout(); + if (vertical != lastVertical_) { + RecreateViews(); + lastVertical_ = vertical; + } + DoRecreateViews(); if (root_) { diff --git a/Common/UI/UIScreen.h b/Common/UI/UIScreen.h index 1b25dc4231..c9f0eb723e 100644 --- a/Common/UI/UIScreen.h +++ b/Common/UI/UIScreen.h @@ -42,7 +42,8 @@ protected: virtual void CreateViews() = 0; virtual void DrawBackground(UIContext &dc) {} - virtual void RecreateViews() override { recreateViews_ = true; } + void RecreateViews() override { recreateViews_ = true; } + bool UseVerticalLayout() const; UI::ViewGroup *root_ = nullptr; Vec3 translation_ = Vec3(0.0f); @@ -54,6 +55,7 @@ private: void DoRecreateViews(); bool recreateViews_ = true; + bool lastVertical_; }; class UIDialogScreen : public UIScreen { diff --git a/UI/DisplayLayoutScreen.cpp b/UI/DisplayLayoutScreen.cpp index 4764b069f0..46188760e3 100644 --- a/UI/DisplayLayoutScreen.cpp +++ b/UI/DisplayLayoutScreen.cpp @@ -199,16 +199,21 @@ void DisplayLayoutScreen::CreateViews() { root_ = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT)); + bool vertical = bounds.h > bounds.w; + // Make it so that a touch can only affect one view. Makes manipulating the background through the buttons // impossible. root_->SetExclusiveTouch(true); - ScrollView *leftScrollView = new ScrollView(ORIENT_VERTICAL, new AnchorLayoutParams(420.0f, FILL_PARENT, 0.f, 0.f, NONE, 0.f, false)); - LinearLayout *leftColumn = new LinearLayout(ORIENT_VERTICAL); - leftColumn->padding.SetAll(8.0f); - leftScrollView->Add(leftColumn); - leftScrollView->SetClickableBackground(true); - root_->Add(leftScrollView); + LinearLayout *leftColumn; + if (!vertical) { + ScrollView *leftScrollView = new ScrollView(ORIENT_VERTICAL, new AnchorLayoutParams(420.0f, FILL_PARENT, 0.f, 0.f, NONE, 0.f, false)); + leftColumn = new LinearLayout(ORIENT_VERTICAL); + leftColumn->padding.SetAll(8.0f); + leftScrollView->Add(leftColumn); + leftScrollView->SetClickableBackground(true); + root_->Add(leftScrollView); + } ScrollView *rightScrollView = new ScrollView(ORIENT_VERTICAL, new AnchorLayoutParams(300.0f, FILL_PARENT, NONE, 0.f, 0.f, 0.f, false)); LinearLayout *rightColumn = new LinearLayout(ORIENT_VERTICAL); @@ -217,8 +222,15 @@ void DisplayLayoutScreen::CreateViews() { rightScrollView->SetClickableBackground(true); root_->Add(rightScrollView); - LinearLayout *bottomControls = new LinearLayout(ORIENT_HORIZONTAL, new AnchorLayoutParams(NONE, NONE, NONE, 10.0f, false)); - root_->Add(bottomControls); + LinearLayout *bottomControls; + if (vertical) { + bottomControls = new LinearLayout(ORIENT_HORIZONTAL); + rightColumn->Add(bottomControls); + leftColumn = rightColumn; + } else { + bottomControls = new LinearLayout(ORIENT_HORIZONTAL, new AnchorLayoutParams(NONE, NONE, NONE, 10.0f, false)); + root_->Add(bottomControls); + } // Set backgrounds for readability Drawable backgroundWithAlpha(GetBackgroundColorWithAlpha(*screenManager()->getUIContext())); @@ -266,6 +278,10 @@ void DisplayLayoutScreen::CreateViews() { back->OnClick.Handle(this, &UIScreen::OnBack); rightColumn->Add(back); + if (vertical) { + leftColumn->Add(new Spacer(24.0f)); + } + static const char *bufFilters[] = { "Linear", "Nearest", }; leftColumn->Add(new PopupMultiChoice(&g_Config.iBufFilter, gr->T("Screen Scaling Filter"), bufFilters, 1, ARRAY_SIZE(bufFilters), gr->GetName(), screenManager())); diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 15d1987f02..3e2a3229a2 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -92,15 +92,10 @@ extern AndroidAudioState *g_audioState; GameSettingsScreen::GameSettingsScreen(const Path &gamePath, std::string gameID, bool editThenRestore) : UIDialogScreenWithGameBackground(gamePath), gameID_(gameID), editThenRestore_(editThenRestore) { - lastVertical_ = UseVerticalLayout(); prevInflightFrames_ = g_Config.iInflightFrames; analogSpeedMapped_ = KeyMap::AxisFromPspButton(VIRTKEY_SPEED_ANALOG, nullptr, nullptr, nullptr); } -bool GameSettingsScreen::UseVerticalLayout() const { - return dp_yres > dp_xres * 1.1f; -} - // This needs before run CheckGPUFeatures() // TODO: Remove this if fix the issue bool CheckSupportShaderTessellationGLES() { @@ -1297,16 +1292,6 @@ UI::EventReturn GameSettingsScreen::OnHwScaleChange(UI::EventParams &e) { return UI::EVENT_DONE; } -void GameSettingsScreen::update() { - UIScreen::update(); - - bool vertical = UseVerticalLayout(); - if (vertical != lastVertical_) { - RecreateViews(); - lastVertical_ = vertical; - } -} - void GameSettingsScreen::onFinish(DialogResult result) { if (g_Config.bEnableSound) { if (PSP_IsInited() && !IsAudioInitialised()) diff --git a/UI/GameSettingsScreen.h b/UI/GameSettingsScreen.h index 5b51ee101d..86d5881f56 100644 --- a/UI/GameSettingsScreen.h +++ b/UI/GameSettingsScreen.h @@ -30,7 +30,6 @@ class GameSettingsScreen : public UIDialogScreenWithGameBackground { public: GameSettingsScreen(const Path &gamePath, std::string gameID = "", bool editThenRestore = false); - void update() override; void onFinish(DialogResult result) override; const char *tag() const override { return "GameSettings"; } @@ -42,7 +41,6 @@ protected: void CallbackRenderingDevice(bool yes); void CallbackInflightFrames(bool yes); void CallbackMemstickFolder(bool yes); - bool UseVerticalLayout() const; void dialogFinished(const Screen *dialog, DialogResult result) override; void RecreateViews() override; @@ -52,7 +50,6 @@ private: void TriggerRestart(const char *why); std::string gameID_; - bool lastVertical_; UI::CheckBox *enableReportsCheckbox_; UI::Choice *layoutEditorChoice_; UI::Choice *displayEditor_; diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index 53d77213c2..0855e7eea6 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -966,7 +966,6 @@ UI::EventReturn GameBrowser::OnHomebrewStore(UI::EventParams &e) { MainScreen::MainScreen() { System_SendMessage("event", "mainscreen"); g_BackgroundAudio.SetGame(Path()); - lastVertical_ = UseVerticalLayout(); } MainScreen::~MainScreen() { @@ -1255,15 +1254,6 @@ void MainScreen::sendMessage(const char *message, const char *value) { void MainScreen::update() { UIScreen::update(); UpdateUIState(UISTATE_MENU); - bool vertical = UseVerticalLayout(); - if (vertical != lastVertical_) { - RecreateViews(); - lastVertical_ = vertical; - } -} - -bool MainScreen::UseVerticalLayout() const { - return dp_yres > dp_xres * 1.1f; } UI::EventReturn MainScreen::OnLoadFile(UI::EventParams &e) { diff --git a/UI/MainScreen.h b/UI/MainScreen.h index b81e193b93..995a912a92 100644 --- a/UI/MainScreen.h +++ b/UI/MainScreen.h @@ -114,7 +114,6 @@ protected: void sendMessage(const char *message, const char *value) override; void dialogFinished(const Screen *dialog, DialogResult result) override; - bool UseVerticalLayout() const; bool DrawBackgroundFor(UIContext &dc, const Path &gamePath, float progress); UI::EventReturn OnGameSelected(UI::EventParams &e); diff --git a/UI/PauseScreen.cpp b/UI/PauseScreen.cpp index 85d60a480f..d76824d9b1 100644 --- a/UI/PauseScreen.cpp +++ b/UI/PauseScreen.cpp @@ -132,7 +132,7 @@ UI::EventReturn ScreenshotViewScreen::OnUndoState(UI::EventParams &e) { class SaveSlotView : public UI::LinearLayout { public: - SaveSlotView(const Path &gamePath, int slot, UI::LayoutParams *layoutParams = nullptr); + SaveSlotView(const Path &gamePath, int slot, bool vertical, UI::LayoutParams *layoutParams = nullptr); void GetContentDimensions(const UIContext &dc, float &w, float &h) const override { w = 500; h = 90; @@ -169,7 +169,7 @@ private: Path screenshotFilename_; }; -SaveSlotView::SaveSlotView(const Path &gameFilename, int slot, UI::LayoutParams *layoutParams) : UI::LinearLayout(UI::ORIENT_HORIZONTAL, layoutParams), slot_(slot), gamePath_(gameFilename) { +SaveSlotView::SaveSlotView(const Path &gameFilename, int slot, bool vertical, UI::LayoutParams *layoutParams) : UI::LinearLayout(UI::ORIENT_HORIZONTAL, layoutParams), slot_(slot), gamePath_(gameFilename) { using namespace UI; screenshotFilename_ = SaveState::GenerateSaveSlotFilename(gamePath_, slot, SaveState::SCREENSHOT_EXTENSION); @@ -185,7 +185,7 @@ SaveSlotView::SaveSlotView(const Path &gameFilename, int slot, UI::LayoutParams Add(lines); - LinearLayout *buttons = new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(WRAP_CONTENT, WRAP_CONTENT)); + LinearLayout *buttons = new LinearLayout(vertical ? ORIENT_VERTICAL : ORIENT_HORIZONTAL, new LinearLayoutParams(WRAP_CONTENT, WRAP_CONTENT)); buttons->SetSpacing(10.0f); lines->Add(buttons); @@ -201,7 +201,11 @@ SaveSlotView::SaveSlotView(const Path &gameFilename, int slot, UI::LayoutParams std::string dateStr = SaveState::GetSlotDateAsString(gamePath_, slot_); if (!dateStr.empty()) { - lines->Add(new TextView(dateStr, new LinearLayoutParams(0.0, G_VCENTER)))->SetShadow(true); + TextView *dateView = new TextView(dateStr, new LinearLayoutParams(0.0, G_VCENTER)); + if (vertical) { + dateView->SetSmall(true); + } + lines->Add(dateView)->SetShadow(true); } } else { fv->SetFilename(Path()); @@ -262,6 +266,8 @@ void GamePauseScreen::CreateViews() { using namespace UI; + bool vertical = UseVerticalLayout(); + Margins scrollMargins(0, 20, 0, 0); Margins actionMenuMargins(0, 20, 15, 0); auto gr = GetI18NCategory("Graphics"); @@ -278,7 +284,7 @@ void GamePauseScreen::CreateViews() { leftColumnItems->Add(new Spacer(0.0)); leftColumnItems->SetSpacing(10.0); for (int i = 0; i < NUM_SAVESLOTS; i++) { - SaveSlotView *slot = leftColumnItems->Add(new SaveSlotView(gamePath_, i, new LayoutParams(FILL_PARENT, WRAP_CONTENT))); + SaveSlotView *slot = leftColumnItems->Add(new SaveSlotView(gamePath_, i, vertical, new LayoutParams(FILL_PARENT, WRAP_CONTENT))); slot->OnStateLoaded.Handle(this, &GamePauseScreen::OnState); slot->OnStateSaved.Handle(this, &GamePauseScreen::OnState); slot->OnScreenshotClicked.Handle(this, &GamePauseScreen::OnScreenshotClicked); @@ -302,7 +308,7 @@ void GamePauseScreen::CreateViews() { rewindButton->OnClick.Handle(this, &GamePauseScreen::OnRewind); } - ViewGroup *rightColumn = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(300, FILL_PARENT, actionMenuMargins)); + ViewGroup *rightColumn = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(vertical ? 200 : 300, FILL_PARENT, actionMenuMargins)); root_->Add(rightColumn); LinearLayout *rightColumnItems = new LinearLayout(ORIENT_VERTICAL); diff --git a/UI/RemoteISOScreen.cpp b/UI/RemoteISOScreen.cpp index 7d60e507a4..93e2ae7681 100644 --- a/UI/RemoteISOScreen.cpp +++ b/UI/RemoteISOScreen.cpp @@ -517,11 +517,11 @@ RemoteISOBrowseScreen::RemoteISOBrowseScreen(const std::string &url, const std:: } void RemoteISOBrowseScreen::CreateViews() { - bool vertical = UseVerticalLayout(); - auto di = GetI18NCategory("Dialog"); auto ri = GetI18NCategory("RemoteISO"); + bool vertical = UseVerticalLayout(); + Margins actionMenuMargins(0, 10, 10, 0); TabHolder *leftColumn = new TabHolder(ORIENT_HORIZONTAL, 64, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT));