Added "Small Screen Position" feature

* error checking for layout value from older config

* rename enum and update aspect ratio code

* rewrite LargeFrameLayout to support multiple positions

* add settings for smallscreenposition, fix minsize function

* fixed framebuffer from res scale (screenshots)

* add desktop UI for small screen position

* small screen position submenu on desktop

* fix int-float conversion warning

* rename Above and Below to hopefully fix linux issue

* Add Small Screen Position Setting to android settings menu

* fix sliders to work with floats, mostly

* fix android slider textinput ui

* change None enums in settings and cam_params

* Apply clang-format-18

* SettingsAdapter.kt: Make more null pointer exception resistant

* Updated license headers

* Code formatting nitpicks

* fix bug in main.ui that was hiding menu

* replace default layout with a special call to LargeFrame (like SideBySide does)

* fix bug when "large screen" is actually narrower

* edit documentation for LargeScreenLayout

* update PortraitTopFullFrameLayout to use LargeFrameLayout

* fix unary minus on unsigned int bug

* Applied formatting correction

* Added `const`s where appropriate

* android: Add mention of the bottom-right small screen position being the default

* review fixes + more constants

* refactor all Upright calculations to a reverseLayout method, simplifying code and reducing bugs

* Removed stray extra newline

* SettingsAdapter.kt: Fixed some strange indentation

* Removed unnecessary `if` in favour of direct value usage

---------

Co-authored-by: Reg Tiangha <rtiangha@users.noreply.github.com>
Co-authored-by: OpenSauce04 <opensauce04@gmail.com>
This commit is contained in:
David Griswold
2024-10-29 14:22:51 -07:00
committed by OpenSauce04
parent 0a3cb3a4dc
commit 43c4d3981d
29 changed files with 780 additions and 454 deletions

View File

