This commit is contained in:
BeniBenj
2024-01-18 15:39:03 +01:00
parent f214ef2c1c
commit fba98d1cdf
6 changed files with 40 additions and 27 deletions
@@ -803,7 +803,7 @@ if (isWindows || isLinux || isWeb) {
title: localize('miMenuBarNoMnemonic', "Menu Bar"),
toggled: ContextKeyExpr.and(IsMacNativeContext.toNegated(), ContextKeyExpr.notEquals('config.window.menuBarVisibility', 'hidden'), ContextKeyExpr.notEquals('config.window.menuBarVisibility', 'toggle'), ContextKeyExpr.notEquals('config.window.menuBarVisibility', 'compact'))
},
when: ContextKeyExpr.and(IsAuxiliaryWindowFocusedContext.toNegated(), ContextKeyExpr.notEquals(TitleBarSetting.TITLE_BAR_STYLE, TitlebarStyle.NATIVE)),
when: ContextKeyExpr.and(IsAuxiliaryWindowFocusedContext.toNegated(), ContextKeyExpr.notEquals(TitleBarSetting.TITLE_BAR_STYLE, TitlebarStyle.NATIVE), IsMainWindowFullscreenContext.negate()),
group: '2_config',
order: 0
});
+31 -17
View File
@@ -347,6 +347,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
LayoutSettings.ACTIVITY_BAR_LOCATION,
LayoutSettings.COMMAND_CENTER,
LayoutSettings.EDITOR_ACTIONS_LOCATION,
LayoutSettings.LAYOUT_ACTIONS,
LegacyWorkbenchLayoutSettings.SIDEBAR_POSITION,
LegacyWorkbenchLayoutSettings.STATUSBAR_VISIBLE,
'window.menuBarVisibility',
@@ -1229,31 +1230,18 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
return false;
}
const nativeTitleBarVisible = hasNativeTitlebar(this.configurationService);
const nativeTitleBarEnabled = hasNativeTitlebar(this.configurationService);
const showCustomTitleBar = this.configurationService.getValue<CustomTitleBarVisibility>(TitleBarSetting.CUSTOM_TITLE_BAR_VISIBILITY);
if (showCustomTitleBar === CustomTitleBarVisibility.NEVER && nativeTitleBarVisible || showCustomTitleBar === CustomTitleBarVisibility.WINDOWED && this.state.runtime.mainWindowFullscreen) {
if (showCustomTitleBar === CustomTitleBarVisibility.NEVER && nativeTitleBarEnabled || showCustomTitleBar === CustomTitleBarVisibility.WINDOWED && this.state.runtime.mainWindowFullscreen) {
return false;
}
// with the command center enabled, we should always show
if (this.configurationService.getValue<boolean>(LayoutSettings.COMMAND_CENTER)) {
return true;
}
// with the activity bar on top, we should always show
if (this.configurationService.getValue(LayoutSettings.ACTIVITY_BAR_LOCATION) === ActivityBarPosition.TOP) {
return true;
}
// with the editor actions on top, we should always show
const editorActionsLocation = this.configurationService.getValue<EditorActionsLocation>(LayoutSettings.EDITOR_ACTIONS_LOCATION);
const editorTabsMode = this.configurationService.getValue<EditorTabsMode>(LayoutSettings.EDITOR_TABS_MODE);
if (editorActionsLocation === EditorActionsLocation.TITLEBAR || editorActionsLocation === EditorActionsLocation.DEFAULT && editorTabsMode === EditorTabsMode.NONE) {
if (!this.isTitleBarEmpty(nativeTitleBarEnabled)) {
return true;
}
// Hide custom title bar when native title bar and custom title bar is empty
if (nativeTitleBarVisible) {
if (nativeTitleBarEnabled) {
return false;
}
@@ -1288,6 +1276,32 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
}
}
private isTitleBarEmpty(nativeTitleBarEnabled: boolean): boolean {
// with the command center enabled, we should always show
if (this.configurationService.getValue<boolean>(LayoutSettings.COMMAND_CENTER)) {
return false;
}
// with the activity bar on top, we should always show
if (this.configurationService.getValue(LayoutSettings.ACTIVITY_BAR_LOCATION) === ActivityBarPosition.TOP) {
return false;
}
// with the editor actions on top, we should always show
const editorActionsLocation = this.configurationService.getValue<EditorActionsLocation>(LayoutSettings.EDITOR_ACTIONS_LOCATION);
const editorTabsMode = this.configurationService.getValue<EditorTabsMode>(LayoutSettings.EDITOR_TABS_MODE);
if (editorActionsLocation === EditorActionsLocation.TITLEBAR || editorActionsLocation === EditorActionsLocation.DEFAULT && editorTabsMode === EditorTabsMode.NONE) {
return false;
}
// Layout don't show with native title bar
if (!nativeTitleBarEnabled && this.configurationService.getValue<boolean>(LayoutSettings.LAYOUT_ACTIONS)) {
return false;
}
return true;
}
private shouldShowBannerFirst(): boolean {
return isWeb && !isWCOEnabled();
}
@@ -69,8 +69,7 @@ registerAction2(class ToggleCustomTitleBar extends Action2 {
constructor() {
super({
id: `toggle.${ToggleCustomTitleBar.settingsID}`,
title: localize('toggle.customTitleBar', 'Custom Title Bar'),
toggled: ContextKeyExpr.true(),
title: localize('toggle.hideCustomTitleBar', 'Hide Custom Title Bar'),
menu: [
{ id: MenuId.TitleBarContext, order: 0, when: ContextKeyExpr.equals(TitleBarSetting.TITLE_BAR_STYLE, TitlebarStyle.NATIVE), group: '3_toggle' },
]
@@ -84,13 +83,12 @@ registerAction2(class ToggleCustomTitleBar extends Action2 {
});
registerAction2(class ToggleCustomTitleBarWindowed extends Action2 {
static readonly settingsID = TitleBarSetting.TITLE_BAR_STYLE;
static readonly settingsID = TitleBarSetting.CUSTOM_TITLE_BAR_VISIBILITY;
constructor() {
super({
id: `toggle.${ToggleCustomTitleBarWindowed.settingsID}.windowed`,
title: localize('toggle.customTitleBarWindowed', 'Custom Title Bar In Full Screen'),
toggled: ContextKeyExpr.true(),
title: localize('toggle.hideCustomTitleBarInFullScreen', 'Hide Custom Title Bar In Full Screen'),
menu: [
{ id: MenuId.TitleBarContext, order: 0, when: IsMainWindowFullscreenContext, group: '3_toggle' },
]
@@ -322,7 +322,7 @@ export class BrowserTitlebarPart extends Part implements ITitlebarPart {
// Actions
if (hasCustomTitlebar(this.configurationService, this.titleBarStyle) && this.actionToolBar) {
const affectsLayoutControl = event.affectsConfiguration('workbench.layoutControl.enabled');
const affectsLayoutControl = event.affectsConfiguration(LayoutSettings.LAYOUT_ACTIONS);
const affectsActivityControl = event.affectsConfiguration(LayoutSettings.ACTIVITY_BAR_LOCATION);
if (affectsLayoutControl || affectsActivityControl) {
@@ -699,7 +699,7 @@ export class BrowserTitlebarPart extends Part implements ITitlebarPart {
}
private get layoutControlEnabled(): boolean {
return !this.isAuxiliary && this.configurationService.getValue<boolean>('workbench.layoutControl.enabled') !== false && !hasNativeTitlebar(this.configurationService, this.titleBarStyle);
return !this.isAuxiliary && this.configurationService.getValue<boolean>(LayoutSettings.LAYOUT_ACTIONS) !== false && !hasNativeTitlebar(this.configurationService, this.titleBarStyle);
}
protected get isCommandCenterVisible() {
@@ -710,7 +710,7 @@ export class BrowserTitlebarPart extends Part implements ITitlebarPart {
return this.editorGroupService.partOptions.editorActionsLocation === EditorActionsLocation.TITLEBAR ||
(
this.editorGroupService.partOptions.editorActionsLocation === EditorActionsLocation.DEFAULT &&
this.editorGroupService.partOptions.showTabs === EditorTabsMode.MULTIPLE
this.editorGroupService.partOptions.showTabs === EditorTabsMode.NONE
);
}
@@ -566,7 +566,7 @@ const registry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Con
tags: ['accessibility'],
enum: ['on', 'off', 'auto']
},
'workbench.layoutControl.enabled': {
[LayoutSettings.LAYOUT_ACTIONS]: {
'type': 'boolean',
'default': true,
'markdownDescription': isWeb ?
@@ -39,6 +39,7 @@ export const enum LayoutSettings {
EDITOR_TABS_MODE = 'workbench.editor.showTabs',
EDITOR_ACTIONS_LOCATION = 'workbench.editor.editorActionsLocation',
COMMAND_CENTER = 'window.commandCenter',
LAYOUT_ACTIONS = 'workbench.layoutControl.enabled',
}
export const enum ActivityBarPosition {