UNPKG

@theia/core

Version:

Theia is a cloud & desktop IDE framework implemented in TypeScript.

80 lines • 3.62 kB
// ***************************************************************************** // Copyright (C) 2026 EclipseSource and others. // // This program and the accompanying materials are made available under the // terms of the Eclipse Public License v. 2.0 which is available at // http://www.eclipse.org/legal/epl-2.0. // // This Source Code may also be made available under the following Secondary // Licenses when the conditions for such availability set forth in the Eclipse // Public License v. 2.0 are satisfied: GNU General Public License, version 2 // with the GNU Classpath Exception which is available at // https://www.gnu.org/software/classpath/license.html. // // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 // ***************************************************************************** var WindowZoomStatusBarItem_1; import { __decorate } from "tslib"; import { inject, injectable } from 'inversify'; import { KeybindingRegistry, StatusBar, StatusBarAlignment } from '../../browser/index.js'; import { CommandRegistry, nls, PreferenceService } from '../../common/index.js'; import { PREF_WINDOW_ZOOM_LEVEL } from '../../electron-common/electron-window-preferences.js'; import { renderWindowZoomActionBar } from './window-zoom-action-bar.js'; let WindowZoomStatusBarItem = class WindowZoomStatusBarItem { static { WindowZoomStatusBarItem_1 = this; } static { this.ID = 'window-zoom-status'; } onStart() { this.preferenceService.ready.then(() => { this.updateZoomStatusBarItem(); this.preferenceService.onPreferenceChanged(e => { if (e.preferenceName === PREF_WINDOW_ZOOM_LEVEL) { this.updateZoomStatusBarItem(); } }); }); } updateZoomStatusBarItem() { const zoomLevel = this.getZoomLevel(); if (zoomLevel === 0) { // Hide the status bar item when zoom is at default level this.statusBar.removeElement(WindowZoomStatusBarItem_1.ID); } else { this.statusBar.setElement(WindowZoomStatusBarItem_1.ID, { name: nls.localizeByDefault('Window Zoom'), text: zoomLevel > 0 ? '$(codicon-zoom-in)' : '$(codicon-zoom-out)', alignment: StatusBarAlignment.RIGHT, priority: 110, tooltip: () => this.createTooltip(zoomLevel), backgroundColor: 'var(--theia-statusBarItem-prominentBackground)', color: 'var(--theia-statusBarItem-prominentForeground)' }); } } getZoomLevel() { return this.preferenceService.get(PREF_WINDOW_ZOOM_LEVEL, 0); } createTooltip(zoomLevel) { const container = document.createElement('div'); container.className = 'window-zoom-action-bar'; renderWindowZoomActionBar(container, zoomLevel, this.commandRegistry, this.keybindingRegistry); return container; } }; __decorate([ inject(StatusBar) ], WindowZoomStatusBarItem.prototype, "statusBar", void 0); __decorate([ inject(PreferenceService) ], WindowZoomStatusBarItem.prototype, "preferenceService", void 0); __decorate([ inject(CommandRegistry) ], WindowZoomStatusBarItem.prototype, "commandRegistry", void 0); __decorate([ inject(KeybindingRegistry) ], WindowZoomStatusBarItem.prototype, "keybindingRegistry", void 0); WindowZoomStatusBarItem = WindowZoomStatusBarItem_1 = __decorate([ injectable() ], WindowZoomStatusBarItem); export { WindowZoomStatusBarItem }; //# sourceMappingURL=window-zoom-status-bar-item.js.map