@@ -25,6 +25,8 @@ import { ICommandService } from 'vs/platform/commands/common/commands';
25
25
import { AuxiliaryBarVisibleContext , PanelAlignmentContext , PanelVisibleContext , SideBarVisibleContext , FocusedViewContext , InEditorZenModeContext , IsCenteredLayoutContext , EditorAreaVisibleContext , IsFullscreenContext } from 'vs/workbench/common/contextkeys' ;
26
26
import { Codicon } from 'vs/base/common/codicons' ;
27
27
import { DisposableStore } from 'vs/base/common/lifecycle' ;
28
+ import { registerIcon } from 'vs/platform/theme/common/iconRegistry' ;
29
+ import { ThemeIcon } from 'vs/platform/theme/common/themeService' ;
28
30
29
31
// --- Close Side Bar
30
32
@@ -1016,22 +1018,44 @@ registerAction2(DecreaseViewSizeAction);
1016
1018
registerAction2 ( DecreaseViewWidthAction ) ;
1017
1019
registerAction2 ( DecreaseViewHeightAction ) ;
1018
1020
1021
+ const menubarIcon = registerIcon ( 'menu-bar' , Codicon . menu , localize ( 'menuBarIcon' , "Represents the menu bar" ) ) ;
1022
+ const activityBarLeftIcon = registerIcon ( 'activity-bar-left' , Codicon . layoutActivitybarLeft , localize ( 'activityBarLeft' , "Represents the activity bar in the left position" ) ) ;
1023
+ const activityBarRightIcon = registerIcon ( 'activity-bar-right' , Codicon . layoutActivitybarRight , localize ( 'activityBarRight' , "Represents the activity bar in the right position" ) ) ;
1024
+ const panelLeftIcon = registerIcon ( 'panel-left' , Codicon . layoutSidebarLeft , localize ( 'panelLeft' , "Represents the side bar or side panel in the left position" ) ) ;
1025
+ const panelRightIcon = registerIcon ( 'panel-right' , Codicon . layoutSidebarRight , localize ( 'panelRight' , "Represents the side bar or side panel in the right position" ) ) ;
1026
+ const panelIcon = registerIcon ( 'panel-bottom' , Codicon . layoutPanel , localize ( 'panelBottom' , "Represents the bottom panel" ) ) ;
1027
+ const statusBarIcon = registerIcon ( 'statusBar' , Codicon . layoutStatusbar , localize ( 'statusBarIcon' , "Represents the status bar" ) ) ;
1028
+
1029
+ const panelAlignmentLeftIcon = registerIcon ( 'panel-align-left' , Codicon . layoutPanelLeft , localize ( 'panelBottomLeft' , "Represents the bottom panel alignment set to the left" ) ) ;
1030
+ const panelAlignmentRightIcon = registerIcon ( 'panel-align-right' , Codicon . layoutPanelRight , localize ( 'panelBottomRight' , "Represents the bottom panel alignment set to the right" ) ) ;
1031
+ const panelAlignmentCenterIcon = registerIcon ( 'panel-align-center' , Codicon . layoutPanelCenter , localize ( 'panelBottomCenter' , "Represents the bottom panel alignment set to the center" ) ) ;
1032
+ const panelAlignmentJustifyIcon = registerIcon ( 'panel-align-justify' , Codicon . layoutPanelJustify , localize ( 'panelBottomJustify' , "Represents the bottom panel alignment set to justified" ) ) ;
1033
+
1034
+ type ContextualLayoutVisualIcon = { iconA : ThemeIcon , iconB : ThemeIcon , whenA : ContextKeyExpression } ;
1035
+ type LayoutVisualIcon = ThemeIcon | ContextualLayoutVisualIcon ;
1036
+
1037
+ function isContextualLayoutVisualIcon ( icon : LayoutVisualIcon ) : icon is ContextualLayoutVisualIcon {
1038
+ return ( icon as ContextualLayoutVisualIcon ) . iconA !== undefined ;
1039
+ }
1040
+
1019
1041
interface CustomizeLayoutItem {
1020
1042
id : string ;
1021
1043
active : ContextKeyExpression ;
1022
1044
label : string ;
1023
1045
activeIcon : Codicon ;
1046
+ visualIcon ?: LayoutVisualIcon ;
1024
1047
activeAriaLabel : string ;
1025
1048
inactiveIcon ?: Codicon ;
1026
1049
inactiveAriaLabel ?: string ;
1027
1050
useButtons : boolean ;
1028
1051
}
1029
1052
1030
- const CreateToggleLayoutItem = ( id : string , active : ContextKeyExpression , label : string ) : CustomizeLayoutItem => {
1053
+ const CreateToggleLayoutItem = ( id : string , active : ContextKeyExpression , label : string , visualIcon ?: LayoutVisualIcon ) : CustomizeLayoutItem => {
1031
1054
return {
1032
1055
id,
1033
1056
active,
1034
1057
label,
1058
+ visualIcon,
1035
1059
activeIcon : Codicon . eye ,
1036
1060
inactiveIcon : Codicon . eyeClosed ,
1037
1061
activeAriaLabel : localize ( 'visible' , "Visible" ) ,
@@ -1040,11 +1064,12 @@ const CreateToggleLayoutItem = (id: string, active: ContextKeyExpression, label:
1040
1064
} ;
1041
1065
} ;
1042
1066
1043
- const CreateOptionLayoutItem = ( id : string , active : ContextKeyExpression , label : string ) : CustomizeLayoutItem => {
1067
+ const CreateOptionLayoutItem = ( id : string , active : ContextKeyExpression , label : string , visualIcon ?: LayoutVisualIcon ) : CustomizeLayoutItem => {
1044
1068
return {
1045
1069
id,
1046
1070
active,
1047
1071
label,
1072
+ visualIcon,
1048
1073
activeIcon : Codicon . check ,
1049
1074
activeAriaLabel : localize ( 'active' , "Active" ) ,
1050
1075
useButtons : false
@@ -1054,27 +1079,27 @@ const CreateOptionLayoutItem = (id: string, active: ContextKeyExpression, label:
1054
1079
const MenuBarToggledContext = ContextKeyExpr . and ( IsMacNativeContext . toNegated ( ) , ContextKeyExpr . notEquals ( 'config.window.menuBarVisibility' , 'hidden' ) , ContextKeyExpr . notEquals ( 'config.window.menuBarVisibility' , 'toggle' ) , ContextKeyExpr . notEquals ( 'config.window.menuBarVisibility' , 'compact' ) ) as ContextKeyExpression ;
1055
1080
const ToggleVisibilityActions : CustomizeLayoutItem [ ] = [ ] ;
1056
1081
if ( ! isMacintosh || ! isNative ) {
1057
- ToggleVisibilityActions . push ( CreateToggleLayoutItem ( 'workbench.action.toggleMenuBar' , MenuBarToggledContext , localize ( 'menuBar' , "Menu Bar" ) ) ) ;
1082
+ ToggleVisibilityActions . push ( CreateToggleLayoutItem ( 'workbench.action.toggleMenuBar' , MenuBarToggledContext , localize ( 'menuBar' , "Menu Bar" ) , menubarIcon ) ) ;
1058
1083
}
1059
1084
1060
1085
ToggleVisibilityActions . push ( ...[
1061
- CreateToggleLayoutItem ( ToggleActivityBarVisibilityAction . ID , ContextKeyExpr . equals ( 'config.workbench.activityBar.visible' , true ) , localize ( 'activityBar' , "Activity Bar" ) ) ,
1062
- CreateToggleLayoutItem ( ToggleSidebarVisibilityAction . ID , SideBarVisibleContext , localize ( 'sideBar' , "Side Bar" ) ) ,
1063
- CreateToggleLayoutItem ( TogglePanelAction . ID , PanelVisibleContext , localize ( 'panel' , "Panel" ) ) ,
1064
- CreateToggleLayoutItem ( ToggleAuxiliaryBarAction . ID , AuxiliaryBarVisibleContext , localize ( 'sidePanel' , "Side Panel" ) ) ,
1065
- CreateToggleLayoutItem ( ToggleStatusbarVisibilityAction . ID , ContextKeyExpr . equals ( 'config.workbench.statusBar.visible' , true ) , localize ( 'statusBar' , "Status Bar" ) ) ,
1086
+ CreateToggleLayoutItem ( ToggleActivityBarVisibilityAction . ID , ContextKeyExpr . equals ( 'config.workbench.activityBar.visible' , true ) , localize ( 'activityBar' , "Activity Bar" ) , { whenA : ContextKeyExpr . equals ( 'config.workbench.sideBar.location' , 'left' ) , iconA : activityBarLeftIcon , iconB : activityBarRightIcon } ) ,
1087
+ CreateToggleLayoutItem ( ToggleSidebarVisibilityAction . ID , SideBarVisibleContext , localize ( 'sideBar' , "Side Bar" ) , { whenA : ContextKeyExpr . equals ( 'config.workbench.sideBar.location' , 'left' ) , iconA : panelLeftIcon , iconB : panelRightIcon } ) ,
1088
+ CreateToggleLayoutItem ( TogglePanelAction . ID , PanelVisibleContext , localize ( 'panel' , "Panel" ) , panelIcon ) ,
1089
+ CreateToggleLayoutItem ( ToggleAuxiliaryBarAction . ID , AuxiliaryBarVisibleContext , localize ( 'sidePanel' , "Side Panel" ) , { whenA : ContextKeyExpr . equals ( 'config.workbench.sideBar.location' , 'left' ) , iconA : panelRightIcon , iconB : panelLeftIcon } ) ,
1090
+ CreateToggleLayoutItem ( ToggleStatusbarVisibilityAction . ID , ContextKeyExpr . equals ( 'config.workbench.statusBar.visible' , true ) , localize ( 'statusBar' , "Status Bar" ) , statusBarIcon ) ,
1066
1091
] ) ;
1067
1092
1068
1093
const MoveSideBarActions : CustomizeLayoutItem [ ] = [
1069
- CreateOptionLayoutItem ( MoveSidebarLeftAction . ID , ContextKeyExpr . equals ( 'config.workbench.sideBar.location' , 'left' ) , localize ( 'leftSideBar' , "Left" ) ) ,
1070
- CreateOptionLayoutItem ( MoveSidebarRightAction . ID , ContextKeyExpr . equals ( 'config.workbench.sideBar.location' , 'right' ) , localize ( 'rightSideBar' , "Right" ) ) ,
1094
+ CreateOptionLayoutItem ( MoveSidebarLeftAction . ID , ContextKeyExpr . equals ( 'config.workbench.sideBar.location' , 'left' ) , localize ( 'leftSideBar' , "Left" ) , panelLeftIcon ) ,
1095
+ CreateOptionLayoutItem ( MoveSidebarRightAction . ID , ContextKeyExpr . equals ( 'config.workbench.sideBar.location' , 'right' ) , localize ( 'rightSideBar' , "Right" ) , panelRightIcon ) ,
1071
1096
] ;
1072
1097
1073
1098
const AlignPanelActions : CustomizeLayoutItem [ ] = [
1074
- CreateOptionLayoutItem ( 'workbench.action.alignPanelLeft' , PanelAlignmentContext . isEqualTo ( 'left' ) , localize ( 'leftPanel' , "Left" ) ) ,
1075
- CreateOptionLayoutItem ( 'workbench.action.alignPanelRight' , PanelAlignmentContext . isEqualTo ( 'right' ) , localize ( 'rightPanel' , "Right" ) ) ,
1076
- CreateOptionLayoutItem ( 'workbench.action.alignPanelCenter' , PanelAlignmentContext . isEqualTo ( 'center' ) , localize ( 'centerPanel' , "Center" ) ) ,
1077
- CreateOptionLayoutItem ( 'workbench.action.alignPanelJustify' , PanelAlignmentContext . isEqualTo ( 'justify' ) , localize ( 'justifyPanel' , "Justify" ) ) ,
1099
+ CreateOptionLayoutItem ( 'workbench.action.alignPanelLeft' , PanelAlignmentContext . isEqualTo ( 'left' ) , localize ( 'leftPanel' , "Left" ) , panelAlignmentLeftIcon ) ,
1100
+ CreateOptionLayoutItem ( 'workbench.action.alignPanelRight' , PanelAlignmentContext . isEqualTo ( 'right' ) , localize ( 'rightPanel' , "Right" ) , panelAlignmentRightIcon ) ,
1101
+ CreateOptionLayoutItem ( 'workbench.action.alignPanelCenter' , PanelAlignmentContext . isEqualTo ( 'center' ) , localize ( 'centerPanel' , "Center" ) , panelAlignmentCenterIcon ) ,
1102
+ CreateOptionLayoutItem ( 'workbench.action.alignPanelJustify' , PanelAlignmentContext . isEqualTo ( 'justify' ) , localize ( 'justifyPanel' , "Justify" ) , panelAlignmentJustifyIcon ) ,
1078
1103
] ;
1079
1104
1080
1105
const MiscLayoutOptions : CustomizeLayoutItem [ ] = [
@@ -1108,12 +1133,22 @@ registerAction2(class CustomizeLayoutAction extends Action2 {
1108
1133
getItems ( contextKeyService : IContextKeyService ) : ( IQuickPickItem | IQuickPickSeparator ) [ ] {
1109
1134
const toQuickPickItem = ( item : CustomizeLayoutItem ) : IQuickPickItem => {
1110
1135
const toggled = item . active . evaluate ( contextKeyService . getContext ( null ) ) ;
1111
- const label = item . useButtons ?
1136
+ let label = item . useButtons ?
1112
1137
item . label :
1113
1138
item . label + ( toggled && item . activeIcon ? ` $(${ item . activeIcon . id } )` : ( ! toggled && item . inactiveIcon ? ` $(${ item . inactiveIcon . id } )` : '' ) ) ;
1114
1139
const ariaLabel =
1115
1140
item . label + ( toggled && item . activeAriaLabel ? ` (${ item . activeAriaLabel } )` : ( ! toggled && item . inactiveAriaLabel ? ` (${ item . inactiveAriaLabel } )` : '' ) ) ;
1116
1141
1142
+ if ( item . visualIcon ) {
1143
+ let icon = item . visualIcon ;
1144
+ if ( isContextualLayoutVisualIcon ( icon ) ) {
1145
+ const useIconA = icon . whenA . evaluate ( contextKeyService . getContext ( null ) ) ;
1146
+ icon = useIconA ? icon . iconA : icon . iconB ;
1147
+ }
1148
+
1149
+ label = `$(${ icon . id } ) ${ label } ` ;
1150
+ }
1151
+
1117
1152
return {
1118
1153
type : 'item' ,
1119
1154
id : item . id ,
@@ -1131,22 +1166,22 @@ registerAction2(class CustomizeLayoutAction extends Action2 {
1131
1166
return [
1132
1167
{
1133
1168
type : 'separator' ,
1134
- label : localize ( 'toggleVisibility' , "Toggle Visibility" )
1169
+ label : localize ( 'toggleVisibility' , "Visibility" )
1135
1170
} ,
1136
1171
...ToggleVisibilityActions . map ( toQuickPickItem ) ,
1137
1172
{
1138
1173
type : 'separator' ,
1139
- label : localize ( 'moveSideBar ' , "Move Side Bar" )
1174
+ label : localize ( 'sideBarPosition ' , "Side Bar Position " )
1140
1175
} ,
1141
1176
...MoveSideBarActions . map ( toQuickPickItem ) ,
1142
1177
{
1143
1178
type : 'separator' ,
1144
- label : localize ( 'alignPanel ' , "Align Panel" )
1179
+ label : localize ( 'panelAlignment ' , "Panel Alignment " )
1145
1180
} ,
1146
1181
...AlignPanelActions . map ( toQuickPickItem ) ,
1147
1182
{
1148
1183
type : 'separator' ,
1149
- label : localize ( 'layoutModes' , "Layout Modes" ) ,
1184
+ label : localize ( 'layoutModes' , "Modes" ) ,
1150
1185
} ,
1151
1186
...MiscLayoutOptions . map ( toQuickPickItem ) ,
1152
1187
] ;
@@ -1160,7 +1195,7 @@ registerAction2(class CustomizeLayoutAction extends Action2 {
1160
1195
quickPick . items = this . getItems ( contextKeyService ) ;
1161
1196
quickPick . ignoreFocusOut = true ;
1162
1197
quickPick . hideInput = true ;
1163
- quickPick . title = localize ( 'layoutOptionsQuickPickTitle ' , "Layout Options " ) ;
1198
+ quickPick . title = localize ( 'customizeLayoutQuickPickTitle ' , "Customize Layout " ) ;
1164
1199
1165
1200
quickPick . buttons = [
1166
1201
{
0 commit comments