diff --git a/arduino-ide-extension/src/browser/arduino-ide-frontend-module.ts b/arduino-ide-extension/src/browser/arduino-ide-frontend-module.ts index f131b1e2..b4eb99b9 100644 --- a/arduino-ide-extension/src/browser/arduino-ide-frontend-module.ts +++ b/arduino-ide-extension/src/browser/arduino-ide-frontend-module.ts @@ -33,7 +33,9 @@ import { ApplicationShell as TheiaApplicationShell, ShellLayoutRestorer as TheiaShellLayoutRestorer, CommonFrontendContribution as TheiaCommonFrontendContribution, - KeybindingRegistry as TheiaKeybindingRegistry + KeybindingRegistry as TheiaKeybindingRegistry, + TabBarRendererFactory, + ContextMenuRenderer } from '@theia/core/lib/browser'; import { MenuContribution } from '@theia/core/lib/common/menu'; import { ApplicationShell } from './theia/core/application-shell'; @@ -120,6 +122,8 @@ import { OutputServicePath, OutputService } from '../common/protocol/output-serv import { NotificationCenter } from './notification-center'; import { NotificationServicePath, NotificationServiceServer } from '../common/protocol'; import { About } from './contributions/about'; +import { IconThemeService } from '@theia/core/lib/browser/icon-theme-service'; +import { TabBarRenderer } from './theia/core/tab-bars'; const ElementQueries = require('css-element-queries/src/ElementQueries'); @@ -329,4 +333,12 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => { bind(NotificationCenter).toSelf().inSingletonScope(); bind(NotificationServiceServer).toDynamicValue(context => WebSocketConnectionProvider.createProxy(context.container, NotificationServicePath)).inSingletonScope(); + + // Enable the dirty indicator on uncloseable widgets. + rebind(TabBarRendererFactory).toFactory(context => () => { + const contextMenuRenderer = context.container.get(ContextMenuRenderer); + const decoratorService = context.container.get(TabBarDecoratorService); + const iconThemeService = context.container.get(IconThemeService); + return new TabBarRenderer(contextMenuRenderer, decoratorService, iconThemeService); + }); }); diff --git a/arduino-ide-extension/src/browser/style/editor.css b/arduino-ide-extension/src/browser/style/editor.css new file mode 100644 index 00000000..220c7bd3 --- /dev/null +++ b/arduino-ide-extension/src/browser/style/editor.css @@ -0,0 +1,6 @@ +/* Show the dirty indicator on unclosable widgets. On hover, it should still show the dot instead of the X. */ +/* https://github.com/arduino/arduino-pro-ide/issues/380 */ +.p-TabBar.theia-app-centers .p-TabBar-tab.p-mod-closable.theia-mod-dirty > .p-TabBar-tabCloseIcon:hover { + background-size: 13px; + background-image: var(--theia-icon-circle); +} diff --git a/arduino-ide-extension/src/browser/style/index.css b/arduino-ide-extension/src/browser/style/index.css index bb8c88c3..68e984f9 100644 --- a/arduino-ide-extension/src/browser/style/index.css +++ b/arduino-ide-extension/src/browser/style/index.css @@ -5,6 +5,7 @@ @import './arduino-select.css'; @import './status-bar.css'; @import './terminal.css'; +@import './editor.css'; .theia-input.warning:focus { outline-width: 1px; diff --git a/arduino-ide-extension/src/browser/theia/core/tab-bars.ts b/arduino-ide-extension/src/browser/theia/core/tab-bars.ts new file mode 100644 index 00000000..c6d547b2 --- /dev/null +++ b/arduino-ide-extension/src/browser/theia/core/tab-bars.ts @@ -0,0 +1,15 @@ +import { TabBar } from '@phosphor/widgets'; +import { Saveable } from '@theia/core/lib/browser/saveable'; +import { TabBarRenderer as TheiaTabBarRenderer } from '@theia/core/lib/browser/shell/tab-bars'; + +export class TabBarRenderer extends TheiaTabBarRenderer { + + createTabClass(data: TabBar.IRenderData): string { + let className = super.createTabClass(data); + if (!data.title.closable && Saveable.isDirty(data.title.owner)) { + className += ' p-mod-closable'; + } + return className; + } + +}