diff --git a/src/vs/base/browser/contextmenu.ts b/src/vs/base/browser/contextmenu.ts index 54dc4d766cab34413c04710a757639aa862cb9e8..4e0bb4b263b89cdb66c4057d2c7d8db6d95d017a 100644 --- a/src/vs/base/browser/contextmenu.ts +++ b/src/vs/base/browser/contextmenu.ts @@ -25,6 +25,7 @@ export class ContextSubMenu extends SubmenuAction { export interface IContextMenuDelegate { getAnchor(): HTMLElement | { x: number; y: number; width?: number; height?: number; }; getActions(): ReadonlyArray; + getCheckedActionsRepresentation?(action: IAction): 'radio' | 'checkbox'; getActionViewItem?(action: IAction): IActionViewItem | undefined; getActionsContext?(event?: IContextMenuEvent): any; getKeyBinding?(action: IAction): ResolvedKeybinding | undefined; diff --git a/src/vs/base/browser/ui/actionbar/actionbar.ts b/src/vs/base/browser/ui/actionbar/actionbar.ts index 27925b09b9c176b1f59db27472d040091d15bb45..c8dc421e6d47ebc8c0f62a6d5a12648e76097e57 100644 --- a/src/vs/base/browser/ui/actionbar/actionbar.ts +++ b/src/vs/base/browser/ui/actionbar/actionbar.ts @@ -224,7 +224,6 @@ export class Separator extends Action { constructor(label?: string) { super(Separator.ID, label, label ? 'separator text' : 'separator'); this.checked = false; - this.radio = false; this.enabled = false; } } diff --git a/src/vs/base/common/actions.ts b/src/vs/base/common/actions.ts index e6e769ea897952dc72c8526073eeedc763231228..135008aa81d174b86fee7ce6699eb6386ef85bcb 100644 --- a/src/vs/base/common/actions.ts +++ b/src/vs/base/common/actions.ts @@ -29,7 +29,6 @@ export interface IAction extends IDisposable { class: string | undefined; enabled: boolean; checked: boolean; - radio: boolean; run(event?: any): Promise; } @@ -54,7 +53,6 @@ export interface IActionChangeEvent { readonly class?: string; readonly enabled?: boolean; readonly checked?: boolean; - readonly radio?: boolean; } export class Action extends Disposable implements IAction { @@ -68,7 +66,6 @@ export class Action extends Disposable implements IAction { protected _cssClass: string | undefined; protected _enabled: boolean = true; protected _checked: boolean = false; - protected _radio: boolean = false; protected readonly _actionCallback?: (event?: any) => Promise; constructor(id: string, label: string = '', cssClass: string = '', enabled: boolean = true, actionCallback?: (event?: any) => Promise) { @@ -152,14 +149,6 @@ export class Action extends Disposable implements IAction { this._setChecked(value); } - get radio(): boolean { - return this._radio; - } - - set radio(value: boolean) { - this._setRadio(value); - } - protected _setChecked(value: boolean): void { if (this._checked !== value) { this._checked = value; @@ -167,13 +156,6 @@ export class Action extends Disposable implements IAction { } } - protected _setRadio(value: boolean): void { - if (this._radio !== value) { - this._radio = value; - this._onDidChange.fire({ radio: value }); - } - } - run(event?: any, _data?: ITelemetryData): Promise { if (this._actionCallback) { return this._actionCallback(event); diff --git a/src/vs/workbench/browser/parts/compositeBar.ts b/src/vs/workbench/browser/parts/compositeBar.ts index 33495bbc8debbea12203e5cf55d8be2b61bf5c05..a0681d0c7f1ae4f18e0d51fe02c53d3e49148365 100644 --- a/src/vs/workbench/browser/parts/compositeBar.ts +++ b/src/vs/workbench/browser/parts/compositeBar.ts @@ -30,11 +30,12 @@ export interface ICompositeBarItem { } export interface ICompositeBarOptions { - icon: boolean; - orientation: ActionsOrientation; - colors: (theme: ITheme) => ICompositeBarColors; - compositeSize: number; - overflowActionSize: number; + readonly icon: boolean; + readonly orientation: ActionsOrientation; + readonly colors: (theme: ITheme) => ICompositeBarColors; + readonly compositeSize: number; + readonly overflowActionSize: number; + getActivityAction: (compositeId: string) => ActivityAction; getCompositePinnedAction: (compositeId: string) => Action; getOnCompositeClickAction: (compositeId: string) => Action; diff --git a/src/vs/workbench/browser/parts/compositeBarActions.ts b/src/vs/workbench/browser/parts/compositeBarActions.ts index e910ee428ea91c68116c4d449119cfb8d2cd592b..5ad81ef1e244eb62d859a557963b7d50059f5653 100644 --- a/src/vs/workbench/browser/parts/compositeBarActions.ts +++ b/src/vs/workbench/browser/parts/compositeBarActions.ts @@ -383,6 +383,7 @@ export class CompositeOverflowActivityActionViewItem extends ActivityActionViewI this.contextMenuService.showContextMenu({ getAnchor: () => this.container, getActions: () => this.actions, + getCheckedActionsRepresentation: () => 'radio', onHide: () => dispose(this.actions) }); } @@ -390,7 +391,7 @@ export class CompositeOverflowActivityActionViewItem extends ActivityActionViewI private getActions(): Action[] { return this.getOverflowingComposites().map(composite => { const action = this.getCompositeOpenAction(composite.id); - action.radio = this.getActiveCompositeId() === action.id; + action.checked = this.getActiveCompositeId() === action.id; const badge = this.getBadge(composite.id); let suffix: string | number | undefined; @@ -614,8 +615,8 @@ export class CompositeActionViewItem extends ActivityActionViewItem { this.contextMenuService.showContextMenu({ getAnchor: () => anchor, - getActionsContext: () => this.activity.id, - getActions: () => actions + getActions: () => actions, + getActionsContext: () => this.activity.id }); } diff --git a/src/vs/workbench/services/contextmenu/electron-browser/contextmenuService.ts b/src/vs/workbench/services/contextmenu/electron-browser/contextmenuService.ts index 410b7e8ed509ec4af4c8d537d69c13d010f11f16..cea0688e45f495d7415c65637e247a8b82b550bf 100644 --- a/src/vs/workbench/services/contextmenu/electron-browser/contextmenuService.ts +++ b/src/vs/workbench/services/contextmenu/electron-browser/contextmenuService.ts @@ -138,10 +138,19 @@ class NativeContextMenuService extends Disposable implements IContextMenuService // Normal Menu Item else { + let type: 'radio' | 'checkbox' | undefined = undefined; + if (!!entry.checked) { + if (typeof delegate.getCheckedActionsRepresentation === 'function') { + type = delegate.getCheckedActionsRepresentation(entry); + } else { + type = 'checkbox'; + } + } + const item: IContextMenuItem = { label: unmnemonicLabel(entry.label), - checked: !!entry.checked || !!entry.radio, - type: !!entry.checked ? 'checkbox' : !!entry.radio ? 'radio' : undefined, + checked: !!entry.checked, + type, enabled: !!entry.enabled, click: event => { @@ -188,4 +197,4 @@ class NativeContextMenuService extends Disposable implements IContextMenuService } } -registerSingleton(IContextMenuService, ContextMenuService, true); \ No newline at end of file +registerSingleton(IContextMenuService, ContextMenuService, true);