Fix screen layout in portrait mode on TouchControlLayoutScreen, fix move/resize selector visual status

This commit is contained in:
Henrik Rydgård
2026-05-04 01:00:40 +02:00
parent 71d04bfcae
commit fd11659b8d
4 changed files with 15 additions and 19 deletions
+12 -18
View File
@@ -580,17 +580,19 @@ DragDropButton *ControlLayoutView::getPickedControl(const int x, const int y) {
}
void TouchControlLayoutScreen::resized() {
UIBaseDialogScreen::resized();
RecreateViews();
}
void TouchControlLayoutScreen::onFinish(DialogResult reason) {
UIBaseDialogScreen::onFinish(reason);
g_Config.Save("TouchControlLayoutScreen::onFinish");
}
void TouchControlLayoutScreen::OnReset(UI::EventParams &e) {
INFO_LOG(Log::G3D, "Resetting touch control layout to default.");
const Bounds &bounds = screenManager()->getUIContext()->GetBounds();
const Bounds &bounds = GetLayoutBounds(*screenManager()->getUIContext());
const DeviceOrientation orientation = GetDeviceOrientation();
TouchControlConfig &touch = g_Config.GetTouchControlsConfig(orientation);
touch.ResetLayout();
@@ -599,16 +601,10 @@ void TouchControlLayoutScreen::OnReset(UI::EventParams &e) {
};
void TouchControlLayoutScreen::dialogFinished(const Screen *dialog, DialogResult result) {
UIBaseDialogScreen::dialogFinished(dialog, result);
RecreateViews();
}
void TouchControlLayoutScreen::OnMode(UI::EventParams &e) {
int mode = mode_->GetSelection();
if (layoutView_) {
layoutView_->mode_ = mode;
}
}
void TouchControlLayoutScreen::update() {
UIBaseDialogScreen::update();
@@ -621,21 +617,13 @@ void TouchControlLayoutScreen::update() {
if (!layoutView_->HasCreatedViews()) {
layoutView_->CreateViews();
}
Bounds bounds = layoutView_->GetBounds();
// Convert virtual pixels to real pixels.
bounds.x /= g_display.dpi_scale_x;
bounds.y /= g_display.dpi_scale_y;
bounds.w /= g_display.dpi_scale_x;
bounds.h /= g_display.dpi_scale_y;
SetOverrideScreenFrame(&bounds);
}
void TouchControlLayoutScreen::CreateViews() {
using namespace UI;
// setup g_Config for button layout
const Bounds &bounds = screenManager()->getUIContext()->GetBounds();
const Bounds &bounds = GetLayoutBounds(*screenManager()->getUIContext());
const DeviceOrientation orientation = GetDeviceOrientation();
InitPadLayout(&g_Config.GetTouchControlsConfig(orientation), orientation, bounds.w, bounds.h);
@@ -659,7 +647,12 @@ void TouchControlLayoutScreen::CreateViews() {
mode_->AddChoice(di->T("Move"), ImageID("I_MOVE"));
mode_->AddChoice(di->T("Resize"), ImageID("I_RESIZE"));
mode_->SetSelection(0, false);
mode_->OnChoice.Handle(this, &TouchControlLayoutScreen::OnMode);
mode_->OnChoice.Add([this](UI::EventParams &e) {
int mode = mode_->GetSelection();
if (layoutView_) {
layoutView_->mode_ = mode;
}
});
CheckBox *snap = new CheckBox(&g_Config.bTouchSnapToGrid, di->T("Snap"));
PopupSliderChoice *gridSize = new PopupSliderChoice(&g_Config.iTouchSnapGridSize, 2, 256, 64, di->T("Grid"), screenManager(), "");
@@ -675,6 +668,7 @@ void TouchControlLayoutScreen::CreateViews() {
leftColumn->Add(new Spacer(12.0f));
leftColumn->Add(new Choice(di->T("Back"), ImageID("I_NAVIGATE_BACK")))->OnClick.Handle<UIScreen>(this, &UIScreen::OnBack);
leftColumn->Add(new Spacer(0.0f));
leftColumnScroll->SetShadows(false);
LinearLayout* rightColumn = root_->Add(new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(1.0f, Margins(0.0f, 12.0f, 12.0f, 12.0f))));
rightColumn->Add(new TextView(co->T(DeviceOrientationToString(orientation))))->SetTextSize(TextSize::Small);