mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Fix proportional resize on the scene editor on touchscreens
This commit is contained in:
@@ -8,7 +8,7 @@ import InstancesSelection from './InstancesSelection';
|
|||||||
type Props = {|
|
type Props = {|
|
||||||
instancesSelection: InstancesSelection,
|
instancesSelection: InstancesSelection,
|
||||||
instanceMeasurer: Object, // To be typed in InstancesRenderer
|
instanceMeasurer: Object, // To be typed in InstancesRenderer
|
||||||
onResize: (number, number) => void,
|
onResize: (deltaX: number | null, deltaY: number | null) => void,
|
||||||
onResizeEnd: () => void,
|
onResizeEnd: () => void,
|
||||||
onRotate: (number, number) => void,
|
onRotate: (number, number) => void,
|
||||||
onRotateEnd: () => void,
|
onRotateEnd: () => void,
|
||||||
@@ -19,10 +19,10 @@ type Props = {|
|
|||||||
const getButtonSizes = (screenType: ScreenType) => {
|
const getButtonSizes = (screenType: ScreenType) => {
|
||||||
if (screenType === 'touch') {
|
if (screenType === 'touch') {
|
||||||
return {
|
return {
|
||||||
buttonSize: 16,
|
buttonSize: 14,
|
||||||
smallButtonSize: 14,
|
smallButtonSize: 12,
|
||||||
buttonPadding: 5,
|
buttonPadding: 5,
|
||||||
hitAreaPadding: 20,
|
hitAreaPadding: 12,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ const CIRCLE_BUTTON_SHAPE = 1;
|
|||||||
export default class SelectedInstances {
|
export default class SelectedInstances {
|
||||||
instancesSelection: InstancesSelection;
|
instancesSelection: InstancesSelection;
|
||||||
instanceMeasurer: Object; // To be typed in InstancesRenderer
|
instanceMeasurer: Object; // To be typed in InstancesRenderer
|
||||||
onResize: (number, number) => void;
|
onResize: (deltaX: number | null, deltaY: number | null) => void;
|
||||||
onResizeEnd: () => void;
|
onResizeEnd: () => void;
|
||||||
onRotate: (number, number) => void;
|
onRotate: (number, number) => void;
|
||||||
onRotateEnd: () => void;
|
onRotateEnd: () => void;
|
||||||
@@ -93,7 +93,7 @@ export default class SelectedInstances {
|
|||||||
this._makeButton(
|
this._makeButton(
|
||||||
this.rightResizeButton,
|
this.rightResizeButton,
|
||||||
event => {
|
event => {
|
||||||
this.onResize(event.deltaX, 0);
|
this.onResize(event.deltaX, null);
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
this.onResizeEnd();
|
this.onResizeEnd();
|
||||||
@@ -103,7 +103,7 @@ export default class SelectedInstances {
|
|||||||
this._makeButton(
|
this._makeButton(
|
||||||
this.bottomResizeButton,
|
this.bottomResizeButton,
|
||||||
event => {
|
event => {
|
||||||
this.onResize(0, event.deltaY);
|
this.onResize(null, event.deltaY);
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
this.onResizeEnd();
|
this.onResizeEnd();
|
||||||
|
@@ -636,14 +636,15 @@ export default class InstancesEditor extends Component<Props> {
|
|||||||
this.props.onInstancesMoved(selectedInstances);
|
this.props.onInstancesMoved(selectedInstances);
|
||||||
};
|
};
|
||||||
|
|
||||||
_onResize = (deltaX: number, deltaY: number) => {
|
_onResize = (deltaX: number | null, deltaY: number | null) => {
|
||||||
const sceneDeltaX = deltaX / this.getZoomFactor();
|
const sceneDeltaX = deltaX !== null ? deltaX / this.getZoomFactor() : 0;
|
||||||
const sceneDeltaY = deltaY / this.getZoomFactor();
|
const sceneDeltaY = deltaY !== null ? deltaY / this.getZoomFactor() : 0;
|
||||||
|
|
||||||
const selectedInstances = this.props.instancesSelection.getSelectedInstances();
|
const selectedInstances = this.props.instancesSelection.getSelectedInstances();
|
||||||
|
const forceProportional =
|
||||||
|
this.props.screenType === 'touch' && deltaX !== null && deltaY !== null;
|
||||||
const proportional =
|
const proportional =
|
||||||
this.keyboardShortcuts.shouldResizeProportionally() ||
|
forceProportional || this.keyboardShortcuts.shouldResizeProportionally();
|
||||||
this.props.screenType === 'touch';
|
|
||||||
this.instancesResizer.resizeBy(
|
this.instancesResizer.resizeBy(
|
||||||
selectedInstances,
|
selectedInstances,
|
||||||
sceneDeltaX,
|
sceneDeltaX,
|
||||||
|
Reference in New Issue
Block a user