@@ -16,7 +16,7 @@ import {
16
16
Status ,
17
17
stringToBoolean ,
18
18
} from '../../../utils' ;
19
- import { Rect } from '../../../math' ;
19
+ import { EPSILON1 , Rect , areClose } from '../../../math' ;
20
20
import {
21
21
stringToDrawLayerType ,
22
22
stringToFrameStrataType ,
@@ -53,6 +53,7 @@ class Frame extends ScriptRegion {
53
53
visible : boolean ;
54
54
strataType : FrameStrataType ;
55
55
level : number ;
56
+ frameScale : number ;
56
57
57
58
layersEnabled : EnumRecord < DrawLayerType , boolean > ;
58
59
backdrop : Backdrop | null ;
@@ -77,6 +78,7 @@ class Frame extends ScriptRegion {
77
78
this . visible = false ;
78
79
this . strataType = FrameStrataType . MEDIUM ;
79
80
this . level = 0 ;
81
+ this . frameScale = 1.0 ;
80
82
81
83
this . layersEnabled = [
82
84
true ,
@@ -210,19 +212,21 @@ class Frame extends ScriptRegion {
210
212
if ( parent ) {
211
213
this . setFrameStrataType ( parent . strataType ) ;
212
214
this . setFrameLevel ( parent . level + 1 , true ) ;
215
+ this . updateScale ( false ) ;
213
216
214
217
// TODO: Alpha and scrolling adjustments
215
218
} else {
216
219
this . setFrameStrataType ( FrameStrataType . MEDIUM ) ;
217
220
this . setFrameLevel ( 0 , true ) ;
221
+ this . updateScale ( false ) ;
218
222
219
223
// TODO: Alpha and scrolling adjustments
220
224
}
221
225
222
226
if ( parent ) {
223
227
// TODO: Parent attachment protection
224
228
const node = new FrameNode ( this ) ;
225
- parent . children . linkToHead ( node ) ;
229
+ parent . children . linkToTail ( node ) ;
226
230
}
227
231
228
232
if ( this . shown ) {
@@ -482,7 +486,7 @@ class Frame extends ScriptRegion {
482
486
return false ;
483
487
}
484
488
485
- if ( this . parent && ! this . parent . visible ) {
489
+ if ( this . _parent && ! this . _parent . visible ) {
486
490
return false ;
487
491
}
488
492
@@ -604,11 +608,23 @@ class Frame extends ScriptRegion {
604
608
605
609
// TODO: Set hit rect
606
610
607
- if ( this . backdrop ) {
608
- this . backdrop . update ( this . rect ) ;
611
+ if ( ! areClose ( rect . minX , this . rect . maxX ) || ! areClose ( rect . minY , this . rect . maxY ) ) {
612
+ if ( this . backdrop ) {
613
+ this . backdrop . update ( this . rect ) ;
614
+ }
615
+
616
+ const ratio = 1.0 / this . layoutScale ;
617
+ const width = ratio * ( this . rect . maxX - this . rect . minX ) ;
618
+ const height = ratio * ( this . rect . maxY - this . rect . minY ) ;
619
+
620
+ this . onFrameSizeChangedRange ( width , height ) ;
609
621
}
610
622
611
- // TODO: Remaining implementation
623
+ UIRoot . instance . notifyFrameMovedOrResized ( this ) ;
624
+ }
625
+
626
+ onFrameSizeChangedRange ( _width : number , _height : number ) {
627
+ // TODO
612
628
}
613
629
614
630
onLayerShow ( ) {
@@ -648,6 +664,29 @@ class Frame extends ScriptRegion {
648
664
this . runScript ( 'OnShow' ) ;
649
665
}
650
666
}
667
+
668
+ updateScale ( force : boolean ) {
669
+ let scale = this . frameScale ;
670
+ if ( this . parent ) {
671
+ scale *= this . parent . layoutScale ;
672
+ }
673
+
674
+ if ( ( ! force && areClose ( scale , this . layoutScale , EPSILON1 ) ) || scale === 0.0 ) {
675
+ return false ;
676
+ }
677
+
678
+ this . setLayoutScale ( scale , force ) ;
679
+
680
+ for ( const region of this . regions ) {
681
+ region . setLayoutScale ( scale , force ) ;
682
+ }
683
+
684
+ for ( const child of this . children ) {
685
+ child . frame . updateScale ( false ) ;
686
+ }
687
+
688
+ return true ;
689
+ }
651
690
}
652
691
653
692
export default Frame ;
0 commit comments