Switch to vertical layout automatically as the window is being resized

Prevents ending up in the wrong layout on startup and being unable to fix it
without restarting the emulator.
This commit is contained in:
Henrik Rydgard 2014-06-29 21:02:32 +02:00
parent 8a7573004d
commit 498136bbf8
2 changed files with 14 additions and 1 deletions

View File

@ -707,6 +707,7 @@ UI::EventReturn GameBrowser::NavigateClick(UI::EventParams &e) {
MainScreen::MainScreen() : highlightProgress_(0.0f), prevHighlightProgress_(0.0f), backFromStore_(false), lockBackgroundAudio_(false) {
System_SendMessage("event", "mainscreen");
SetBackgroundAudioGame("");
lastVertical_ = UseVerticalLayout();
}
MainScreen::~MainScreen() {
@ -721,7 +722,7 @@ void MainScreen::CreateViews() {
using namespace UI;
// Vertical mode is not finished.
bool vertical = dp_yres > dp_xres;
bool vertical = UseVerticalLayout();
I18NCategory *m = GetI18NCategory("MainMenu");
@ -906,6 +907,15 @@ void MainScreen::sendMessage(const char *message, const char *value) {
void MainScreen::update(InputState &input) {
UIScreen::update(input);
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) {

View File

@ -71,6 +71,9 @@ private:
float prevHighlightProgress_;
bool lockBackgroundAudio_;
bool backFromStore_;
bool lastVertical_;
bool UseVerticalLayout() const;
};
class GamePauseScreen : public UIDialogScreenWithGameBackground {