From c0f0bc88af39a0457c231a6c1a454b9d020400a8 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Wed, 27 Dec 2017 01:13:47 -0800 Subject: [PATCH] UI: Trigger view recreate on static sized screens. If a screen doesn't size via layout, it needs to recreate views on resize, which is what the resized() method is for. --- UI/DisplayLayoutScreen.cpp | 6 +++++- UI/DisplayLayoutScreen.h | 1 + UI/NativeApp.cpp | 4 ---- UI/TouchControlLayoutScreen.cpp | 6 +++++- UI/TouchControlLayoutScreen.h | 1 + Windows/MainWindow.cpp | 4 ---- ext/native/ui/ui_screen.cpp | 4 ++++ ext/native/ui/ui_screen.h | 1 + 8 files changed, 17 insertions(+), 10 deletions(-) diff --git a/UI/DisplayLayoutScreen.cpp b/UI/DisplayLayoutScreen.cpp index f198e18647..7b9dfc2f7c 100644 --- a/UI/DisplayLayoutScreen.cpp +++ b/UI/DisplayLayoutScreen.cpp @@ -165,7 +165,11 @@ bool DisplayLayoutScreen::touch(const TouchInput &touch) { picked_ = 0; } return true; -}; +} + +void DisplayLayoutScreen::resized() { + RecreateViews(); +} void DisplayLayoutScreen::onFinish(DialogResult reason) { g_Config.Save(); diff --git a/UI/DisplayLayoutScreen.h b/UI/DisplayLayoutScreen.h index a9d29c19e9..725131fab3 100644 --- a/UI/DisplayLayoutScreen.h +++ b/UI/DisplayLayoutScreen.h @@ -31,6 +31,7 @@ public: virtual bool touch(const TouchInput &touch) override; virtual void dialogFinished(const Screen *dialog, DialogResult result) override; virtual void onFinish(DialogResult reason) override; + virtual void resized() override; std::string tag() const override { return "display layout screen"; } protected: diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index bf866a211d..07dc956c33 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -1099,10 +1099,6 @@ void NativeResized() { // NativeResized can come from any thread so we just set a flag, then process it later. if (g_graphicsInited) { resized = true; - if (uiContext) { - // Still have to update bounds to avoid problems in display layout and touch controls layout screens - uiContext->SetBounds(Bounds(0, 0, dp_xres, dp_yres)); - } } else { ILOG("NativeResized ignored, not initialized"); } diff --git a/UI/TouchControlLayoutScreen.cpp b/UI/TouchControlLayoutScreen.cpp index 08e1159b04..87dee45e31 100644 --- a/UI/TouchControlLayoutScreen.cpp +++ b/UI/TouchControlLayoutScreen.cpp @@ -279,7 +279,11 @@ bool TouchControlLayoutScreen::touch(const TouchInput &touch) { pickedControl_ = 0; } return true; -}; +} + +void TouchControlLayoutScreen::resized() { + RecreateViews(); +} void TouchControlLayoutScreen::onFinish(DialogResult reason) { g_Config.Save(); diff --git a/UI/TouchControlLayoutScreen.h b/UI/TouchControlLayoutScreen.h index 59e3d9fd65..789d5a25e7 100644 --- a/UI/TouchControlLayoutScreen.h +++ b/UI/TouchControlLayoutScreen.h @@ -34,6 +34,7 @@ public: virtual bool touch(const TouchInput &touch) override; virtual void dialogFinished(const Screen *dialog, DialogResult result) override; virtual void onFinish(DialogResult reason) override; + virtual void resized() override; protected: virtual UI::EventReturn OnReset(UI::EventParams &e); diff --git a/Windows/MainWindow.cpp b/Windows/MainWindow.cpp index 61a1950002..f56ade7bce 100644 --- a/Windows/MainWindow.cpp +++ b/Windows/MainWindow.cpp @@ -279,10 +279,6 @@ namespace MainWindow NativeMessageReceived("gpu_resized", ""); } - if (screenManager) { - screenManager->RecreateAllViews(); - } - // Don't save the window state if fullscreen. if (!g_Config.bFullScreen) { g_WindowState = newSizingType; diff --git a/ext/native/ui/ui_screen.cpp b/ext/native/ui/ui_screen.cpp index babbae9d7c..7581e5fcdc 100644 --- a/ext/native/ui/ui_screen.cpp +++ b/ext/native/ui/ui_screen.cpp @@ -309,6 +309,10 @@ void PopupScreen::TriggerFinish(DialogResult result) { OnCompleted(result); } +void PopupScreen::resized() { + RecreateViews(); +} + void PopupScreen::CreateViews() { using namespace UI; UIContext &dc = *screenManager()->getUIContext(); diff --git a/ext/native/ui/ui_screen.h b/ext/native/ui/ui_screen.h index 8ab4ce49fb..3844cba71a 100644 --- a/ext/native/ui/ui_screen.h +++ b/ext/native/ui/ui_screen.h @@ -72,6 +72,7 @@ public: virtual bool isTransparent() const override { return true; } virtual bool touch(const TouchInput &touch) override; virtual bool key(const KeyInput &key) override; + virtual void resized() override; virtual void TriggerFinish(DialogResult result) override;