@@ -96,9 +96,9 @@ type Props = {|
96
96
...InstancesEditorPropsWithoutSizeAndScroll ,
97
97
width : number ,
98
98
height : number ,
99
- onViewPositionChanged : ViewPosition => void ,
100
- onMouseMove : MouseEvent => void ,
101
- onMouseLeave : MouseEvent => void ,
99
+ onViewPositionChanged ? : ViewPosition => void ,
100
+ onMouseMove ? : MouseEvent => void ,
101
+ onMouseLeave ? : MouseEvent => void ,
102
102
screenType : ScreenType ,
103
103
showObjectInstancesIn3D : boolean ,
104
104
| } ;
@@ -161,7 +161,7 @@ export default class InstancesEditor extends Component<Props> {
161
161
// project can be used here for initializing stuff, but don't keep references to it.
162
162
// Instead, create editors in _mountEditorComponents (as they will be destroyed/recreated
163
163
// if the project changes).
164
- const { project } = this . props ;
164
+ const { project , onMouseMove , onMouseLeave } = this . props ;
165
165
166
166
this . keyboardShortcuts = new KeyboardShortcuts ( {
167
167
shortcutCallbacks : {
@@ -257,12 +257,14 @@ export default class InstancesEditor extends Component<Props> {
257
257
'mouseup' ,
258
258
this . keyboardShortcuts . onMouseUp
259
259
) ;
260
- this . pixiRenderer . view . addEventListener ( 'mousemove' , event => {
261
- this . props . onMouseMove ( event ) ;
262
- } ) ;
263
- this . pixiRenderer . view . addEventListener ( 'mouseout' , event => {
264
- this . props . onMouseLeave ( event ) ;
265
- } ) ;
260
+ if ( onMouseMove )
261
+ this . pixiRenderer . view . addEventListener ( 'mousemove' , event => {
262
+ onMouseMove ( event ) ;
263
+ } ) ;
264
+ if ( onMouseLeave )
265
+ this . pixiRenderer . view . addEventListener ( 'mouseout' , event => {
266
+ onMouseLeave ( event ) ;
267
+ } ) ;
266
268
this . pixiRenderer . view . addEventListener ( 'focusout' , event => {
267
269
if ( this . keyboardShortcuts ) {
268
270
this . keyboardShortcuts . resetModifiers ( ) ;
@@ -368,9 +370,9 @@ export default class InstancesEditor extends Component<Props> {
368
370
* this when the initial instances were recreated to ensure that there
369
371
* is not mismatch between renderers and the instances that were updated.
370
372
*/
371
- forceRemount ( ) {
373
+ forceRemount = ( ) = > {
372
374
this . _mountEditorComponents ( this . props ) ;
373
- }
375
+ } ;
374
376
375
377
_mountEditorComponents ( props : Props ) {
376
378
//Remove and delete any existing editor component
@@ -558,14 +560,14 @@ export default class InstancesEditor extends Component<Props> {
558
560
* See also ResourcesLoader and PixiResourcesLoader.
559
561
* @param {string } objectName The name of the object for which instance must be re-rendered.
560
562
*/
561
- resetInstanceRenderersFor ( objectName : string ) {
563
+ resetInstanceRenderersFor = ( objectName : string ) = > {
562
564
if ( this . instancesRenderer )
563
565
this . instancesRenderer . resetInstanceRenderersFor ( objectName ) ;
564
- }
566
+ } ;
565
567
566
- zoomBy ( value : number ) {
568
+ zoomBy = ( value : number ) = > {
567
569
this . setZoomFactor ( this . getZoomFactor ( ) * value ) ;
568
- }
570
+ } ;
569
571
570
572
/**
571
573
* Zoom and scroll so that the cursor stays on the same position scene-wise.
@@ -642,7 +644,8 @@ export default class InstancesEditor extends Component<Props> {
642
644
643
645
if (
644
646
! this . keyboardShortcuts . shouldMultiSelect ( ) &&
645
- ! this . keyboardShortcuts . shouldMoveView ( )
647
+ ! this . keyboardShortcuts . shouldMoveView ( ) &&
648
+ this . props . instancesSelection . hasSelectedInstances ( )
646
649
) {
647
650
this . props . instancesSelection . clearSelection ( ) ;
648
651
this . props . onInstancesSelected ( [ ] ) ;
@@ -925,7 +928,7 @@ export default class InstancesEditor extends Component<Props> {
925
928
return this . canvasArea . getBoundingClientRect ( ) ;
926
929
}
927
930
928
- zoomToFitContent ( ) {
931
+ zoomToFitContent = ( ) = > {
929
932
const { initialInstances } = this . props ;
930
933
if ( initialInstances . getInstancesCount ( ) === 0 ) return ;
931
934
@@ -954,9 +957,9 @@ export default class InstancesEditor extends Component<Props> {
954
957
initialInstances . iterateOverInstances ( getInstanceRectangle ) ;
955
958
getInstanceRectangle . delete ( ) ;
956
959
if ( contentAABB ) this . fitViewToRectangle ( contentAABB , { adaptZoom : true } ) ;
957
- }
960
+ } ;
958
961
959
- zoomToInitialPosition ( ) {
962
+ zoomToInitialPosition = ( ) => {
960
963
const width = this . props . project . getGameResolutionWidth ( ) ;
961
964
const height = this . props . project . getGameResolutionHeight ( ) ;
962
965
const x = width / 2 ;
@@ -965,9 +968,9 @@ export default class InstancesEditor extends Component<Props> {
965
968
getRecommendedInitialZoomFactor ( Math . max ( height , width ) )
966
969
) ;
967
970
this . scrollTo ( x , y ) ;
968
- }
971
+ } ;
969
972
970
- zoomToFitSelection ( instances : Array < gdInitialInstance > ) {
973
+ zoomToFitSelection = ( instances : Array < gdInitialInstance > ) => {
971
974
if ( instances . length === 0 ) return ;
972
975
const [ firstInstance , ...otherInstances ] = instances ;
973
976
const instanceMeasurer = this . instancesRenderer . getInstanceMeasurer ( ) ;
@@ -981,9 +984,12 @@ export default class InstancesEditor extends Component<Props> {
981
984
) ;
982
985
} ) ;
983
986
this . fitViewToRectangle ( selectedInstancesRectangle , { adaptZoom : true } ) ;
984
- }
987
+ } ;
985
988
986
- centerViewOnLastInstance ( instances : Array < gdInitialInstance > ) {
989
+ centerViewOnLastInstance = (
990
+ instances : Array < gdInitialInstance > ,
991
+ offset ?: ?[ number , number ]
992
+ ) => {
987
993
if ( instances . length === 0 ) return ;
988
994
989
995
const instanceMeasurer = this . instancesRenderer . getInstanceMeasurer ( ) ;
@@ -992,7 +998,8 @@ export default class InstancesEditor extends Component<Props> {
992
998
new Rectangle ( )
993
999
) ;
994
1000
this . fitViewToRectangle ( lastInstanceRectangle , { adaptZoom : false } ) ;
995
- }
1001
+ if ( offset ) this . scrollBy ( offset [ 0 ] , offset [ 1 ] ) ;
1002
+ } ;
996
1003
997
1004
getLastContextMenuSceneCoordinates = ( ) => {
998
1005
return this . viewPosition . toSceneCoordinates (
@@ -1008,7 +1015,7 @@ export default class InstancesEditor extends Component<Props> {
1008
1015
) ;
1009
1016
} ;
1010
1017
1011
- getViewPosition = ( ) /* : ?ViewPosition */ => {
1018
+ getViewPosition = ( ) : ?ViewPosition => {
1012
1019
return this . viewPosition ;
1013
1020
} ;
1014
1021
0 commit comments