Skip to content

Commit

Permalink
Fixes #21784: Add editor.minimap.showSlider to control the minimap'…
Browse files Browse the repository at this point in the history
…s slider visibility
  • Loading branch information
alexdima committed Jun 7, 2017
1 parent 8535146 commit 6f0d0c6
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/vs/editor/browser/viewParts/minimap/minimap.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

.monaco-editor .minimap-slider {
/* START cover the case that slider is visible on mouseover */
.monaco-editor .minimap.slider-mouseover .minimap-slider {
opacity: 0;
transition: opacity 100ms linear;
}
.monaco-editor .minimap:hover .minimap-slider {
.monaco-editor .minimap.slider-mouseover:hover .minimap-slider {
opacity: 1;
}
.monaco-editor .minimap-slider.active {
.monaco-editor .minimap.slider-mouseover .minimap-slider.active {
opacity: 1;
}
/* END cover the case that slider is visible on mouseover */

.monaco-editor .minimap-shadow-hidden {
position: absolute;
width: 0;
Expand Down
15 changes: 14 additions & 1 deletion src/vs/editor/browser/viewParts/minimap/minimap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ class MinimapOptions {

public readonly renderMinimap: RenderMinimap;

public readonly showSlider: 'always' | 'mouseover';

public readonly pixelRatio: number;

public readonly lineHeight: number;
Expand Down Expand Up @@ -107,8 +109,10 @@ class MinimapOptions {
constructor(configuration: editorCommon.IConfiguration) {
const pixelRatio = configuration.editor.pixelRatio;
const layoutInfo = configuration.editor.layoutInfo;
const viewInfo = configuration.editor.viewInfo;

this.renderMinimap = layoutInfo.renderMinimap | 0;
this.showSlider = viewInfo.minimap.showSlider;
this.pixelRatio = pixelRatio;
this.lineHeight = configuration.editor.lineHeight;
this.minimapWidth = layoutInfo.minimapWidth;
Expand All @@ -123,6 +127,7 @@ class MinimapOptions {

public equals(other: MinimapOptions): boolean {
return (this.renderMinimap === other.renderMinimap
&& this.showSlider === other.showSlider
&& this.pixelRatio === other.pixelRatio
&& this.lineHeight === other.lineHeight
&& this.minimapWidth === other.minimapWidth
Expand Down Expand Up @@ -440,7 +445,7 @@ export class Minimap extends ViewPart {

this._domNode = createFastDomNode(document.createElement('div'));
PartFingerprints.write(this._domNode, PartFingerprint.Minimap);
this._domNode.setClassName('minimap');
this._domNode.setClassName(this._getMinimapDomNodeClassName());
this._domNode.setPosition('absolute');
this._domNode.setAttribute('role', 'presentation');
this._domNode.setAttribute('aria-hidden', 'true');
Expand Down Expand Up @@ -549,6 +554,13 @@ export class Minimap extends ViewPart {
super.dispose();
}

private _getMinimapDomNodeClassName(): string {
if (this._options.showSlider === 'always') {
return 'minimap slider-always';
}
return 'minimap slider-mouseover';
}

public getDomNode(): FastDomNode<HTMLElement> {
return this._domNode;
}
Expand Down Expand Up @@ -585,6 +597,7 @@ export class Minimap extends ViewPart {
this._lastRenderData = null;
this._buffers = null;
this._applyLayout();
this._domNode.setClassName(this._getMinimapDomNodeClassName());
return true;
}

Expand Down
6 changes: 6 additions & 0 deletions src/vs/editor/common/config/commonEditorConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,12 @@ const editorConfiguration: IConfigurationNode = {
'default': EDITOR_DEFAULTS.viewInfo.minimap.enabled,
'description': nls.localize('minimap.enabled', "Controls if the minimap is shown")
},
'editor.minimap.showSlider': {
'type': 'string',
'enum': ['always', 'mouseover'],
'default': EDITOR_DEFAULTS.viewInfo.minimap.showSlider,
'description': nls.localize('minimap.showSlider', "Controls whether the minimap slider is automatically hidden.")
},
'editor.minimap.renderCharacters': {
'type': 'boolean',
'default': EDITOR_DEFAULTS.viewInfo.minimap.renderCharacters,
Expand Down
10 changes: 10 additions & 0 deletions src/vs/editor/common/config/editorOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ export interface IEditorMinimapOptions {
* Defaults to false.
*/
enabled?: boolean;
/**
* Control the rendering of the minimap slider.
* Defaults to 'mouseover'.
*/
showSlider?: 'always' | 'mouseover';
/**
* Render the actual text on a line (as opposed to color blocks).
* Defaults to true.
Expand Down Expand Up @@ -691,6 +696,7 @@ export interface InternalEditorScrollbarOptions {

export interface InternalEditorMinimapOptions {
readonly enabled: boolean;
readonly showSlider: 'always' | 'mouseover';
readonly renderCharacters: boolean;
readonly maxColumn: number;
}
Expand Down Expand Up @@ -1028,6 +1034,7 @@ export class InternalEditorOptions {
private static _equalsMinimapOptions(a: InternalEditorMinimapOptions, b: InternalEditorMinimapOptions): boolean {
return (
a.enabled === b.enabled
&& a.showSlider === b.showSlider
&& a.renderCharacters === b.renderCharacters
&& a.maxColumn === b.maxColumn
);
Expand Down Expand Up @@ -1474,6 +1481,7 @@ export class EditorOptionsValidator {
}
return {
enabled: _boolean(opts.enabled, defaults.enabled),
showSlider: _stringSet<'always' | 'mouseover'>(opts.showSlider, defaults.showSlider, ['always', 'mouseover']),
renderCharacters: _boolean(opts.renderCharacters, defaults.renderCharacters),
maxColumn: _clampedInt(opts.maxColumn, defaults.maxColumn, 1, 10000),
};
Expand Down Expand Up @@ -1689,6 +1697,7 @@ export class InternalEditorOptionsFactory {
minimap: {
enabled: (accessibilityIsOn ? false : opts.viewInfo.minimap.enabled), // DISABLED WHEN SCREEN READER IS ATTACHED
renderCharacters: opts.viewInfo.minimap.renderCharacters,
showSlider: opts.viewInfo.minimap.showSlider,
maxColumn: opts.viewInfo.minimap.maxColumn
},
fixedOverflowWidgets: opts.viewInfo.fixedOverflowWidgets
Expand Down Expand Up @@ -2118,6 +2127,7 @@ export const EDITOR_DEFAULTS: IValidatedEditorOptions = {
},
minimap: {
enabled: true,
showSlider: 'mouseover',
renderCharacters: true,
maxColumn: 120
},
Expand Down
6 changes: 6 additions & 0 deletions src/vs/monaco.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2655,6 +2655,11 @@ declare module monaco.editor {
* Defaults to false.
*/
enabled?: boolean;
/**
* Control the rendering of the minimap slider.
* Defaults to 'mouseover'.
*/
showSlider?: 'always' | 'mouseover';
/**
* Render the actual text on a line (as opposed to color blocks).
* Defaults to true.
Expand Down Expand Up @@ -3177,6 +3182,7 @@ declare module monaco.editor {

export interface InternalEditorMinimapOptions {
readonly enabled: boolean;
readonly showSlider: 'always' | 'mouseover';
readonly renderCharacters: boolean;
readonly maxColumn: number;
}
Expand Down

0 comments on commit 6f0d0c6

Please sign in to comment.