From 3d24b3c0549bb8b33f5c314b35eb9c2853a1bc5a Mon Sep 17 00:00:00 2001 From: Romain Goyet Date: Wed, 17 Jun 2020 14:27:38 -0400 Subject: [PATCH 1/3] [simulator] Make the calculator's screen pixel-perfect --- ion/src/simulator/shared/layout.cpp | 2 +- ion/src/simulator/shared/main_sdl.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ion/src/simulator/shared/layout.cpp b/ion/src/simulator/shared/layout.cpp index 0b2241778..088e5444c 100644 --- a/ion/src/simulator/shared/layout.cpp +++ b/ion/src/simulator/shared/layout.cpp @@ -11,7 +11,7 @@ static constexpr float X(int x) { return static_cast(x)/static_cast(y)/static_cast(backgroundHeight); } static constexpr SDL_FRect areaOfInterest = {X(110), Y(30), X(940), Y(2150)}; -static constexpr SDL_FRect screenRect = {X(192), Y(191), X(779), Y(582)}; +static constexpr SDL_FRect screenRect = {X(192), Y(191), X(776), Y(582)}; static SDL_Rect sFrame; diff --git a/ion/src/simulator/shared/main_sdl.cpp b/ion/src/simulator/shared/main_sdl.cpp index bc7f59f83..0a79caf9c 100644 --- a/ion/src/simulator/shared/main_sdl.cpp +++ b/ion/src/simulator/shared/main_sdl.cpp @@ -73,7 +73,7 @@ void init() { Ion::Display::Height, 0 // Default flags: no high-dpi, not resizeable. #else - 290, 555, // Otherwise use a default size that matches the whole calculator + 458, 888, // Otherwise use a default size that makes the screen pixel-perfect SDL_WINDOW_ALLOW_HIGHDPI #if EPSILON_SDL_FULLSCREEN | SDL_WINDOW_FULLSCREEN From 85a10ab084d3acd9f1a18636f344209ed4d3c71c Mon Sep 17 00:00:00 2001 From: Romain Goyet Date: Thu, 25 Jun 2020 22:32:31 -0400 Subject: [PATCH 2/3] [ion/simulator] Ion::Simulator::Main::relayout() should not draw That function is supposed to recompute the layout, not perform any drawing. Namely, presenting the render without a potential previous call to SDL_RenderClear could lead to some visual glitches. --- ion/src/simulator/shared/main_sdl.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/ion/src/simulator/shared/main_sdl.cpp b/ion/src/simulator/shared/main_sdl.cpp index 0a79caf9c..241b2495c 100644 --- a/ion/src/simulator/shared/main_sdl.cpp +++ b/ion/src/simulator/shared/main_sdl.cpp @@ -115,11 +115,6 @@ void relayout() { sScreenRect.h = windowHeight; #else Layout::recompute(windowWidth, windowHeight); - SDL_Rect backgroundRect; - Layout::getBackgroundRect(&backgroundRect); - - SDL_RenderCopy(sRenderer, sBackgroundTexture, nullptr, &backgroundRect); - SDL_RenderPresent(sRenderer); #endif setNeedsRefresh(); From 585bf65294fcb476541846ce162c4fb7b1a6b0dc Mon Sep 17 00:00:00 2001 From: Romain Goyet Date: Thu, 25 Jun 2020 22:34:31 -0400 Subject: [PATCH 3/3] [ion/simulator] Relayout on any windows event We might be relayouting a bit too often, but better safe than sorry! Jokes aside, most SDL_WINDOWEVENT should trigger a relayout, and in general those events aren't triggered on a regular basis anyway. --- ion/src/simulator/shared/events_keyboard.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ion/src/simulator/shared/events_keyboard.cpp b/ion/src/simulator/shared/events_keyboard.cpp index 61fe0f972..806372e19 100644 --- a/ion/src/simulator/shared/events_keyboard.cpp +++ b/ion/src/simulator/shared/events_keyboard.cpp @@ -175,9 +175,8 @@ Event getPlatformEvent() { while (SDL_PollEvent(&event)) { // The while is important: it'll do a fast-pass over all useless SDL events if (event.type == SDL_WINDOWEVENT) { - if (event.window.event == SDL_WINDOWEVENT_RESIZED) { - Ion::Simulator::Main::relayout(); - } + Ion::Simulator::Main::relayout(); + break; } if (event.type == SDL_QUIT) { result = Termination;