Skip to content

Commit 49bb6bd

Browse files
committed
Support "active" tabbars in main and bottom area
1 parent 0d02ba9 commit 49bb6bd

File tree

5 files changed

+36
-4
lines changed

5 files changed

+36
-4
lines changed

packages/core/src/browser/common-frontend-contribution.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,10 +1474,6 @@ export class CommonFrontendContribution implements FrontendApplicationContributi
14741474
},
14751475
{
14761476
id: 'tab.activeBorderTop',
1477-
defaults: {
1478-
dark: 'focusBorder',
1479-
light: 'focusBorder'
1480-
},
14811477
description: 'Border to the top of an active tab. Tabs are the containers for editors in the editor area. Multiple tabs can be opened in one editor group. There can be multiple editor groups.'
14821478
},
14831479
{

packages/core/src/browser/shell/application-shell.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,7 @@ export class ApplicationShell extends Widget {
690690
this.collapseBottomPanel();
691691
}
692692
const widgets = toArray(this.bottomPanel.widgets());
693+
this.bottomPanel.markActiveTabBar(widgets[0]?.title);
693694
if (bottomPanel.pinned && bottomPanel.pinned.length === widgets.length) {
694695
widgets.forEach((a, i) => {
695696
if (bottomPanel.pinned![i]) {
@@ -706,6 +707,9 @@ export class ApplicationShell extends Widget {
706707
this.mainPanel.restoreLayout(mainPanel);
707708
this.registerWithFocusTracker(mainPanel.main);
708709
const widgets = toArray(this.mainPanel.widgets());
710+
// We don't store information about the last active tabbar
711+
// So we simply mark the first as being active
712+
this.mainPanel.markActiveTabBar(widgets[0]?.title);
709713
if (mainPanelPinned && mainPanelPinned.length === widgets.length) {
710714
widgets.forEach((a, i) => {
711715
if (mainPanelPinned[i]) {

packages/core/src/browser/shell/theia-dock-panel.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { inject } from 'inversify';
2424
import { Emitter, environment } from '../../common';
2525

2626
export const MAXIMIZED_CLASS = 'theia-maximized';
27+
export const ACTIVE_TABBAR_CLASS = 'theia-tabBar-active';
2728
const VISIBLE_MENU_MAXIMIZED_CLASS = 'theia-visible-menu-maximized';
2829

2930
export const MAIN_AREA_ID = 'theia-main-content-panel';
@@ -106,6 +107,7 @@ export class TheiaDockPanel extends DockPanel {
106107
markAsCurrent(title: Title<Widget> | undefined): void {
107108
this.toDisposeOnMarkAsCurrent.dispose();
108109
this._currentTitle = title;
110+
this.markActiveTabBar(title);
109111
if (title) {
110112
const resetCurrent = () => this.markAsCurrent(undefined);
111113
title.owner.disposed.connect(resetCurrent);
@@ -115,17 +117,31 @@ export class TheiaDockPanel extends DockPanel {
115117
}
116118
}
117119

120+
markActiveTabBar(title?: Title<Widget>): void {
121+
const tabBars = toArray(this.tabBars());
122+
tabBars.forEach(tabBar => tabBar.removeClass(ACTIVE_TABBAR_CLASS));
123+
const activeTabBar = title && this.findTabBar(title);
124+
if (activeTabBar) {
125+
activeTabBar.addClass(ACTIVE_TABBAR_CLASS);
126+
} else if (tabBars.length > 0) {
127+
// At least one tabbar needs to be active
128+
tabBars[0].addClass(ACTIVE_TABBAR_CLASS);
129+
}
130+
}
131+
118132
override addWidget(widget: Widget, options?: DockPanel.IAddOptions): void {
119133
if (this.mode === 'single-document' && widget.parent === this) {
120134
return;
121135
}
122136
super.addWidget(widget, options);
123137
this.widgetAdded.emit(widget);
138+
this.markActiveTabBar(widget.title);
124139
}
125140

126141
override activateWidget(widget: Widget): void {
127142
super.activateWidget(widget);
128143
this.widgetActivated.emit(widget);
144+
this.markActiveTabBar(widget.title);
129145
}
130146

131147
protected override onChildRemoved(msg: Widget.ChildMessage): void {

packages/core/src/browser/style/sidepanel.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,14 @@
285285
border-top: var(--theia-border-width) solid var(--theia-panelTitle-activeBorder);
286286
}
287287

288+
#theia-bottom-content-panel .p-TabBar:not(.theia-tabBar-active) .p-TabBar-tab .theia-tab-icon-label {
289+
color: var(--theia-tab-unfocusedInactiveForeground);
290+
}
291+
292+
#theia-bottom-content-panel .p-TabBar:not(.theia-tabBar-active) .p-TabBar-tab.p-mod-current .theia-tab-icon-label {
293+
color: var(--theia-tab-unfocusedActiveForeground);
294+
}
295+
288296
/*-----------------------------------------------------------------------------
289297
| Hidden tab bars used for rendering vertical side bars
290298
|----------------------------------------------------------------------------*/

packages/core/src/browser/style/tabs.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,14 @@
9191
border-top: 1px solid var(--theia-tab-activeBorderTop);
9292
}
9393

94+
#theia-main-content-panel .p-TabBar:not(.theia-tabBar-active) .p-TabBar-tab .p-TabBar-tabLabel {
95+
color: var(--theia-tab-unfocusedInactiveForeground);
96+
}
97+
98+
#theia-main-content-panel .p-TabBar:not(.theia-tabBar-active) .p-TabBar-tab.p-mod-current .p-TabBar-tabLabel {
99+
color: var(--theia-tab-unfocusedActiveForeground);
100+
}
101+
94102
.p-TabBar.theia-app-centers {
95103
background: var(--theia-editorGroupHeader-tabsBackground);
96104
}

0 commit comments

Comments
 (0)