@@ -1,4 +1,4 @@
// Copyright 2018 Citra Emulator Project
// Copyright Citra Emulator Project / Lime3DS Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
@@ -32,7 +32,7 @@ void QtCameraInterface::SetFlip(Service::CAM::Flip flip) {
}
void QtCameraInterface::SetEffect(Service::CAM::Effect effect) {
if (effect != Service::CAM::Effect::None) {
if (effect != Service::CAM::Effect::NoEffect) {
LOG_ERROR(Service_CAM, "Unimplemented effect {}", static_cast<int>(effect));
}
}

View File

@@ -577,6 +577,16 @@ void GMainWindow::InitializeWidgets() {
actionGroup_ScreenLayouts->addAction(ui->action_Screen_Layout_Separate_Windows);
actionGroup_ScreenLayouts->addAction(ui->action_Screen_Layout_Hybrid_Screen);
actionGroup_ScreenLayouts->addAction(ui->action_Screen_Layout_Custom_Layout);
QActionGroup* actionGroup_SmallPositions = new QActionGroup(this);
actionGroup_SmallPositions->addAction(ui->action_Small_Screen_TopRight);
actionGroup_SmallPositions->addAction(ui->action_Small_Screen_MiddleRight);
actionGroup_SmallPositions->addAction(ui->action_Small_Screen_BottomRight);
actionGroup_SmallPositions->addAction(ui->action_Small_Screen_TopLeft);
actionGroup_SmallPositions->addAction(ui->action_Small_Screen_MiddleLeft);
actionGroup_SmallPositions->addAction(ui->action_Small_Screen_BottomLeft);
actionGroup_SmallPositions->addAction(ui->action_Small_Screen_Above);
actionGroup_SmallPositions->addAction(ui->action_Small_Screen_Below);
}
void GMainWindow::InitializeDebugWidgets() {
@@ -1025,6 +1035,14 @@ void GMainWindow::ConnectMenuEvents() {
connect_menu(ui->action_Screen_Layout_Custom_Layout, &GMainWindow::ChangeScreenLayout);
connect_menu(ui->action_Screen_Layout_Swap_Screens, &GMainWindow::OnSwapScreens);
connect_menu(ui->action_Screen_Layout_Upright_Screens, &GMainWindow::OnRotateScreens);
connect_menu(ui->action_Small_Screen_TopRight, &GMainWindow::ChangeSmallScreenPosition);
connect_menu(ui->action_Small_Screen_MiddleRight, &GMainWindow::ChangeSmallScreenPosition);
connect_menu(ui->action_Small_Screen_BottomRight, &GMainWindow::ChangeSmallScreenPosition);
connect_menu(ui->action_Small_Screen_TopLeft, &GMainWindow::ChangeSmallScreenPosition);
connect_menu(ui->action_Small_Screen_MiddleLeft, &GMainWindow::ChangeSmallScreenPosition);
connect_menu(ui->action_Small_Screen_BottomLeft, &GMainWindow::ChangeSmallScreenPosition);
connect_menu(ui->action_Small_Screen_Above, &GMainWindow::ChangeSmallScreenPosition);
connect_menu(ui->action_Small_Screen_Below, &GMainWindow::ChangeSmallScreenPosition);
// Movie
connect_menu(ui->action_Record_Movie, &GMainWindow::OnRecordMovie);
@@ -2491,13 +2509,13 @@ void GMainWindow::UpdateSecondaryWindowVisibility() {
void GMainWindow::ChangeScreenLayout() {
Settings::LayoutOption new_layout = Settings::LayoutOption::Default;
if (ui->action_Screen_Layout_Default->isChecked()) {
new_layout = Settings::LayoutOption::Default;
} else if (ui->action_Screen_Layout_Single_Screen->isChecked()) {
new_layout = Settings::LayoutOption::SingleScreen;
} else if (ui->action_Screen_Layout_Large_Screen->isChecked()) {
new_layout = Settings::LayoutOption::LargeScreen;
ui->menu_Small_Screen_Position->setEnabled(true);
} else if (ui->action_Screen_Layout_Hybrid_Screen->isChecked()) {
new_layout = Settings::LayoutOption::HybridScreen;
} else if (ui->action_Screen_Layout_Side_by_Side->isChecked()) {
@@ -2509,6 +2527,34 @@ void GMainWindow::ChangeScreenLayout() {
}
Settings::values.layout_option = new_layout;
SyncMenuUISettings();
system.ApplySettings();
UpdateSecondaryWindowVisibility();
}
void GMainWindow::ChangeSmallScreenPosition() {
Settings::SmallScreenPosition new_position = Settings::SmallScreenPosition::BottomRight;
if (ui->action_Small_Screen_TopRight->isChecked()) {
new_position = Settings::SmallScreenPosition::TopRight;
} else if (ui->action_Small_Screen_MiddleRight->isChecked()) {
new_position = Settings::SmallScreenPosition::MiddleRight;
} else if (ui->action_Small_Screen_BottomRight->isChecked()) {
new_position = Settings::SmallScreenPosition::BottomRight;
} else if (ui->action_Small_Screen_TopLeft->isChecked()) {
new_position = Settings::SmallScreenPosition::TopLeft;
} else if (ui->action_Small_Screen_MiddleLeft->isChecked()) {
new_position = Settings::SmallScreenPosition::MiddleLeft;
} else if (ui->action_Small_Screen_BottomLeft->isChecked()) {
new_position = Settings::SmallScreenPosition::BottomLeft;
} else if (ui->action_Small_Screen_Above->isChecked()) {
new_position = Settings::SmallScreenPosition::AboveLarge;
} else if (ui->action_Small_Screen_Below->isChecked()) {
new_position = Settings::SmallScreenPosition::BelowLarge;
}
Settings::values.small_screen_position = new_position;
SyncMenuUISettings();
system.ApplySettings();
UpdateSecondaryWindowVisibility();
}
@@ -3592,6 +3638,31 @@ void GMainWindow::SyncMenuUISettings() {
ui->action_Screen_Layout_Swap_Screens->setChecked(Settings::values.swap_screen.GetValue());
ui->action_Screen_Layout_Upright_Screens->setChecked(
Settings::values.upright_screen.GetValue());
ui->menu_Small_Screen_Position->setEnabled(Settings::values.layout_option.GetValue() ==
Settings::LayoutOption::LargeScreen);
ui->action_Small_Screen_TopRight->setChecked(
Settings::values.small_screen_position.GetValue() ==
Settings::SmallScreenPosition::TopRight);
ui->action_Small_Screen_MiddleRight->setChecked(
Settings::values.small_screen_position.GetValue() ==
Settings::SmallScreenPosition::MiddleRight);
ui->action_Small_Screen_BottomRight->setChecked(
Settings::values.small_screen_position.GetValue() ==
Settings::SmallScreenPosition::BottomRight);
ui->action_Small_Screen_TopLeft->setChecked(Settings::values.small_screen_position.GetValue() ==
Settings::SmallScreenPosition::TopLeft);
ui->action_Small_Screen_MiddleLeft->setChecked(
Settings::values.small_screen_position.GetValue() ==
Settings::SmallScreenPosition::MiddleLeft);
ui->action_Small_Screen_BottomLeft->setChecked(
Settings::values.small_screen_position.GetValue() ==
Settings::SmallScreenPosition::BottomLeft);
ui->action_Small_Screen_Above->setChecked(Settings::values.small_screen_position.GetValue() ==
Settings::SmallScreenPosition::AboveLarge);
ui->action_Small_Screen_Below->setChecked(Settings::values.small_screen_position.GetValue() ==
Settings::SmallScreenPosition::BelowLarge);
}
void GMainWindow::RetranslateStatusBar() {

View File

@@ -263,6 +263,7 @@ private slots:
void ToggleFullscreen();
void ToggleSecondaryFullscreen();
void ChangeScreenLayout();
void ChangeSmallScreenPosition();
void UpdateSecondaryWindowVisibility();
void ToggleScreenLayout();
void OnSwapScreens();

View File

@@ -519,6 +519,7 @@ void QtConfig::ReadLayoutValues() {
ReadGlobalSetting(Settings::values.swap_screen);
ReadGlobalSetting(Settings::values.upright_screen);
ReadGlobalSetting(Settings::values.large_screen_proportion);
ReadGlobalSetting(Settings::values.small_screen_position);
if (global) {
ReadBasicSetting(Settings::values.mono_render_option);
@@ -1083,7 +1084,7 @@ void QtConfig::SaveLayoutValues() {
WriteGlobalSetting(Settings::values.swap_screen);
WriteGlobalSetting(Settings::values.upright_screen);
WriteGlobalSetting(Settings::values.large_screen_proportion);
WriteGlobalSetting(Settings::values.small_screen_position);
if (global) {
WriteBasicSetting(Settings::values.mono_render_option);
WriteBasicSetting(Settings::values.custom_top_x);

View File

@@ -206,8 +206,8 @@ void ConfigureCamera::StartPreviewing() {
}
previewing_camera->SetResolution(
{static_cast<u16>(preview_width), static_cast<u16>(preview_height)});
previewing_camera->SetEffect(Service::CAM::Effect::None);
previewing_camera->SetFlip(Service::CAM::Flip::None);
previewing_camera->SetEffect(Service::CAM::Effect::NoEffect);
previewing_camera->SetFlip(Service::CAM::Flip::NoFlip);
previewing_camera->SetFormat(Service::CAM::OutputFormat::RGB565);
previewing_camera->SetFrameRate(Service::CAM::FrameRate::Rate_30);
previewing_camera->StartCapture();

View File

@@ -27,6 +27,15 @@ ConfigureLayout::ConfigureLayout(QWidget* parent)
currentIndex == (uint)(Settings::LayoutOption::LargeScreen));
});
ui->small_screen_position_combobox->setEnabled(
(Settings::values.layout_option.GetValue() == Settings::LayoutOption::LargeScreen));
connect(ui->layout_combobox,
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
[this](int currentIndex) {
ui->small_screen_position_combobox->setEnabled(
currentIndex == (uint)(Settings::LayoutOption::LargeScreen));
});
ui->single_screen_layout_config_group->setEnabled(
(Settings::values.layout_option.GetValue() == Settings::LayoutOption::SingleScreen) ||
(Settings::values.layout_option.GetValue() == Settings::LayoutOption::SeparateWindows));
@@ -96,7 +105,8 @@ void ConfigureLayout::SetConfiguration() {
ui->toggle_swap_screen->setChecked(Settings::values.swap_screen.GetValue());
ui->toggle_upright_screen->setChecked(Settings::values.upright_screen.GetValue());
ui->large_screen_proportion->setValue(Settings::values.large_screen_proportion.GetValue());
ui->small_screen_position_combobox->setCurrentIndex(
static_cast<int>(Settings::values.small_screen_position.GetValue()));
ui->custom_top_x->setValue(Settings::values.custom_top_x.GetValue());
ui->custom_top_y->setValue(Settings::values.custom_top_y.GetValue());
ui->custom_top_width->setValue(Settings::values.custom_top_width.GetValue());
@@ -133,7 +143,8 @@ void ConfigureLayout::RetranslateUI() {
void ConfigureLayout::ApplyConfiguration() {
Settings::values.large_screen_proportion = ui->large_screen_proportion->value();
Settings::values.small_screen_position = static_cast<Settings::SmallScreenPosition>(
ui->small_screen_position_combobox->currentIndex());
Settings::values.custom_top_x = ui->custom_top_x->value();
Settings::values.custom_top_y = ui->custom_top_y->value();
Settings::values.custom_top_width = ui->custom_top_width->value();

View File

@@ -145,6 +145,75 @@
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="small_pos_widget" native="true">
<layout class="QHBoxLayout" name="small_pos_layout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="small_pos_label">
<property name="text">
<string>Small Screen Position</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="small_screen_position_combobox">
<item>
<property name="text">
<string>Upper Right</string>
</property>
</item>
<item>
<property name="text">
<string>Middle Right</string>
</property>
</item>
<item>
<property name="text">
<string>Bottom Right (default)</string>
</property>
</item>
<item>
<property name="text">
<string>Upper Left</string>
</property>
</item>
<item>
<property name="text">
<string>Middle Left</string>
</property>
</item>
<item>
<property name="text">
<string>Bottom Left</string>
</property>
</item>
<item>
<property name="text">
<string>Above large screen</string>
</property>
</item>
<item>
<property name="text">
<string>Below large screen</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="bg_color_group" native="true">
<layout class="QHBoxLayout" name="bg_color_group_2">
@@ -592,6 +661,7 @@
<tabstop>toggle_swap_screen</tabstop>
<tabstop>toggle_upright_screen</tabstop>
<tabstop>large_screen_proportion</tabstop>
<tabstop>small_screen_position_combobox</tabstop>
<tabstop>bg_button</tabstop>
</tabstops>
<resources/>

View File

@@ -142,6 +142,23 @@
<addaction name="separator"/>
<addaction name="action_Screen_Layout_Upright_Screens"/>
<addaction name="action_Screen_Layout_Swap_Screens"/>
<widget class="QMenu" name="menu_Small_Screen_Position">
<property name="enabled">
<bool>true</bool>
</property>
<property name="title">
<string>Small Screen Position</string>
</property>
<addaction name="action_Small_Screen_TopRight"/>
<addaction name="action_Small_Screen_MiddleRight"/>
<addaction name="action_Small_Screen_BottomRight"/>
<addaction name="action_Small_Screen_TopLeft"/>
<addaction name="action_Small_Screen_MiddleLeft"/>
<addaction name="action_Small_Screen_BottomLeft"/>
<addaction name="action_Small_Screen_Above"/>
<addaction name="action_Small_Screen_Below"/>
</widget>
<addaction name="menu_Small_Screen_Position"/>
</widget>
<addaction name="action_Fullscreen"/>
<addaction name="action_Single_Window_Mode"/>
@@ -541,6 +558,70 @@
<string>Custom Layout</string>
</property>
</action>
<action name="action_Small_Screen_TopRight">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Top Right</string>
</property>
</action>
<action name="action_Small_Screen_MiddleRight">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Middle Right</string>
</property>
</action>
<action name="action_Small_Screen_BottomRight">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Bottom Right</string>
</property>
</action>
<action name="action_Small_Screen_TopLeft">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Top Left</string>
</property>
</action>
<action name="action_Small_Screen_MiddleLeft">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Middle Left</string>
</property>
</action>
<action name="action_Small_Screen_BottomLeft">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Bottom Left</string>
</property>
</action>
<action name="action_Small_Screen_Above">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Above</string>
</property>
</action>
<action name="action_Small_Screen_Below">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Below</string>
</property>
</action>
<action name="action_Screen_Layout_Swap_Screens">
<property name="checkable">
<bool>true</bool>