summaryrefslogtreecommitdiffstats
path: root/src/common/emu_window.cpp
diff options
context:
space:
mode:
authorJames Rowe <jroweboy@gmail.com>2016-05-03 08:07:17 +0200
committerJames Rowe <jroweboy@gmail.com>2016-11-05 09:55:41 +0100
commit2b1654ad9bbd8af53f22434d350704a1a1d0a285 (patch)
tree0da3cc7a1c622c1a659f4b2a8c5c08984dabd5c3 /src/common/emu_window.cpp
parentUpdate CONTRIBUTING.md (diff)
downloadyuzu-2b1654ad9bbd8af53f22434d350704a1a1d0a285.tar
yuzu-2b1654ad9bbd8af53f22434d350704a1a1d0a285.tar.gz
yuzu-2b1654ad9bbd8af53f22434d350704a1a1d0a285.tar.bz2
yuzu-2b1654ad9bbd8af53f22434d350704a1a1d0a285.tar.lz
yuzu-2b1654ad9bbd8af53f22434d350704a1a1d0a285.tar.xz
yuzu-2b1654ad9bbd8af53f22434d350704a1a1d0a285.tar.zst
yuzu-2b1654ad9bbd8af53f22434d350704a1a1d0a285.zip
Diffstat (limited to '')
-rw-r--r--src/common/emu_window.cpp68
1 files changed, 15 insertions, 53 deletions
diff --git a/src/common/emu_window.cpp b/src/common/emu_window.cpp
index 122f1c212..e3a9e08e6 100644
--- a/src/common/emu_window.cpp
+++ b/src/common/emu_window.cpp
@@ -40,7 +40,7 @@ void EmuWindow::CirclePadUpdated(float x, float y) {
* @param framebuffer_y Framebuffer y-coordinate to check
* @return True if the coordinates are within the touchpad, otherwise false
*/
-static bool IsWithinTouchscreen(const EmuWindow::FramebufferLayout& layout, unsigned framebuffer_x,
+static bool IsWithinTouchscreen(const Layout::FramebufferLayout& layout, unsigned framebuffer_x,
unsigned framebuffer_y) {
return (
framebuffer_y >= layout.bottom_screen.top && framebuffer_y < layout.bottom_screen.bottom &&
@@ -89,57 +89,19 @@ void EmuWindow::TouchMoved(unsigned framebuffer_x, unsigned framebuffer_y) {
TouchPressed(framebuffer_x, framebuffer_y);
}
-EmuWindow::FramebufferLayout EmuWindow::FramebufferLayout::DefaultScreenLayout(unsigned width,
- unsigned height) {
- // When hiding the widget, the function receives a size of 0
- if (width == 0)
- width = 1;
- if (height == 0)
- height = 1;
-
- EmuWindow::FramebufferLayout res = {width, height, {}, {}};
-
- float window_aspect_ratio = static_cast<float>(height) / width;
- float emulation_aspect_ratio =
- static_cast<float>(VideoCore::kScreenTopHeight * 2) / VideoCore::kScreenTopWidth;
-
- if (window_aspect_ratio > emulation_aspect_ratio) {
- // Window is narrower than the emulation content => apply borders to the top and bottom
- int viewport_height = static_cast<int>(std::round(emulation_aspect_ratio * width));
-
- res.top_screen.left = 0;
- res.top_screen.right = res.top_screen.left + width;
- res.top_screen.top = (height - viewport_height) / 2;
- res.top_screen.bottom = res.top_screen.top + viewport_height / 2;
-
- int bottom_width = static_cast<int>(
- (static_cast<float>(VideoCore::kScreenBottomWidth) / VideoCore::kScreenTopWidth) *
- (res.top_screen.right - res.top_screen.left));
- int bottom_border = ((res.top_screen.right - res.top_screen.left) - bottom_width) / 2;
-
- res.bottom_screen.left = bottom_border;
- res.bottom_screen.right = res.bottom_screen.left + bottom_width;
- res.bottom_screen.top = res.top_screen.bottom;
- res.bottom_screen.bottom = res.bottom_screen.top + viewport_height / 2;
- } else {
- // Otherwise, apply borders to the left and right sides of the window.
- int viewport_width = static_cast<int>(std::round(height / emulation_aspect_ratio));
-
- res.top_screen.left = (width - viewport_width) / 2;
- res.top_screen.right = res.top_screen.left + viewport_width;
- res.top_screen.top = 0;
- res.top_screen.bottom = res.top_screen.top + height / 2;
-
- int bottom_width = static_cast<int>(
- (static_cast<float>(VideoCore::kScreenBottomWidth) / VideoCore::kScreenTopWidth) *
- (res.top_screen.right - res.top_screen.left));
- int bottom_border = ((res.top_screen.right - res.top_screen.left) - bottom_width) / 2;
-
- res.bottom_screen.left = res.top_screen.left + bottom_border;
- res.bottom_screen.right = res.bottom_screen.left + bottom_width;
- res.bottom_screen.top = res.top_screen.bottom;
- res.bottom_screen.bottom = res.bottom_screen.top + height / 2;
+void EmuWindow::UpdateCurrentFramebufferLayout(unsigned width, unsigned height) {
+ Layout::FramebufferLayout layout;
+ switch (Settings::values.layout_option) {
+ case Settings::LayoutOption::SingleScreen:
+ layout = Layout::SingleFrameLayout(width, height, Settings::values.swap_screen);
+ break;
+ case Settings::LayoutOption::LargeScreen:
+ layout = Layout::LargeFrameLayout(width, height, Settings::values.swap_screen);
+ break;
+ case Settings::LayoutOption::Default:
+ default:
+ layout = Layout::DefaultFrameLayout(width, height, Settings::values.swap_screen);
+ break;
}
-
- return res;
+ NotifyFramebufferLayoutChanged(layout);
}