Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option for always visible action buttons in side panels. #41414

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/vs/base/browser/ui/splitview/panelview.css
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@

/* TODO: actions should be part of the panel, but they aren't yet */
.monaco-panel-view .panel:hover > .panel-header.expanded > .actions,
.monaco-panel-view .panel > .panel-header.actions-always-visible.expanded > .actions,
.monaco-panel-view .panel > .panel-header.focused.expanded > .actions {
display: initial;
}
Expand Down
18 changes: 16 additions & 2 deletions src/vs/workbench/browser/parts/views/panelViewlet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { ColorIdentifier, contrastBorder } from 'vs/platform/theme/common/colorR
import { attachStyler, IColorMapping, IThemable } from 'vs/platform/theme/common/styler';
import { SIDE_BAR_DRAG_AND_DROP_BACKGROUND, SIDE_BAR_SECTION_HEADER_FOREGROUND, SIDE_BAR_SECTION_HEADER_BACKGROUND } from 'vs/workbench/common/theme';
import { Dimension, Builder } from 'vs/base/browser/builder';
import { append, $, trackFocus } from 'vs/base/browser/dom';
import { append, $, trackFocus, toggleClass } from 'vs/base/browser/dom';
import { IDisposable, combinedDisposable } from 'vs/base/common/lifecycle';
import { firstIndex } from 'vs/base/common/arrays';
import { IAction, IActionRunner } from 'vs/base/common/actions';
Expand All @@ -25,6 +25,7 @@ import { IContextMenuService } from 'vs/platform/contextview/browser/contextView
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { PanelView, IPanelViewOptions, IPanelOptions, Panel } from 'vs/base/browser/ui/splitview/panelview';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';

