import { UIWindow } from "./window"; export class ViewManager { private currentWindow: UIWindow; private windows: UIWindow[]; private viewElement: HTMLDivElement; public constructor() { this.windows = []; this.viewElement = document.createElement("div"); } public add(window: UIWindow) { this.windows.push(window); window.onConnect(); this.viewElement.appendChild(window.show()); } public remove(window: UIWindow) { this.windows.splice(this.windows.indexOf(window), 1); window.onDisconnect(); this.viewElement.removeChild(window.show()); } public switchTo(window: UIWindow) { if (this.currentWindow !== undefined) { this.currentWindow.onDisconnect(); } this.currentWindow = window; this.currentWindow.onConnect(); } public render() { return this.viewElement; } }