import { IDanmaMessage , Point , Rect } from '../interface/IDanmaMessage' ; import { IDanmaTrackInfo } from '../interface/IDanmaTrack' ; export abstract class BaseMessage implements IDanmaMessage { created : boolean = false ; distoryed : boolean = false ; isLayout : boolean = false ; position : Point = { top : 0 , left : 0 } ; size : Rect = { width : 0 , height : 0 } ; onBaseCreate ( ) { this . onCreate ( ( val ) => { if ( val ) { this . created = true ; } else { this . distoryed = true ; } } ) ; } onBaseDestroyed ( ) { this . distoryed = this . onDestroyed ( ) ; } onBaseMeasure ( ctx , trackInfo ) { this . size = this . onMeasure ( ctx , trackInfo ) ; } onBaseLayout ( ctx , trackInfo ) { this . position = this . onLayout ( ctx , trackInfo ) ; } onBaseDraw ( ctx , trackInfo ) { this . onDraw ( ctx , trackInfo ) ; } abstract onCreate ( callback ) ; abstract onMeasure ( ctx , trackInfo ) ; abstract onLayout ( ctx , trackInfo ) ; abstract onDraw ( ctx , trackInfo ) ; abstract onDestroyed ( ) ; }