mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-31 05:40:04 +00:00 
			
		
		
		
	Merge pull request #5069 from vitor-k/min-window2
Update minimum window size based on current layout
This commit is contained in:
		
						commit
						17e9522921
					
				
					 5 changed files with 58 additions and 3 deletions
				
			
		|  | @ -389,6 +389,7 @@ void GRenderWindow::InitRenderTarget() { | ||||||
|     core_context = CreateSharedContext(); |     core_context = CreateSharedContext(); | ||||||
|     resize(Core::kScreenTopWidth, Core::kScreenTopHeight + Core::kScreenBottomHeight); |     resize(Core::kScreenTopWidth, Core::kScreenTopHeight + Core::kScreenBottomHeight); | ||||||
|     OnMinimalClientAreaChangeRequest(GetActiveConfig().min_client_area_size); |     OnMinimalClientAreaChangeRequest(GetActiveConfig().min_client_area_size); | ||||||
|  |     OnFramebufferSizeChanged(); | ||||||
|     BackupGeometry(); |     BackupGeometry(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -4,6 +4,7 @@ | ||||||
| 
 | 
 | ||||||
| #include <cmath> | #include <cmath> | ||||||
| #include <mutex> | #include <mutex> | ||||||
|  | #include "core/3ds.h" | ||||||
| #include "core/frontend/emu_window.h" | #include "core/frontend/emu_window.h" | ||||||
| #include "core/frontend/input.h" | #include "core/frontend/input.h" | ||||||
| #include "core/settings.h" | #include "core/settings.h" | ||||||
|  | @ -45,7 +46,8 @@ private: | ||||||
| 
 | 
 | ||||||
| EmuWindow::EmuWindow() { | EmuWindow::EmuWindow() { | ||||||
|     // TODO: Find a better place to set this.
 |     // TODO: Find a better place to set this.
 | ||||||
|     config.min_client_area_size = std::make_pair(400u, 480u); |     config.min_client_area_size = | ||||||
|  |         std::make_pair(Core::kScreenTopWidth, Core::kScreenTopHeight + Core::kScreenBottomHeight); | ||||||
|     active_config = config; |     active_config = config; | ||||||
|     touch_state = std::make_shared<TouchState>(); |     touch_state = std::make_shared<TouchState>(); | ||||||
|     Input::RegisterFactory<Input::TouchDevice>("emu_window", touch_state); |     Input::RegisterFactory<Input::TouchDevice>("emu_window", touch_state); | ||||||
|  | @ -145,10 +147,16 @@ void EmuWindow::TouchMoved(unsigned framebuffer_x, unsigned framebuffer_y) { | ||||||
| 
 | 
 | ||||||
| void EmuWindow::UpdateCurrentFramebufferLayout(unsigned width, unsigned height) { | void EmuWindow::UpdateCurrentFramebufferLayout(unsigned width, unsigned height) { | ||||||
|     Layout::FramebufferLayout layout; |     Layout::FramebufferLayout layout; | ||||||
|  |     const auto layout_option = Settings::values.layout_option; | ||||||
|  |     const auto min_size = | ||||||
|  |         Layout::GetMinimumSizeFromLayout(layout_option, Settings::values.upright_screen); | ||||||
|  | 
 | ||||||
|     if (Settings::values.custom_layout == true) { |     if (Settings::values.custom_layout == true) { | ||||||
|         layout = Layout::CustomFrameLayout(width, height); |         layout = Layout::CustomFrameLayout(width, height); | ||||||
|     } else { |     } 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: |         case Settings::LayoutOption::SingleScreen: | ||||||
|             layout = Layout::SingleFrameLayout(width, height, Settings::values.swap_screen, |             layout = Layout::SingleFrameLayout(width, height, Settings::values.swap_screen, | ||||||
|                                                Settings::values.upright_screen); |                                                Settings::values.upright_screen); | ||||||
|  | @ -167,8 +175,16 @@ void EmuWindow::UpdateCurrentFramebufferLayout(unsigned width, unsigned height) | ||||||
|                                                 Settings::values.upright_screen); |                                                 Settings::values.upright_screen); | ||||||
|             break; |             break; | ||||||
|         } |         } | ||||||
|  |         UpdateMinimumWindowSize(min_size); | ||||||
|     } |     } | ||||||
|     NotifyFramebufferLayoutChanged(layout); |     NotifyFramebufferLayoutChanged(layout); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | void EmuWindow::UpdateMinimumWindowSize(std::pair<unsigned, unsigned> min_size) { | ||||||
|  |     WindowConfig new_config = config; | ||||||
|  |     new_config.min_client_area_size = min_size; | ||||||
|  |     SetConfig(new_config); | ||||||
|  |     ProcessConfigurationChanges(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| } // namespace Frontend
 | } // namespace Frontend
 | ||||||
|  |  | ||||||
|  | @ -180,7 +180,7 @@ protected: | ||||||
| 
 | 
 | ||||||
|         if (config.min_client_area_size != active_config.min_client_area_size) { |         if (config.min_client_area_size != active_config.min_client_area_size) { | ||||||
|             OnMinimalClientAreaChangeRequest(config.min_client_area_size); |             OnMinimalClientAreaChangeRequest(config.min_client_area_size); | ||||||
|             config.min_client_area_size = active_config.min_client_area_size; |             active_config.min_client_area_size = config.min_client_area_size; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | @ -215,6 +215,8 @@ private: | ||||||
|      * Clip the provided coordinates to be inside the touchscreen area. |      * Clip the provided coordinates to be inside the touchscreen area. | ||||||
|      */ |      */ | ||||||
|     std::tuple<unsigned, unsigned> ClipToTouchScreen(unsigned new_x, unsigned new_y) const; |     std::tuple<unsigned, unsigned> ClipToTouchScreen(unsigned new_x, unsigned new_y) const; | ||||||
|  | 
 | ||||||
|  |     void UpdateMinimumWindowSize(std::pair<unsigned, unsigned> min_size); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| } // namespace Frontend
 | } // namespace Frontend
 | ||||||
|  |  | ||||||
|  | @ -363,4 +363,36 @@ FramebufferLayout FrameLayoutFromResolutionScale(u32 res_scale) { | ||||||
|     return layout; |     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
 | } // namespace Layout
 | ||||||
|  |  | ||||||
|  | @ -5,6 +5,7 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include "common/math_util.h" | #include "common/math_util.h" | ||||||
|  | #include "core/settings.h" | ||||||
| 
 | 
 | ||||||
| namespace Layout { | namespace Layout { | ||||||
| 
 | 
 | ||||||
|  | @ -80,4 +81,7 @@ FramebufferLayout CustomFrameLayout(u32 width, u32 height); | ||||||
|  */ |  */ | ||||||
| FramebufferLayout FrameLayoutFromResolutionScale(u32 res_scale); | FramebufferLayout FrameLayoutFromResolutionScale(u32 res_scale); | ||||||
| 
 | 
 | ||||||
|  | std::pair<unsigned, unsigned> GetMinimumSizeFromLayout(Settings::LayoutOption layout, | ||||||
|  |                                                        bool upright_screen); | ||||||
|  | 
 | ||||||
| } // namespace Layout
 | } // namespace Layout
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue