Merge pull request #12567 from iota97/snap2

Use snap grid on resize as well
This commit is contained in:
Henrik Rydgård 2020-01-26 11:36:28 +01:00 committed by GitHub
commit 8203c79e43
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -288,6 +288,11 @@ bool TouchControlLayoutScreen::touch(const TouchInput &touch) {
float diffX = (touch.x - startX_);
float diffY = -(touch.y - startY_);
// Snap to grid
if (g_Config.bTouchSnapToGrid) {
diffX -= (int)(touch.x - startX_) % (g_Config.iTouchSnapGridSize/2);
diffY += (int)(touch.y - startY_) % (g_Config.iTouchSnapGridSize/2);
}
float movementScale = 0.02f;
float newScale = startScale_ + diffY * movementScale;
float newSpacing = startSpacing_ + diffX * movementScale;
@ -363,7 +368,7 @@ void TouchControlLayoutScreen::CreateViews() {
// ->OnChange.Handle(this, &GameSettingsScreen::OnChangeControlScaling);
CheckBox *snap = new CheckBox(&g_Config.bTouchSnapToGrid, di->T("Snap"), "", new AnchorLayoutParams(leftColumnWidth, WRAP_CONTENT, 10, NONE, NONE, 228));
PopupSliderChoice *gridSize = new PopupSliderChoice(&g_Config.iTouchSnapGridSize, 1, 256, di->T("Grid"), screenManager(), "", new AnchorLayoutParams(leftColumnWidth, WRAP_CONTENT, 10, NONE, NONE, 158));
PopupSliderChoice *gridSize = new PopupSliderChoice(&g_Config.iTouchSnapGridSize, 2, 256, di->T("Grid"), screenManager(), "", new AnchorLayoutParams(leftColumnWidth, WRAP_CONTENT, 10, NONE, NONE, 158));
gridSize->SetEnabledPtr(&g_Config.bTouchSnapToGrid);
mode_ = new ChoiceStrip(ORIENT_VERTICAL, new AnchorLayoutParams(leftColumnWidth, WRAP_CONTENT, 10, NONE, NONE, 140 + 158 + 64 + 10));