@@ -10,13 +10,12 @@ import { ActionsOrientation } from 'vs/base/browser/ui/actionbar/actionbar';
10
10
import { Part } from 'vs/workbench/browser/part' ;
11
11
import { ActivityBarPosition , IWorkbenchLayoutService , LayoutSettings , Parts , Position } from 'vs/workbench/services/layout/browser/layoutService' ;
12
12
import { IInstantiationService , ServicesAccessor } from 'vs/platform/instantiation/common/instantiation' ;
13
- import { DisposableStore } from 'vs/base/common/lifecycle' ;
13
+ import { DisposableStore , MutableDisposable } from 'vs/base/common/lifecycle' ;
14
14
import { ToggleSidebarPositionAction } from 'vs/workbench/browser/actions/layoutActions' ;
15
15
import { IThemeService , IColorTheme , registerThemingParticipant } from 'vs/platform/theme/common/themeService' ;
16
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 'vs/workbench/common/theme' ;
17
17
import { activeContrastBorder , contrastBorder , focusBorder } from 'vs/platform/theme/common/colorRegistry' ;
18
- import { addDisposableListener , append , EventType , isAncestor , $ } from 'vs/base/browser/dom' ;
19
- import { ICompositeBarColors , IActivityHoverOptions } from 'vs/workbench/browser/parts/compositeBarActions' ;
18
+ import { addDisposableListener , append , EventType , isAncestor , $ , clearNode } from 'vs/base/browser/dom' ;
20
19
import { assertIsDefined } from 'vs/base/common/types' ;
21
20
import { CustomMenubarControl } from 'vs/workbench/browser/parts/titlebar/menubarControl' ;
22
21
import { IConfigurationService } from 'vs/platform/configuration/common/configuration' ;
@@ -57,7 +56,8 @@ export class ActivitybarPart extends Part {
57
56
58
57
//#endregion
59
58
60
- private readonly compositeBar : PaneCompositeBar ;
59
+ private readonly compositeBar = this . _register ( new MutableDisposable < PaneCompositeBar > ( ) ) ;
60
+ private content : HTMLElement | undefined ;
61
61
62
62
constructor (
63
63
private readonly paneCompositePart : IPaneCompositePart ,
@@ -67,51 +67,59 @@ export class ActivitybarPart extends Part {
67
67
@IStorageService storageService : IStorageService ,
68
68
) {
69
69
super ( Parts . ACTIVITYBAR_PART , { hasTitle : false } , themeService , storageService , layoutService ) ;
70
- this . compositeBar = this . createCompositeBar ( ) ;
71
70
}
72
71
73
72
private createCompositeBar ( ) : PaneCompositeBar {
74
- return this . _register ( this . instantiationService . createInstance ( ActivityBarCompositeBar , {
73
+ return this . instantiationService . createInstance ( ActivityBarCompositeBar , {
75
74
partContainerClass : 'activitybar' ,
76
75
pinnedViewContainersKey : ActivitybarPart . pinnedViewContainersKey ,
77
76
placeholderViewContainersKey : ActivitybarPart . placeholderViewContainersKey ,
78
77
viewContainersWorkspaceStateKey : ActivitybarPart . viewContainersWorkspaceStateKey ,
79
78
orientation : ActionsOrientation . VERTICAL ,
80
79
icon : true ,
81
80
iconSize : 24 ,
82
- activityHoverOptions : this . getActivityHoverOptions ( ) ,
81
+ activityHoverOptions : {
82
+ position : ( ) => this . layoutService . getSideBarPosition ( ) === Position . LEFT ? HoverPosition . RIGHT : HoverPosition . LEFT ,
83
+ } ,
83
84
preventLoopNavigation : true ,
84
85
recomputeSizes : false ,
85
86
fillExtraContextMenuActions : ( actions , e ?: MouseEvent | GestureEvent ) => { } ,
86
87
compositeSize : 52 ,
87
- colors : ( theme : IColorTheme ) => this . getActivitybarItemColors ( theme ) ,
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
+ } ) ,
88
98
overflowActionSize : ActivitybarPart . ACTION_HEIGHT ,
89
- } , Parts . ACTIVITYBAR_PART , this . paneCompositePart , true ) ) ;
90
- }
91
-
92
- private getActivityHoverOptions ( ) : IActivityHoverOptions {
93
- return {
94
- position : ( ) => this . layoutService . getSideBarPosition ( ) === Position . LEFT ? HoverPosition . RIGHT : HoverPosition . LEFT ,
95
- } ;
99
+ } , Parts . ACTIVITYBAR_PART , this . paneCompositePart , true ) ;
96
100
}
97
101
98
102
protected override createContentArea ( parent : HTMLElement ) : HTMLElement {
99
103
this . element = parent ;
100
- const content = append ( this . element , $ ( '.content' ) ) ;
101
- this . compositeBar . create ( content ) ;
102
- return content ;
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 ;
103
111
}
104
112
105
113
getPinnedPaneCompositeIds ( ) : string [ ] {
106
- return this . compositeBar . getPinnedPaneCompositeIds ( ) ;
114
+ return this . compositeBar . value ?. getPinnedPaneCompositeIds ( ) ?? [ ] ;
107
115
}
108
116
109
117
getVisiblePaneCompositeIds ( ) : string [ ] {
110
- return this . compositeBar . getVisiblePaneCompositeIds ( ) ;
118
+ return this . compositeBar . value ?. getVisiblePaneCompositeIds ( ) ?? [ ] ;
111
119
}
112
120
113
121
focus ( ) : void {
114
- this . compositeBar . focus ( ) ;
122
+ this . compositeBar . value ?. focus ( ) ;
115
123
}
116
124
117
125
override updateStyles ( ) : void {
@@ -126,29 +134,47 @@ export class ActivitybarPart extends Part {
126
134
container . style . borderColor = borderColor ? borderColor : '' ;
127
135
}
128
136
129
- private getActivitybarItemColors ( theme : IColorTheme ) : ICompositeBarColors {
130
- return {
131
- activeForegroundColor : theme . getColor ( ACTIVITY_BAR_FOREGROUND ) ,
132
- inactiveForegroundColor : theme . getColor ( ACTIVITY_BAR_INACTIVE_FOREGROUND ) ,
133
- activeBorderColor : theme . getColor ( ACTIVITY_BAR_ACTIVE_BORDER ) ,
134
- activeBackground : theme . getColor ( ACTIVITY_BAR_ACTIVE_BACKGROUND ) ,
135
- badgeBackground : theme . getColor ( ACTIVITY_BAR_BADGE_BACKGROUND ) ,
136
- badgeForeground : theme . getColor ( ACTIVITY_BAR_BADGE_FOREGROUND ) ,
137
- dragAndDropBorder : theme . getColor ( ACTIVITY_BAR_DRAG_AND_DROP_BORDER ) ,
138
- activeBackgroundColor : undefined , inactiveBackgroundColor : undefined , activeBorderBottomColor : undefined ,
139
- } ;
137
+ show ( ) : void {
138
+ if ( ! this . content ) {
139
+ return ;
140
+ }
141
+
142
+ if ( this . compositeBar . value ) {
143
+ return ;
144
+ }
145
+
146
+ this . compositeBar . value = this . createCompositeBar ( ) ;
147
+ this . compositeBar . value . create ( this . content ) ;
148
+
149
+ if ( this . dimension ) {
150
+ this . layout ( this . dimension . width , this . dimension . height ) ;
151
+ }
152
+ }
153
+
154
+ hide ( ) : void {
155
+ if ( ! this . compositeBar . value ) {
156
+ return ;
157
+ }
158
+
159
+ this . compositeBar . clear ( ) ;
160
+
161
+ if ( this . content ) {
162
+ clearNode ( this . content ) ;
163
+ }
140
164
}
141
165
142
166
override layout ( width : number , height : number ) : void {
143
- if ( ! this . layoutService . isVisible ( Parts . ACTIVITYBAR_PART ) ) {
167
+ super . layout ( width , height , 0 , 0 ) ;
168
+
169
+ if ( ! this . compositeBar . value ) {
144
170
return ;
145
171
}
146
172
147
173
// Layout contents
148
174
const contentAreaSize = super . layoutContents ( width , height ) . contentSize ;
149
175
150
176
// Layout composite bar
151
- this . compositeBar . layout ( width , contentAreaSize . height ) ;
177
+ this . compositeBar . value . layout ( width , contentAreaSize . height ) ;
152
178
}
153
179
154
180
toJSON ( ) : object {
0 commit comments