UNPKG

@itwin/frontend-devtools

Version:

Debug menu and supporting UI widgets

72 lines 2.63 kB
"use strict"; /*--------------------------------------------------------------------------------------------- * Copyright (c) Bentley Systems, Incorporated. All rights reserved. * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ /** @packageDocumentation * @module Widgets */ Object.defineProperty(exports, "__esModule", { value: true }); exports.RenderCommandBreakdown = void 0; const core_frontend_1 = require("@itwin/core-frontend"); const CheckBox_1 = require("../ui/CheckBox"); class RenderCommandBreakdown { _div; _cellDiv; _curIntervalId; _cells = new Map(); _total; constructor(parent) { (0, CheckBox_1.createCheckBox)({ parent, name: "Render Commands", id: "renderCommandBreakdown", handler: () => this.toggle(), }); parent.appendChild(this._div = document.createElement("div")); this._div.style.display = "none"; this._div.style.textAlign = "right"; this._div.appendChild(this._cellDiv = document.createElement("div")); this._div.appendChild(this._total = document.createElement("div")); this._total.innerText = "Total: 0"; } [Symbol.dispose]() { this.clearInterval(); } toggle() { if (undefined !== this._curIntervalId) { this._div.style.display = "none"; this.clearInterval(); } else { this._div.style.display = "block"; this.update(); this._curIntervalId = window.setInterval(() => this.update(), 500); } } clearInterval() { if (undefined !== this._curIntervalId) { window.clearInterval(this._curIntervalId); this._curIntervalId = undefined; } } update() { const ctrl = core_frontend_1.IModelApp.viewManager.selectedView?.target.debugControl; if (!ctrl) return; const cmds = ctrl.getRenderCommands(); let total = 0; for (const cmd of cmds) { let cell = this._cells.get(cmd.name); if (!cell) { this._cellDiv.appendChild(cell = document.createElement("div")); this._cells.set(cmd.name, cell); } total += cmd.count; cell.innerText = `${cmd.name}: ${cmd.count}`; } this._total.innerText = `Total: ${total}`; } } exports.RenderCommandBreakdown = RenderCommandBreakdown; //# sourceMappingURL=RenderCommandBreakdown.js.map