1/* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16import {Traces} from 'trace/traces'; 17import {TracePosition} from 'trace/trace_position'; 18import {TraceType} from 'trace/trace_type'; 19import {View, Viewer, ViewType} from 'viewers/viewer'; 20import {Events} from './events'; 21import {Presenter} from './presenter'; 22import {UiData} from './ui_data'; 23 24export class ViewerTransitions implements Viewer { 25 constructor(traces: Traces) { 26 this.htmlElement = document.createElement('viewer-transitions'); 27 28 this.presenter = new Presenter(traces, (data: UiData) => { 29 (this.htmlElement as any).inputData = data; 30 }); 31 32 this.htmlElement.addEventListener(Events.TransitionSelected, (event) => { 33 this.presenter.onTransitionSelected((event as CustomEvent).detail); 34 }); 35 } 36 37 async onTracePositionUpdate(position: TracePosition) { 38 await this.presenter.onTracePositionUpdate(position); 39 } 40 41 getViews(): View[] { 42 return [ 43 new View( 44 ViewType.TAB, 45 this.getDependencies(), 46 this.htmlElement, 47 'Transitions', 48 TraceType.TRANSITION 49 ), 50 ]; 51 } 52 53 getDependencies(): TraceType[] { 54 return ViewerTransitions.DEPENDENCIES; 55 } 56 57 static readonly DEPENDENCIES: TraceType[] = [TraceType.TRANSITION]; 58 private htmlElement: HTMLElement; 59 private presenter: Presenter; 60} 61