mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-11 17:18:13 +01:00
💄 sash enabled property
This commit is contained in:
@@ -52,16 +52,39 @@ export class Sash {
|
||||
|
||||
private el: HTMLElement;
|
||||
private layoutProvider: ISashLayoutProvider;
|
||||
private isDisabled: boolean;
|
||||
private hidden: boolean;
|
||||
private orientation: Orientation;
|
||||
private size: number;
|
||||
private disposables: IDisposable[] = [];
|
||||
|
||||
private _onDidStart = new Emitter<ISashEvent>();
|
||||
private _onDidChange = new Emitter<ISashEvent>();
|
||||
private _onDidReset = new Emitter<void>();
|
||||
private _onDidEnd = new Emitter<void>();
|
||||
private _enabled = true;
|
||||
get enabled(): boolean { return this._enabled; }
|
||||
set enabled(enabled: boolean) {
|
||||
this._enabled = enabled;
|
||||
|
||||
if (enabled) {
|
||||
removeClass(this.el, 'disabled');
|
||||
} else {
|
||||
addClass(this.el, 'disabled');
|
||||
}
|
||||
|
||||
this._onDidEnablementChange.fire(enabled);
|
||||
}
|
||||
|
||||
private readonly _onDidEnablementChange = new Emitter<boolean>();
|
||||
readonly onDidEnablementChange: Event<boolean> = this._onDidEnablementChange.event;
|
||||
|
||||
private readonly _onDidStart = new Emitter<ISashEvent>();
|
||||
readonly onDidStart: Event<ISashEvent> = this._onDidStart.event;
|
||||
|
||||
private readonly _onDidChange = new Emitter<ISashEvent>();
|
||||
readonly onDidChange: Event<ISashEvent> = this._onDidChange.event;
|
||||
|
||||
private readonly _onDidReset = new Emitter<void>();
|
||||
readonly onDidReset: Event<void> = this._onDidReset.event;
|
||||
|
||||
private readonly _onDidEnd = new Emitter<void>();
|
||||
readonly onDidEnd: Event<void> = this._onDidEnd.event;
|
||||
|
||||
constructor(container: HTMLElement, layoutProvider: ISashLayoutProvider, options: ISashOptions = {}) {
|
||||
this.el = append(container, $('.monaco-sash'));
|
||||
@@ -85,27 +108,10 @@ export class Sash {
|
||||
|
||||
this.setOrientation(options.orientation || Orientation.VERTICAL);
|
||||
|
||||
this.isDisabled = false;
|
||||
this.hidden = false;
|
||||
this.layoutProvider = layoutProvider;
|
||||
}
|
||||
|
||||
get onDidStart(): Event<ISashEvent> {
|
||||
return this._onDidStart.event;
|
||||
}
|
||||
|
||||
get onDidChange(): Event<ISashEvent> {
|
||||
return this._onDidChange.event;
|
||||
}
|
||||
|
||||
get onDidReset(): Event<void> {
|
||||
return this._onDidReset.event;
|
||||
}
|
||||
|
||||
get onDidEnd(): Event<void> {
|
||||
return this._onDidEnd.event;
|
||||
}
|
||||
|
||||
setOrientation(orientation: Orientation): void {
|
||||
this.orientation = orientation;
|
||||
|
||||
@@ -127,7 +133,7 @@ export class Sash {
|
||||
private onMouseDown(e: MouseEvent): void {
|
||||
EventHelper.stop(e, false);
|
||||
|
||||
if (this.isDisabled) {
|
||||
if (!this.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -279,20 +285,6 @@ export class Sash {
|
||||
return this.hidden;
|
||||
}
|
||||
|
||||
enable(): void {
|
||||
removeClass(this.el, 'disabled');
|
||||
this.isDisabled = false;
|
||||
}
|
||||
|
||||
disable(): void {
|
||||
addClass(this.el, 'disabled');
|
||||
this.isDisabled = true;
|
||||
}
|
||||
|
||||
get enabled(): boolean {
|
||||
return !this.isDisabled;
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
if (this.el && this.el.parentElement) {
|
||||
this.el.parentElement.removeChild(this.el);
|
||||
|
||||
@@ -461,11 +461,7 @@ export class SplitView implements IDisposable {
|
||||
const expandsUp = reverseViews.map(i => previous = (i.view.maximumSize - i.size > 0) || previous).reverse();
|
||||
|
||||
this.sashItems.forEach((s, i) => {
|
||||
if ((collapsesDown[i] && expandsUp[i + 1]) || (expandsDown[i] && collapsesUp[i + 1])) {
|
||||
s.sash.enable();
|
||||
} else {
|
||||
s.sash.disable();
|
||||
}
|
||||
s.sash.enabled = (collapsesDown[i] && expandsUp[i + 1]) || (expandsDown[i] && collapsesUp[i + 1]);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1520,7 +1520,7 @@ class DiffEdtorWidgetSideBySide extends DiffEditorWidgetStyle implements IDiffEd
|
||||
this._sash = this._register(new Sash(this._dataSource.getContainerDomNode(), this));
|
||||
|
||||
if (this._disableSash) {
|
||||
this._sash.disable();
|
||||
this._sash.enabled = false;
|
||||
}
|
||||
|
||||
this._sash.onDidStart(() => this.onSashDragStart());
|
||||
@@ -1539,9 +1539,9 @@ class DiffEdtorWidgetSideBySide extends DiffEditorWidgetStyle implements IDiffEd
|
||||
this._disableSash = newDisableSash;
|
||||
|
||||
if (this._disableSash) {
|
||||
this._sash.disable();
|
||||
this._sash.enabled = false;
|
||||
} else {
|
||||
this._sash.enable();
|
||||
this._sash.enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -459,7 +459,7 @@ export abstract class ZoneWidget implements IHorizontalSashLayoutProvider {
|
||||
|
||||
if (!this.options.isResizeable) {
|
||||
this._resizeSash.hide();
|
||||
this._resizeSash.disable();
|
||||
this._resizeSash.enabled = false;
|
||||
}
|
||||
|
||||
let data: { startY: number; heightInLines: number; };
|
||||
|
||||
Reference in New Issue
Block a user