mirror of
https://github.com/citra-emu/citra-canary.git
synced 2024-12-23 09:45:31 +00:00
Make a separate function for getting minimum size based on layout
This commit is contained in:
parent
0dcb886ef2
commit
157f82141d
|
@ -147,49 +147,35 @@ void EmuWindow::TouchMoved(unsigned framebuffer_x, unsigned framebuffer_y) {
|
|||
|
||||
void EmuWindow::UpdateCurrentFramebufferLayout(unsigned width, unsigned height) {
|
||||
Layout::FramebufferLayout layout;
|
||||
unsigned int min_width, min_height;
|
||||
Settings::LayoutOption layout_option = Settings::values.layout_option;
|
||||
std::pair<unsigned, unsigned> min_size =
|
||||
Layout::GetMinimumSizeFromLayout(layout_option, Settings::values.upright_screen);
|
||||
|
||||
if (Settings::values.custom_layout == true) {
|
||||
layout = Layout::CustomFrameLayout(width, height);
|
||||
} else {
|
||||
switch (Settings::values.layout_option) {
|
||||
width = std::max(width, min_size.first);
|
||||
height = std::max(height, min_size.second);
|
||||
switch (layout_option) {
|
||||
case Settings::LayoutOption::SingleScreen:
|
||||
min_width =
|
||||
Settings::values.swap_screen ? Core::kScreenBottomWidth : Core::kScreenTopWidth;
|
||||
min_height = Core::kScreenBottomHeight;
|
||||
layout = Layout::SingleFrameLayout(
|
||||
std::max(width, min_width), std::max(height, min_height),
|
||||
Settings::values.swap_screen, Settings::values.upright_screen);
|
||||
layout = Layout::SingleFrameLayout(width, height, Settings::values.swap_screen,
|
||||
Settings::values.upright_screen);
|
||||
break;
|
||||
case Settings::LayoutOption::LargeScreen:
|
||||
min_width = Settings::values.swap_screen
|
||||
? Core::kScreenTopWidth / 4 + Core::kScreenBottomWidth
|
||||
: Core::kScreenTopWidth + Core::kScreenBottomWidth / 4;
|
||||
min_height = Core::kScreenBottomHeight;
|
||||
layout = Layout::LargeFrameLayout(
|
||||
std::max(width, min_width), std::max(height, min_height),
|
||||
Settings::values.swap_screen, Settings::values.upright_screen);
|
||||
layout = Layout::LargeFrameLayout(width, height, Settings::values.swap_screen,
|
||||
Settings::values.upright_screen);
|
||||
break;
|
||||
case Settings::LayoutOption::SideScreen:
|
||||
min_width = Core::kScreenTopWidth + Core::kScreenBottomWidth;
|
||||
min_height = Core::kScreenBottomHeight;
|
||||
layout = Layout::SideFrameLayout(
|
||||
std::max(width, min_width), std::max(height, min_height),
|
||||
Settings::values.swap_screen, Settings::values.upright_screen);
|
||||
layout = Layout::SideFrameLayout(width, height, Settings::values.swap_screen,
|
||||
Settings::values.upright_screen);
|
||||
break;
|
||||
case Settings::LayoutOption::Default:
|
||||
default:
|
||||
min_width = Core::kScreenTopWidth;
|
||||
min_height = Core::kScreenTopHeight + Core::kScreenBottomHeight;
|
||||
layout = Layout::DefaultFrameLayout(
|
||||
std::max(width, min_width), std::max(height, min_height),
|
||||
Settings::values.swap_screen, Settings::values.upright_screen);
|
||||
layout = Layout::DefaultFrameLayout(width, height, Settings::values.swap_screen,
|
||||
Settings::values.upright_screen);
|
||||
break;
|
||||
}
|
||||
if (Settings::values.upright_screen) {
|
||||
UpdateMinimumWindowSize(min_height, min_width);
|
||||
} else {
|
||||
UpdateMinimumWindowSize(min_width, min_height);
|
||||
}
|
||||
UpdateMinimumWindowSize(min_size);
|
||||
}
|
||||
NotifyFramebufferLayoutChanged(layout);
|
||||
}
|
||||
|
|
|
@ -216,9 +216,9 @@ private:
|
|||
*/
|
||||
std::tuple<unsigned, unsigned> ClipToTouchScreen(unsigned new_x, unsigned new_y) const;
|
||||
|
||||
void UpdateMinimumWindowSize(unsigned int min_width, unsigned int min_height) {
|
||||
void UpdateMinimumWindowSize(std::pair<unsigned, unsigned> min_size) {
|
||||
WindowConfig new_config = config;
|
||||
new_config.min_client_area_size = std::make_pair(min_width, min_height);
|
||||
new_config.min_client_area_size = min_size;
|
||||
SetConfig(new_config);
|
||||
ProcessConfigurationChanges();
|
||||
}
|
||||
|
|
|
@ -363,4 +363,36 @@ FramebufferLayout FrameLayoutFromResolutionScale(u32 res_scale) {
|
|||
return layout;
|
||||
}
|
||||
|
||||
std::pair<unsigned, unsigned> GetMinimumSizeFromLayout(Settings::LayoutOption layout,
|
||||
bool upright_screen) {
|
||||
unsigned min_width, min_height;
|
||||
|
||||
switch (layout) {
|
||||
case Settings::LayoutOption::SingleScreen:
|
||||
min_width = Settings::values.swap_screen ? Core::kScreenBottomWidth : Core::kScreenTopWidth;
|
||||
min_height = Core::kScreenBottomHeight;
|
||||
break;
|
||||
case Settings::LayoutOption::LargeScreen:
|
||||
min_width = Settings::values.swap_screen
|
||||
? Core::kScreenTopWidth / 4 + Core::kScreenBottomWidth
|
||||
: Core::kScreenTopWidth + Core::kScreenBottomWidth / 4;
|
||||
min_height = Core::kScreenBottomHeight;
|
||||
break;
|
||||
case Settings::LayoutOption::SideScreen:
|
||||
min_width = Core::kScreenTopWidth + Core::kScreenBottomWidth;
|
||||
min_height = Core::kScreenBottomHeight;
|
||||
break;
|
||||
case Settings::LayoutOption::Default:
|
||||
default:
|
||||
min_width = Core::kScreenTopWidth;
|
||||
min_height = Core::kScreenTopHeight + Core::kScreenBottomHeight;
|
||||
break;
|
||||
}
|
||||
if (upright_screen) {
|
||||
return std::make_pair(min_height, min_width);
|
||||
} else {
|
||||
return std::make_pair(min_width, min_height);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Layout
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "common/math_util.h"
|
||||
#include "core/settings.h"
|
||||
|
||||
namespace Layout {
|
||||
|
||||
|
@ -80,4 +81,7 @@ FramebufferLayout CustomFrameLayout(u32 width, u32 height);
|
|||
*/
|
||||
FramebufferLayout FrameLayoutFromResolutionScale(u32 res_scale);
|
||||
|
||||
std::pair<unsigned, unsigned> GetMinimumSizeFromLayout(Settings::LayoutOption layout,
|
||||
bool upright_screen);
|
||||
|
||||
} // namespace Layout
|
||||
|
|
Loading…
Reference in a new issue