Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/browser/parts/activitybar/activitybarPart.ts
3296 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import './media/activitybarpart.css';
7
import './media/activityaction.css';
8
import { localize, localize2 } from '../../../../nls.js';
9
import { ActionsOrientation } from '../../../../base/browser/ui/actionbar/actionbar.js';
10
import { Part } from '../../part.js';
11
import { ActivityBarPosition, IWorkbenchLayoutService, LayoutSettings, Parts, Position } from '../../../services/layout/browser/layoutService.js';
12
import { IInstantiationService, ServicesAccessor } from '../../../../platform/instantiation/common/instantiation.js';
13
import { DisposableStore, MutableDisposable } from '../../../../base/common/lifecycle.js';
14
import { ToggleSidebarPositionAction, ToggleSidebarVisibilityAction } from '../../actions/layoutActions.js';
15
import { IThemeService, IColorTheme, registerThemingParticipant } from '../../../../platform/theme/common/themeService.js';
16
import { ACTIVITY_BAR_BACKGROUND, ACTIVITY_BAR_BORDER, ACTIVITY_BAR_FOREGROUND, ACTIVITY_BAR_ACTIVE_BORDER, ACTIVITY_BAR_BADGE_BACKGROUND, ACTIVITY_BAR_BADGE_FOREGROUND, ACTIVITY_BAR_INACTIVE_FOREGROUND, ACTIVITY_BAR_ACTIVE_BACKGROUND, ACTIVITY_BAR_DRAG_AND_DROP_BORDER, ACTIVITY_BAR_ACTIVE_FOCUS_BORDER } from '../../../common/theme.js';
17
import { activeContrastBorder, contrastBorder, focusBorder } from '../../../../platform/theme/common/colorRegistry.js';
18
import { addDisposableListener, append, EventType, isAncestor, $, clearNode } from '../../../../base/browser/dom.js';
19
import { assertReturnsDefined } from '../../../../base/common/types.js';
20
import { CustomMenubarControl } from '../titlebar/menubarControl.js';
21
import { IConfigurationService } from '../../../../platform/configuration/common/configuration.js';
22
import { getMenuBarVisibility, MenuSettings } from '../../../../platform/window/common/window.js';
23
import { IAction, Separator, SubmenuAction, toAction } from '../../../../base/common/actions.js';
24
import { StandardKeyboardEvent } from '../../../../base/browser/keyboardEvent.js';
25
import { KeyCode } from '../../../../base/common/keyCodes.js';
26
import { HoverPosition } from '../../../../base/browser/ui/hover/hoverWidget.js';
27
import { GestureEvent } from '../../../../base/browser/touch.js';
28
import { IPaneCompositePart } from '../paneCompositePart.js';
29
import { IPaneCompositeBarOptions, PaneCompositeBar } from '../paneCompositeBar.js';
30
import { GlobalCompositeBar } from '../globalCompositeBar.js';
31
import { IStorageService } from '../../../../platform/storage/common/storage.js';
32
import { Action2, IMenuService, MenuId, MenuRegistry, registerAction2 } from '../../../../platform/actions/common/actions.js';
33
import { ContextKeyExpr, IContextKeyService } from '../../../../platform/contextkey/common/contextkey.js';
34
import { Categories } from '../../../../platform/action/common/actionCommonCategories.js';
35
import { getContextMenuActions } from '../../../../platform/actions/browser/menuEntryActionViewItem.js';
36
import { IViewDescriptorService, ViewContainerLocation, ViewContainerLocationToString } from '../../../common/views.js';
37
import { IExtensionService } from '../../../services/extensions/common/extensions.js';
38
import { IWorkbenchEnvironmentService } from '../../../services/environment/common/environmentService.js';
39
import { IViewsService } from '../../../services/views/common/viewsService.js';
40
import { SwitchCompositeViewAction } from '../compositeBarActions.js';
41
42
export class ActivitybarPart extends Part {
43
44
static readonly ACTION_HEIGHT = 48;
45
46
static readonly pinnedViewContainersKey = 'workbench.activity.pinnedViewlets2';
47
static readonly placeholderViewContainersKey = 'workbench.activity.placeholderViewlets';
48
static readonly viewContainersWorkspaceStateKey = 'workbench.activity.viewletsWorkspaceState';
49
50
//#region IView
51
52
readonly minimumWidth: number = 48;
53
readonly maximumWidth: number = 48;
54
readonly minimumHeight: number = 0;
55
readonly maximumHeight: number = Number.POSITIVE_INFINITY;
56
57
//#endregion
58
59
private readonly compositeBar = this._register(new MutableDisposable<PaneCompositeBar>());
60
private content: HTMLElement | undefined;
61
62
constructor(
63
private readonly paneCompositePart: IPaneCompositePart,
64
@IInstantiationService private readonly instantiationService: IInstantiationService,
65
@IWorkbenchLayoutService layoutService: IWorkbenchLayoutService,
66
@IThemeService themeService: IThemeService,
67
@IStorageService storageService: IStorageService,
68
) {
69
super(Parts.ACTIVITYBAR_PART, { hasTitle: false }, themeService, storageService, layoutService);
70
}
71
72
private createCompositeBar(): PaneCompositeBar {
73
return this.instantiationService.createInstance(ActivityBarCompositeBar, {
74
partContainerClass: 'activitybar',
75
pinnedViewContainersKey: ActivitybarPart.pinnedViewContainersKey,
76
placeholderViewContainersKey: ActivitybarPart.placeholderViewContainersKey,
77
viewContainersWorkspaceStateKey: ActivitybarPart.viewContainersWorkspaceStateKey,
78
orientation: ActionsOrientation.VERTICAL,
79
icon: true,
80
iconSize: 24,
81
activityHoverOptions: {
82
position: () => this.layoutService.getSideBarPosition() === Position.LEFT ? HoverPosition.RIGHT : HoverPosition.LEFT,
83
},
84
preventLoopNavigation: true,
85
recomputeSizes: false,
86
fillExtraContextMenuActions: (actions, e?: MouseEvent | GestureEvent) => { },
87
compositeSize: 52,
88
colors: (theme: IColorTheme) => ({
89
activeForegroundColor: theme.getColor(ACTIVITY_BAR_FOREGROUND),
90
inactiveForegroundColor: theme.getColor(ACTIVITY_BAR_INACTIVE_FOREGROUND),
91
activeBorderColor: theme.getColor(ACTIVITY_BAR_ACTIVE_BORDER),
92
activeBackground: theme.getColor(ACTIVITY_BAR_ACTIVE_BACKGROUND),
93
badgeBackground: theme.getColor(ACTIVITY_BAR_BADGE_BACKGROUND),
94
badgeForeground: theme.getColor(ACTIVITY_BAR_BADGE_FOREGROUND),
95
dragAndDropBorder: theme.getColor(ACTIVITY_BAR_DRAG_AND_DROP_BORDER),
96
activeBackgroundColor: undefined, inactiveBackgroundColor: undefined, activeBorderBottomColor: undefined,
97
}),
98
overflowActionSize: ActivitybarPart.ACTION_HEIGHT,
99
}, Parts.ACTIVITYBAR_PART, this.paneCompositePart, true);
100
}
101
102
protected override createContentArea(parent: HTMLElement): HTMLElement {
103
this.element = parent;
104
this.content = append(this.element, $('.content'));
105
106
if (this.layoutService.isVisible(Parts.ACTIVITYBAR_PART)) {
107
this.show();
108
}
109
110
return this.content;
111
}
112
113
getPinnedPaneCompositeIds(): string[] {
114
return this.compositeBar.value?.getPinnedPaneCompositeIds() ?? [];
115
}
116
117
getVisiblePaneCompositeIds(): string[] {
118
return this.compositeBar.value?.getVisiblePaneCompositeIds() ?? [];
119
}
120
121
getPaneCompositeIds(): string[] {
122
return this.compositeBar.value?.getPaneCompositeIds() ?? [];
123
}
124
125
focus(): void {
126
this.compositeBar.value?.focus();
127
}
128
129
override updateStyles(): void {
130
super.updateStyles();
131
132
const container = assertReturnsDefined(this.getContainer());
133
const background = this.getColor(ACTIVITY_BAR_BACKGROUND) || '';
134
container.style.backgroundColor = background;
135
136
const borderColor = this.getColor(ACTIVITY_BAR_BORDER) || this.getColor(contrastBorder) || '';
137
container.classList.toggle('bordered', !!borderColor);
138
container.style.borderColor = borderColor ? borderColor : '';
139
}
140
141
show(focus?: boolean): void {
142
if (!this.content) {
143
return;
144
}
145
146
if (!this.compositeBar.value) {
147
this.compositeBar.value = this.createCompositeBar();
148
this.compositeBar.value.create(this.content);
149
150
if (this.dimension) {
151
this.layout(this.dimension.width, this.dimension.height);
152
}
153
}
154
155
if (focus) {
156
this.focus();
157
}
158
}
159
160
hide(): void {
161
if (!this.compositeBar.value) {
162
return;
163
}
164
165
this.compositeBar.clear();
166
167
if (this.content) {
168
clearNode(this.content);
169
}
170
}
171
172
override layout(width: number, height: number): void {
173
super.layout(width, height, 0, 0);
174
175
if (!this.compositeBar.value) {
176
return;
177
}
178
179
// Layout contents
180
const contentAreaSize = super.layoutContents(width, height).contentSize;
181
182
// Layout composite bar
183
this.compositeBar.value.layout(width, contentAreaSize.height);
184
}
185
186
toJSON(): object {
187
return {
188
type: Parts.ACTIVITYBAR_PART
189
};
190
}
191
}
192
193
export class ActivityBarCompositeBar extends PaneCompositeBar {
194
195
private element: HTMLElement | undefined;
196
197
private readonly menuBar = this._register(new MutableDisposable<CustomMenubarControl>());
198
private menuBarContainer: HTMLElement | undefined;
199
private compositeBarContainer: HTMLElement | undefined;
200
private readonly globalCompositeBar: GlobalCompositeBar | undefined;
201
202
private readonly keyboardNavigationDisposables = this._register(new DisposableStore());
203
204
constructor(
205
options: IPaneCompositeBarOptions,
206
part: Parts,
207
paneCompositePart: IPaneCompositePart,
208
showGlobalActivities: boolean,
209
@IInstantiationService instantiationService: IInstantiationService,
210
@IStorageService storageService: IStorageService,
211
@IExtensionService extensionService: IExtensionService,
212
@IViewDescriptorService viewDescriptorService: IViewDescriptorService,
213
@IViewsService viewService: IViewsService,
214
@IContextKeyService contextKeyService: IContextKeyService,
215
@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService,
216
@IConfigurationService private readonly configurationService: IConfigurationService,
217
@IMenuService private readonly menuService: IMenuService,
218
@IWorkbenchLayoutService layoutService: IWorkbenchLayoutService,
219
) {
220
super({
221
...options,
222
fillExtraContextMenuActions: (actions, e) => {
223
options.fillExtraContextMenuActions(actions, e);
224
this.fillContextMenuActions(actions, e);
225
}
226
}, part, paneCompositePart, instantiationService, storageService, extensionService, viewDescriptorService, viewService, contextKeyService, environmentService, layoutService);
227
228
if (showGlobalActivities) {
229
this.globalCompositeBar = this._register(instantiationService.createInstance(GlobalCompositeBar, () => this.getContextMenuActions(), (theme: IColorTheme) => this.options.colors(theme), this.options.activityHoverOptions));
230
}
231
232
// Register for configuration changes
233
this._register(this.configurationService.onDidChangeConfiguration(e => {
234
if (e.affectsConfiguration(MenuSettings.MenuBarVisibility)) {
235
if (getMenuBarVisibility(this.configurationService) === 'compact') {
236
this.installMenubar();
237
} else {
238
this.uninstallMenubar();
239
}
240
}
241
}));
242
}
243
244
private fillContextMenuActions(actions: IAction[], e?: MouseEvent | GestureEvent) {
245
// Menu
246
const menuBarVisibility = getMenuBarVisibility(this.configurationService);
247
if (menuBarVisibility === 'compact' || menuBarVisibility === 'hidden' || menuBarVisibility === 'toggle') {
248
actions.unshift(...[toAction({ id: 'toggleMenuVisibility', label: localize('menu', "Menu"), checked: menuBarVisibility === 'compact', run: () => this.configurationService.updateValue(MenuSettings.MenuBarVisibility, menuBarVisibility === 'compact' ? 'toggle' : 'compact') }), new Separator()]);
249
}
250
251
if (menuBarVisibility === 'compact' && this.menuBarContainer && e?.target) {
252
if (isAncestor(e.target as Node, this.menuBarContainer)) {
253
actions.unshift(...[toAction({ id: 'hideCompactMenu', label: localize('hideMenu', "Hide Menu"), run: () => this.configurationService.updateValue(MenuSettings.MenuBarVisibility, 'toggle') }), new Separator()]);
254
}
255
}
256
257
// Global Composite Bar
258
if (this.globalCompositeBar) {
259
actions.push(new Separator());
260
actions.push(...this.globalCompositeBar.getContextMenuActions());
261
}
262
actions.push(new Separator());
263
actions.push(...this.getActivityBarContextMenuActions());
264
}
265
266
private uninstallMenubar() {
267
if (this.menuBar.value) {
268
this.menuBar.value = undefined;
269
}
270
271
if (this.menuBarContainer) {
272
this.menuBarContainer.remove();
273
this.menuBarContainer = undefined;
274
}
275
}
276
277
private installMenubar() {
278
if (this.menuBar.value) {
279
return; // prevent menu bar from installing twice #110720
280
}
281
282
this.menuBarContainer = $('.menubar');
283
284
const content = assertReturnsDefined(this.element);
285
content.prepend(this.menuBarContainer);
286
287
// Menubar: install a custom menu bar depending on configuration
288
this.menuBar.value = this._register(this.instantiationService.createInstance(CustomMenubarControl));
289
this.menuBar.value.create(this.menuBarContainer);
290
291
}
292
293
private registerKeyboardNavigationListeners(): void {
294
this.keyboardNavigationDisposables.clear();
295
296
// Up/Down or Left/Right arrow on compact menu
297
if (this.menuBarContainer) {
298
this.keyboardNavigationDisposables.add(addDisposableListener(this.menuBarContainer, EventType.KEY_DOWN, e => {
299
const kbEvent = new StandardKeyboardEvent(e);
300
if (kbEvent.equals(KeyCode.DownArrow) || kbEvent.equals(KeyCode.RightArrow)) {
301
this.focus();
302
}
303
}));
304
}
305
306
// Up/Down on Activity Icons
307
if (this.compositeBarContainer) {
308
this.keyboardNavigationDisposables.add(addDisposableListener(this.compositeBarContainer, EventType.KEY_DOWN, e => {
309
const kbEvent = new StandardKeyboardEvent(e);
310
if (kbEvent.equals(KeyCode.DownArrow) || kbEvent.equals(KeyCode.RightArrow)) {
311
this.globalCompositeBar?.focus();
312
} else if (kbEvent.equals(KeyCode.UpArrow) || kbEvent.equals(KeyCode.LeftArrow)) {
313
this.menuBar.value?.toggleFocus();
314
}
315
}));
316
}
317
318
// Up arrow on global icons
319
if (this.globalCompositeBar) {
320
this.keyboardNavigationDisposables.add(addDisposableListener(this.globalCompositeBar.element, EventType.KEY_DOWN, e => {
321
const kbEvent = new StandardKeyboardEvent(e);
322
if (kbEvent.equals(KeyCode.UpArrow) || kbEvent.equals(KeyCode.LeftArrow)) {
323
this.focus(this.getVisiblePaneCompositeIds().length - 1);
324
}
325
}));
326
}
327
}
328
329
override create(parent: HTMLElement): HTMLElement {
330
this.element = parent;
331
332
// Install menubar if compact
333
if (getMenuBarVisibility(this.configurationService) === 'compact') {
334
this.installMenubar();
335
}
336
337
// View Containers action bar
338
this.compositeBarContainer = super.create(this.element);
339
340
// Global action bar
341
if (this.globalCompositeBar) {
342
this.globalCompositeBar.create(this.element);
343
}
344
345
// Keyboard Navigation
346
this.registerKeyboardNavigationListeners();
347
348
return this.compositeBarContainer;
349
}
350
351
override layout(width: number, height: number): void {
352
if (this.menuBarContainer) {
353
if (this.options.orientation === ActionsOrientation.VERTICAL) {
354
height -= this.menuBarContainer.clientHeight;
355
} else {
356
width -= this.menuBarContainer.clientWidth;
357
}
358
}
359
if (this.globalCompositeBar) {
360
if (this.options.orientation === ActionsOrientation.VERTICAL) {
361
height -= (this.globalCompositeBar.size() * ActivitybarPart.ACTION_HEIGHT);
362
} else {
363
width -= this.globalCompositeBar.element.clientWidth;
364
}
365
}
366
super.layout(width, height);
367
}
368
369
getActivityBarContextMenuActions(): IAction[] {
370
const activityBarPositionMenu = this.menuService.getMenuActions(MenuId.ActivityBarPositionMenu, this.contextKeyService, { shouldForwardArgs: true, renderShortTitle: true });
371
const positionActions = getContextMenuActions(activityBarPositionMenu).secondary;
372
const actions = [
373
new SubmenuAction('workbench.action.panel.position', localize('activity bar position', "Activity Bar Position"), positionActions),
374
toAction({ id: ToggleSidebarPositionAction.ID, label: ToggleSidebarPositionAction.getLabel(this.layoutService), run: () => this.instantiationService.invokeFunction(accessor => new ToggleSidebarPositionAction().run(accessor)) }),
375
];
376
377
if (this.part === Parts.SIDEBAR_PART) {
378
actions.push(toAction({ id: ToggleSidebarVisibilityAction.ID, label: ToggleSidebarVisibilityAction.LABEL, run: () => this.instantiationService.invokeFunction(accessor => new ToggleSidebarVisibilityAction().run(accessor)) }));
379
}
380
381
return actions;
382
}
383
384
}
385
386
registerAction2(class extends Action2 {
387
constructor() {
388
super({
389
id: 'workbench.action.activityBarLocation.default',
390
title: {
391
...localize2('positionActivityBarDefault', 'Move Activity Bar to Side'),
392
mnemonicTitle: localize({ key: 'miDefaultActivityBar', comment: ['&& denotes a mnemonic'] }, "&&Default"),
393
},
394
shortTitle: localize('default', "Default"),
395
category: Categories.View,
396
toggled: ContextKeyExpr.equals(`config.${LayoutSettings.ACTIVITY_BAR_LOCATION}`, ActivityBarPosition.DEFAULT),
397
menu: [{
398
id: MenuId.ActivityBarPositionMenu,
399
order: 1
400
}, {
401
id: MenuId.CommandPalette,
402
when: ContextKeyExpr.notEquals(`config.${LayoutSettings.ACTIVITY_BAR_LOCATION}`, ActivityBarPosition.DEFAULT),
403
}]
404
});
405
}
406
run(accessor: ServicesAccessor): void {
407
const configurationService = accessor.get(IConfigurationService);
408
configurationService.updateValue(LayoutSettings.ACTIVITY_BAR_LOCATION, ActivityBarPosition.DEFAULT);
409
}
410
});
411
412
registerAction2(class extends Action2 {
413
constructor() {
414
super({
415
id: 'workbench.action.activityBarLocation.top',
416
title: {
417
...localize2('positionActivityBarTop', 'Move Activity Bar to Top'),
418
mnemonicTitle: localize({ key: 'miTopActivityBar', comment: ['&& denotes a mnemonic'] }, "&&Top"),
419
},
420
shortTitle: localize('top', "Top"),
421
category: Categories.View,
422
toggled: ContextKeyExpr.equals(`config.${LayoutSettings.ACTIVITY_BAR_LOCATION}`, ActivityBarPosition.TOP),
423
menu: [{
424
id: MenuId.ActivityBarPositionMenu,
425
order: 2
426
}, {
427
id: MenuId.CommandPalette,
428
when: ContextKeyExpr.notEquals(`config.${LayoutSettings.ACTIVITY_BAR_LOCATION}`, ActivityBarPosition.TOP),
429
}]
430
});
431
}
432
run(accessor: ServicesAccessor): void {
433
const configurationService = accessor.get(IConfigurationService);
434
configurationService.updateValue(LayoutSettings.ACTIVITY_BAR_LOCATION, ActivityBarPosition.TOP);
435
}
436
});
437
438
registerAction2(class extends Action2 {
439
constructor() {
440
super({
441
id: 'workbench.action.activityBarLocation.bottom',
442
title: {
443
...localize2('positionActivityBarBottom', 'Move Activity Bar to Bottom'),
444
mnemonicTitle: localize({ key: 'miBottomActivityBar', comment: ['&& denotes a mnemonic'] }, "&&Bottom"),
445
},
446
shortTitle: localize('bottom', "Bottom"),
447
category: Categories.View,
448
toggled: ContextKeyExpr.equals(`config.${LayoutSettings.ACTIVITY_BAR_LOCATION}`, ActivityBarPosition.BOTTOM),
449
menu: [{
450
id: MenuId.ActivityBarPositionMenu,
451
order: 3
452
}, {
453
id: MenuId.CommandPalette,
454
when: ContextKeyExpr.notEquals(`config.${LayoutSettings.ACTIVITY_BAR_LOCATION}`, ActivityBarPosition.BOTTOM),
455
}]
456
});
457
}
458
run(accessor: ServicesAccessor): void {
459
const configurationService = accessor.get(IConfigurationService);
460
configurationService.updateValue(LayoutSettings.ACTIVITY_BAR_LOCATION, ActivityBarPosition.BOTTOM);
461
}
462
});
463
464
registerAction2(class extends Action2 {
465
constructor() {
466
super({
467
id: 'workbench.action.activityBarLocation.hide',
468
title: {
469
...localize2('hideActivityBar', 'Hide Activity Bar'),
470
mnemonicTitle: localize({ key: 'miHideActivityBar', comment: ['&& denotes a mnemonic'] }, "&&Hidden"),
471
},
472
shortTitle: localize('hide', "Hidden"),
473
category: Categories.View,
474
toggled: ContextKeyExpr.equals(`config.${LayoutSettings.ACTIVITY_BAR_LOCATION}`, ActivityBarPosition.HIDDEN),
475
menu: [{
476
id: MenuId.ActivityBarPositionMenu,
477
order: 4
478
}, {
479
id: MenuId.CommandPalette,
480
when: ContextKeyExpr.notEquals(`config.${LayoutSettings.ACTIVITY_BAR_LOCATION}`, ActivityBarPosition.HIDDEN),
481
}]
482
});
483
}
484
run(accessor: ServicesAccessor): void {
485
const configurationService = accessor.get(IConfigurationService);
486
configurationService.updateValue(LayoutSettings.ACTIVITY_BAR_LOCATION, ActivityBarPosition.HIDDEN);
487
}
488
});
489
490
MenuRegistry.appendMenuItem(MenuId.MenubarAppearanceMenu, {
491
submenu: MenuId.ActivityBarPositionMenu,
492
title: localize('positionActivituBar', "Activity Bar Position"),
493
group: '3_workbench_layout_move',
494
order: 2
495
});
496
497
MenuRegistry.appendMenuItem(MenuId.ViewContainerTitleContext, {
498
submenu: MenuId.ActivityBarPositionMenu,
499
title: localize('positionActivituBar', "Activity Bar Position"),
500
when: ContextKeyExpr.or(
501
ContextKeyExpr.equals('viewContainerLocation', ViewContainerLocationToString(ViewContainerLocation.Sidebar)),
502
ContextKeyExpr.equals('viewContainerLocation', ViewContainerLocationToString(ViewContainerLocation.AuxiliaryBar))
503
),
504
group: '3_workbench_layout_move',
505
order: 1
506
});
507
508
registerAction2(class extends SwitchCompositeViewAction {
509
constructor() {
510
super({
511
id: 'workbench.action.previousSideBarView',
512
title: localize2('previousSideBarView', 'Previous Primary Side Bar View'),
513
category: Categories.View,
514
f1: true
515
}, ViewContainerLocation.Sidebar, -1);
516
}
517
});
518
519
registerAction2(class extends SwitchCompositeViewAction {
520
constructor() {
521
super({
522
id: 'workbench.action.nextSideBarView',
523
title: localize2('nextSideBarView', 'Next Primary Side Bar View'),
524
category: Categories.View,
525
f1: true
526
}, ViewContainerLocation.Sidebar, 1);
527
}
528
});
529
530
registerAction2(
531
class FocusActivityBarAction extends Action2 {
532
constructor() {
533
super({
534
id: 'workbench.action.focusActivityBar',
535
title: localize2('focusActivityBar', 'Focus Activity Bar'),
536
category: Categories.View,
537
f1: true
538
});
539
}
540
541
async run(accessor: ServicesAccessor): Promise<void> {
542
const layoutService = accessor.get(IWorkbenchLayoutService);
543
layoutService.focusPart(Parts.ACTIVITYBAR_PART);
544
}
545
});
546
547
registerThemingParticipant((theme, collector) => {
548
549
const activityBarActiveBorderColor = theme.getColor(ACTIVITY_BAR_ACTIVE_BORDER);
550
if (activityBarActiveBorderColor) {
551
collector.addRule(`
552
.monaco-workbench .activitybar > .content :not(.monaco-menu) > .monaco-action-bar .action-item.checked .active-item-indicator:before {
553
border-left-color: ${activityBarActiveBorderColor};
554
}
555
`);
556
}
557
558
const activityBarActiveFocusBorderColor = theme.getColor(ACTIVITY_BAR_ACTIVE_FOCUS_BORDER);
559
if (activityBarActiveFocusBorderColor) {
560
collector.addRule(`
561
.monaco-workbench .activitybar > .content :not(.monaco-menu) > .monaco-action-bar .action-item.checked:focus::before {
562
visibility: hidden;
563
}
564
565
.monaco-workbench .activitybar > .content :not(.monaco-menu) > .monaco-action-bar .action-item.checked:focus .active-item-indicator:before {
566
visibility: visible;
567
border-left-color: ${activityBarActiveFocusBorderColor};
568
}
569
`);
570
}
571
572
const activityBarActiveBackgroundColor = theme.getColor(ACTIVITY_BAR_ACTIVE_BACKGROUND);
573
if (activityBarActiveBackgroundColor) {
574
collector.addRule(`
575
.monaco-workbench .activitybar > .content :not(.monaco-menu) > .monaco-action-bar .action-item.checked .active-item-indicator {
576
z-index: 0;
577
background-color: ${activityBarActiveBackgroundColor};
578
}
579
`);
580
}
581
582
// Styling with Outline color (e.g. high contrast theme)
583
const outline = theme.getColor(activeContrastBorder);
584
if (outline) {
585
collector.addRule(`
586
.monaco-workbench .activitybar > .content :not(.monaco-menu) > .monaco-action-bar .action-item .action-label::before{
587
padding: 6px;
588
}
589
590
.monaco-workbench .activitybar > .content :not(.monaco-menu) > .monaco-action-bar .action-item.active .action-label::before,
591
.monaco-workbench .activitybar > .content :not(.monaco-menu) > .monaco-action-bar .action-item.active:hover .action-label::before,
592
.monaco-workbench .activitybar > .content :not(.monaco-menu) > .monaco-action-bar .action-item.checked .action-label::before,
593
.monaco-workbench .activitybar > .content :not(.monaco-menu) > .monaco-action-bar .action-item.checked:hover .action-label::before {
594
outline: 1px solid ${outline};
595
}
596
597
.monaco-workbench .activitybar > .content :not(.monaco-menu) > .monaco-action-bar .action-item:hover .action-label::before {
598
outline: 1px dashed ${outline};
599
}
600
601
.monaco-workbench .activitybar > .content :not(.monaco-menu) > .monaco-action-bar .action-item:focus .active-item-indicator:before {
602
border-left-color: ${outline};
603
}
604
`);
605
}
606
607
// Styling without outline color
608
else {
609
const focusBorderColor = theme.getColor(focusBorder);
610
if (focusBorderColor) {
611
collector.addRule(`
612
.monaco-workbench .activitybar > .content :not(.monaco-menu) > .monaco-action-bar .action-item:focus .active-item-indicator::before {
613
border-left-color: ${focusBorderColor};
614
}
615
`);
616
}
617
}
618
});
619
620