export interface IPanelColors extends IColorMapping {
dropBackground?: ColorIdentifier;
Expand Down Expand Up @@ -54,15 +55,20 @@ export abstract class ViewletPanel extends Panel {
protected actionRunner: IActionRunner;
protected toolbar: ToolBar;

// callback for when user changed settings and we need to re-render this panel
private updateActionVisibilityPreferences: () => void = () => { };

constructor(
readonly title: string,
options: IViewletPanelOptions,
@IKeybindingService protected keybindingService: IKeybindingService,
@IContextMenuService protected contextMenuService: IContextMenuService
@IContextMenuService protected contextMenuService: IContextMenuService,
@IConfigurationService protected readonly configurationService: IConfigurationService
) {
super(options);

this.actionRunner = options.actionRunner;
this.configurationService.onDidChangeConfiguration(() => this.updateActionVisibilityPreferences());
}

render(container: HTMLElement): void {
Expand All @@ -76,6 +82,10 @@ export abstract class ViewletPanel extends Panel {
protected renderHeader(container: HTMLElement): void {
this.renderHeaderTitle(container);

// assign to the callback now when we have the panel's container HTMLelement in scope
this.updateActionVisibilityPreferences = () => toggleClass(container, 'actions-always-visible', this.shouldAlwaysShowActions());
this.updateActionVisibilityPreferences();

const actions = append(container, $('.actions'));
this.toolbar = new ToolBar(actions, this.contextMenuService, {
orientation: ActionsOrientation.HORIZONTAL,
Expand All @@ -102,6 +112,10 @@ export abstract class ViewletPanel extends Panel {
this.toolbar.context = this.getActionsContext();
}

private shouldAlwaysShowActions(): boolean {
return this.configurationService.getValue<boolean>('workbench.panel.alwaysShowActions');
}

getActions(): IAction[] {
return [];
}
Expand Down
6 changes: 4 additions & 2 deletions src/vs/workbench/browser/parts/views/treeView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { IExtensionService } from 'vs/platform/extensions/common/extensions';
import { IViewletViewOptions, IViewOptions, TreeViewsViewletPanel, FileIconThemableWorkbenchTree } from 'vs/workbench/browser/parts/views/viewsViewlet';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { WorkbenchTree, IListService } from 'vs/platform/list/browser/listService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ResourceLabel } from 'vs/workbench/browser/labels';
import URI from 'vs/base/common/uri';
import { basename } from 'vs/base/common/paths';
Expand All @@ -52,9 +53,10 @@ export class TreeView extends TreeViewsViewletPanel {
@IThemeService private themeService: IWorkbenchThemeService,
@IContextKeyService private contextKeyService: IContextKeyService,
@IExtensionService private extensionService: IExtensionService,
@ICommandService private commandService: ICommandService
@ICommandService private commandService: ICommandService,
@IConfigurationService protected readonly configurationService: IConfigurationService
) {
super({ ...(options as IViewOptions), ariaHeaderLabel: options.name }, keybindingService, contextMenuService);
super({ ...(options as IViewOptions), ariaHeaderLabel: options.name }, keybindingService, contextMenuService, configurationService);
this.menus = this.instantiationService.createInstance(Menus, this.id);
this.menus.onDidChangeTitle(() => this.updateActions(), this, this.disposables);
themeService.onThemeChange(() => this.tree.refresh() /* soft refresh */, this, this.disposables);
Expand Down
11 changes: 7 additions & 4 deletions src/vs/workbench/browser/parts/views/viewsViewlet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { IContextKeyService, IContextKeyChangeEvent } from 'vs/platform/contextk
import { StandardMouseEvent } from 'vs/base/browser/mouseEvent';
import { PanelViewlet, ViewletPanel } from 'vs/workbench/browser/parts/views/panelViewlet';
import { IPanelOptions } from 'vs/base/browser/ui/splitview/panelview';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { WorkbenchTree, IListService } from 'vs/platform/list/browser/listService';
import { IWorkbenchThemeService, IFileIconTheme } from 'vs/workbench/services/themes/common/workbenchThemeService';
import { ITreeConfiguration, ITreeOptions } from 'vs/base/parts/tree/browser/tree';
Expand All @@ -48,9 +49,10 @@ export abstract class ViewsViewletPanel extends ViewletPanel {
constructor(
options: IViewOptions,
protected keybindingService: IKeybindingService,
protected contextMenuService: IContextMenuService
protected contextMenuService: IContextMenuService,
@IConfigurationService protected readonly configurationService: IConfigurationService
) {
super(options.name, options, keybindingService, contextMenuService);
super(options.name, options, keybindingService, contextMenuService, configurationService);

this.id = options.id;
this.name = options.name;
Expand Down Expand Up @@ -112,9 +114,10 @@ export abstract class TreeViewsViewletPanel extends ViewsViewletPanel {
constructor(
options: IViewOptions,
protected keybindingService: IKeybindingService,
protected contextMenuService: IContextMenuService
protected contextMenuService: IContextMenuService,
@IConfigurationService protected readonly configurationService: IConfigurationService
) {
super(options, keybindingService, contextMenuService);
super(options, keybindingService, contextMenuService, configurationService);

this.id = options.id;
this.name = options.name;
Expand Down
5 changes: 5 additions & 0 deletions src/vs/workbench/electron-browser/main.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,11 @@ configurationRegistry.registerConfiguration({
'default': true,
'description': nls.localize('activityBarVisibility', "Controls the visibility of the activity bar in the workbench.")
},
'workbench.panel.alwaysShowActions': {
'type': 'boolean',
'default': false,
'description': nls.localize('panelActionVisibility', "Controls the visibility of side panel tree view actions. A panel's actions may either be always visible, or only visible when that panel is active.")
},
'workbench.fontAliasing': {
'type': 'string',
'enum': ['default', 'antialiased', 'none'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { ViewsViewletPanel, IViewletViewOptions } from 'vs/workbench/browser/par
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { attachInputBoxStyler } from 'vs/platform/theme/common/styler';
import { isCodeEditor } from 'vs/editor/browser/editorBrowser';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';

const $ = dom.$;

Expand All @@ -54,9 +55,10 @@ export class BreakpointsView extends ViewsViewletPanel {
@IThemeService private themeService: IThemeService,
@IEditorService private editorService: IEditorService,
@IContextViewService private contextViewService: IContextViewService,
@IContextKeyService private contextKeyService: IContextKeyService
@IContextKeyService private contextKeyService: IContextKeyService,
@IConfigurationService protected readonly configurationService: IConfigurationService
) {
super(options, keybindingService, contextMenuService);
super(options, keybindingService, contextMenuService, configurationService);

this.minimumBodySize = this.maximumBodySize = this.getExpandedBodySize();
this.settings = options.viewletSettings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { WorkbenchTree, IListService } from 'vs/platform/list/browser/listServic
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import FileResultsNavigation from 'vs/workbench/parts/files/browser/fileResultsNavigation';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';

const $ = dom.$;

Expand All @@ -51,8 +52,9 @@ export class CallStackView extends TreeViewsViewletPanel {
@IThemeService private themeService: IThemeService,
@IListService private listService: IListService,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@IConfigurationService protected readonly configurationService: IConfigurationService,
) {
super({ ...(options as IViewOptions), ariaHeaderLabel: nls.localize('callstackSection', "Call Stack Section") }, keybindingService, contextMenuService);
super({ ...(options as IViewOptions), ariaHeaderLabel: nls.localize('callstackSection', "Call Stack Section") }, keybindingService, contextMenuService, configurationService);
this.settings = options.viewletSettings;

// Create scheduler to prevent unnecessary flashing of tree when reacting to changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { ViewModel } from 'vs/workbench/parts/debug/common/debugViewModel';
import { equalsIgnoreCase } from 'vs/base/common/strings';
import { IMouseEvent } from 'vs/base/browser/mouseEvent';
import { WorkbenchTree, IListService } from 'vs/platform/list/browser/listService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';

const $ = dom.$;

Expand All @@ -48,9 +49,10 @@ export class VariablesView extends TreeViewsViewletPanel {
@IInstantiationService private instantiationService: IInstantiationService,
@IListService private listService: IListService,
@IContextKeyService private contextKeyService: IContextKeyService,
@IThemeService private themeService: IThemeService
@IThemeService private themeService: IThemeService,
@IConfigurationService protected readonly configurationService: IConfigurationService,
) {
super({ ...(options as IViewOptions), ariaHeaderLabel: nls.localize('variablesSection', "Variables Section") }, keybindingService, contextMenuService);
super({ ...(options as IViewOptions), ariaHeaderLabel: nls.localize('variablesSection', "Variables Section") }, keybindingService, contextMenuService, configurationService);

this.settings = options.viewletSettings;
this.expandedElements = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { IMouseEvent, DragMouseEvent } from 'vs/base/browser/mouseEvent';
import { DefaultDragAndDrop } from 'vs/base/parts/tree/browser/treeDefaults';
import { IVariableTemplateData, renderVariable, renderRenameBox, renderExpressionValue, BaseDebugController, twistiePixels, renderViewTree } from 'vs/workbench/parts/debug/electron-browser/baseDebugView';
import { WorkbenchTree, IListService } from 'vs/platform/list/browser/listService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';

const $ = dom.$;
const MAX_VALUE_RENDER_LENGTH_IN_VIEWLET = 1024;
Expand All @@ -49,9 +50,10 @@ export class WatchExpressionsView extends TreeViewsViewletPanel {
@IContextKeyService private contextKeyService: IContextKeyService,
@IListService private listService: IListService,
@IInstantiationService private instantiationService: IInstantiationService,
@IThemeService private themeService: IThemeService
@IThemeService private themeService: IThemeService,
@IConfigurationService protected readonly configurationService: IConfigurationService,
) {
super({ ...(options as IViewOptions), ariaHeaderLabel: nls.localize('expressionsSection', "Expressions Section") }, keybindingService, contextMenuService);
super({ ...(options as IViewOptions), ariaHeaderLabel: nls.localize('expressionsSection', "Expressions Section") }, keybindingService, contextMenuService, configurationService);
this.settings = options.viewletSettings;

this.onWatchExpressionsUpdatedScheduler = new RunOnceScheduler(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
import { InstallWorkspaceRecommendedExtensionsAction, ConfigureWorkspaceFolderRecommendedExtensionsAction } from 'vs/workbench/parts/extensions/browser/extensionsActions';
import { WorkbenchPagedList, IListService } from 'vs/platform/list/browser/listService';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';

export class ExtensionsListView extends ViewsViewletPanel {

Expand All @@ -61,9 +62,10 @@ export class ExtensionsListView extends ViewsViewletPanel {
@IExtensionTipsService private tipsService: IExtensionTipsService,
@IModeService private modeService: IModeService,
@ITelemetryService private telemetryService: ITelemetryService,
@IContextKeyService private contextKeyService: IContextKeyService
@IContextKeyService private contextKeyService: IContextKeyService,
@IConfigurationService protected readonly configurationService: IConfigurationService,
) {
super({ ...(options as IViewOptions), ariaHeaderLabel: options.name }, keybindingService, contextMenuService);
super({ ...(options as IViewOptions), ariaHeaderLabel: options.name }, keybindingService, contextMenuService, configurationService);
}

renderHeader(container: HTMLElement): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { IThemeService } from 'vs/platform/theme/common/themeService';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';

export class EmptyView extends ViewsViewletPanel {

Expand All @@ -37,9 +38,10 @@ export class EmptyView extends ViewsViewletPanel {
@IInstantiationService private instantiationService: IInstantiationService,
@IKeybindingService keybindingService: IKeybindingService,
@IContextMenuService contextMenuService: IContextMenuService,
@IWorkspaceContextService private contextService: IWorkspaceContextService
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@IConfigurationService protected configurationService: IConfigurationService
) {
super({ ...(options as IViewOptions), ariaHeaderLabel: nls.localize('explorerSection', "Files Explorer Section") }, keybindingService, contextMenuService);
super({ ...(options as IViewOptions), ariaHeaderLabel: nls.localize('explorerSection', "Files Explorer Section") }, keybindingService, contextMenuService, configurationService);
this.contextService.onDidChangeWorkbenchState(() => this.setLabels());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ export class ExplorerView extends TreeViewsViewletPanel implements IExplorerView
@IPartService private partService: IPartService,
@IKeybindingService keybindingService: IKeybindingService,
@IContextKeyService private contextKeyService: IContextKeyService,
@IConfigurationService private configurationService: IConfigurationService,
@IConfigurationService protected configurationService: IConfigurationService,
@IWorkbenchThemeService private themeService: IWorkbenchThemeService,
@IDecorationsService decorationService: IDecorationsService
) {
super({ ...(options as IViewOptions), ariaHeaderLabel: nls.localize('explorerSection', "Files Explorer Section") }, keybindingService, contextMenuService);
super({ ...(options as IViewOptions), ariaHeaderLabel: nls.localize('explorerSection', "Files Explorer Section") }, keybindingService, contextMenuService, configurationService);

this.settings = options.viewletSettings;
this.viewletState = options.viewletState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class OpenEditorsView extends ViewsViewletPanel {
@ITextFileService private textFileService: ITextFileService,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@IEditorGroupService private editorGroupService: IEditorGroupService,
@IConfigurationService private configurationService: IConfigurationService,
@IConfigurationService protected configurationService: IConfigurationService,
@IKeybindingService keybindingService: IKeybindingService,
@IListService private listService: IListService,
@IUntitledEditorService private untitledEditorService: IUntitledEditorService,
Expand All @@ -84,7 +84,7 @@ export class OpenEditorsView extends ViewsViewletPanel {
super({
...(options as IViewOptions),
ariaHeaderLabel: nls.localize({ key: 'openEditosrSection', comment: ['Open is an adjective'] }, "Open Editors Section"),
}, keybindingService, contextMenuService);
}, keybindingService, contextMenuService, configurationService);

this.model = editorGroupService.getStacksModel();

Expand Down
7 changes: 4 additions & 3 deletions src/vs/workbench/parts/scm/electron-browser/scmViewlet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,10 @@ class MainPanel extends ViewletPanel {
@IThemeService private themeService: IThemeService,
@IContextKeyService private contextKeyService: IContextKeyService,
@IListService private listService: IListService,
@IMenuService private menuService: IMenuService
@IMenuService private menuService: IMenuService,
@IConfigurationService protected readonly configurationService: IConfigurationService
) {
super(localize('scm providers', "Source Control Providers"), {}, keybindingService, contextMenuService);
super(localize('scm providers', "Source Control Providers"), {}, keybindingService, contextMenuService, configurationService);
this.updateBodySize();
}

Expand Down Expand Up @@ -699,7 +700,7 @@ export class RepositoryPanel extends ViewletPanel {
@IInstantiationService protected instantiationService: IInstantiationService,
@IConfigurationService protected configurationService: IConfigurationService
) {
super(repository.provider.label, {}, keybindingService, contextMenuService);
super(repository.provider.label, {}, keybindingService, contextMenuService, configurationService);
this.menus = instantiationService.createInstance(SCMMenus, repository.provider);
}

Expand Down