提交 242ebf7d 编写于 作者: A Alex Dima

Some cleanup in view events

上级 9651adf7
......@@ -21,6 +21,7 @@ import { ViewContext } from 'vs/editor/common/view/viewContext';
import { VisibleRange } from 'vs/editor/common/view/renderingContext';
import { TextAreaWrapper } from 'vs/editor/browser/controller/input/textAreaWrapper';
import * as viewEvents from 'vs/editor/common/view/viewEvents';
import { ScrollEvent } from 'vs/base/common/scrollable';
export interface IKeyboardHandlerHelper {
viewDomNode: HTMLElement;
......@@ -53,8 +54,8 @@ export class KeyboardHandler extends ViewEventHandler implements IDisposable {
Configuration.applyFontInfoSlow(this.textArea.actual, this._context.configuration.editor.fontInfo);
this.viewHelper = viewHelper;
this.contentLeft = 0;
this.contentWidth = 0;
this.contentLeft = this._context.configuration.editor.layoutInfo.contentLeft;
this.contentWidth = this._context.configuration.editor.layoutInfo.contentWidth;
this.scrollLeft = 0;
this.textAreaHandler = new TextAreaHandler(browser, this._getStrategy(), this.textArea, this._context.model, () => this.viewHelper.flushAnyAccumulatedEvents());
......@@ -170,10 +171,14 @@ export class KeyboardHandler extends ViewEventHandler implements IDisposable {
if (e.viewInfo.experimentalScreenReader) {
this.textAreaHandler.setStrategy(this._getStrategy());
}
if (e.layoutInfo) {
this.contentLeft = this._context.configuration.editor.layoutInfo.contentLeft;
this.contentWidth = this._context.configuration.editor.layoutInfo.contentWidth;
}
return false;
}
public onScrollChanged(e: editorCommon.IScrollEvent): boolean {
public onScrollChanged(e: ScrollEvent): boolean {
this.scrollLeft = e.scrollLeft;
if (this.visibleRange) {
StyleMutator.setTop(this.textArea.actual, this.visibleRange.top);
......@@ -193,12 +198,6 @@ export class KeyboardHandler extends ViewEventHandler implements IDisposable {
return false;
}
public onLayoutChanged(layoutInfo: editorCommon.EditorLayoutInfo): boolean {
this.contentLeft = layoutInfo.contentLeft;
this.contentWidth = layoutInfo.contentWidth;
return false;
}
public writeToTextArea(): void {
if (this._lastCursorSelectionChanged) {
let e = this._lastCursorSelectionChanged;
......
......@@ -22,6 +22,7 @@ import { StandardMouseWheelEvent } from 'vs/base/browser/mouseEvent';
import { EditorZoom } from 'vs/editor/common/config/editorZoom';
import { IViewCursorRenderData } from 'vs/editor/browser/viewParts/viewCursors/viewCursor';
import * as viewEvents from 'vs/editor/common/view/viewEvents';
import { ScrollEvent } from 'vs/base/common/scrollable';
/**
* Merges mouse events when mouse move events are throttled
......@@ -205,10 +206,7 @@ export class MouseHandler extends ViewEventHandler implements IDisposable {
}
// --- begin event handlers
public onLayoutChanged(layoutInfo: editorCommon.EditorLayoutInfo): boolean {
return false;
}
public onScrollChanged(e: editorCommon.IScrollEvent): boolean {
public onScrollChanged(e: ScrollEvent): boolean {
this._mouseDownOperation.onScrollChanged();
return false;
}
......
......@@ -51,6 +51,7 @@ import { ViewportData } from 'vs/editor/common/viewLayout/viewLinesViewportData'
import { EditorScrollbar } from 'vs/editor/browser/viewParts/editorScrollbar/editorScrollbar';
import { Minimap } from 'vs/editor/browser/viewParts/minimap/minimap';
import * as viewEvents from 'vs/editor/common/view/viewEvents';
import { ScrollEvent } from 'vs/base/common/scrollable';
export class View extends ViewEventHandler implements editorBrowser.IView, IDisposable {
......@@ -141,6 +142,7 @@ export class View extends ViewEventHandler implements editorBrowser.IView, IDisp
this.createTextArea();
this.createViewParts();
this._setLayout();
// Keyboard handler
this.keyboardHandler = new KeyboardHandler(this._context, viewController, this.createKeyboardHandlerHelper());
......@@ -465,7 +467,8 @@ export class View extends ViewEventHandler implements editorBrowser.IView, IDisp
this.layoutProvider.onModelLinesInserted(e);
return false;
}
public onLayoutChanged(layoutInfo: editorCommon.EditorLayoutInfo): boolean {
private _setLayout(): void {
const layoutInfo = this._context.configuration.editor.layoutInfo;
if (browser.isChrome) {
/* tslint:disable:no-unused-variable */
// Access overflowGuardContainer.clientWidth to prevent relayouting bug in Chrome
......@@ -486,8 +489,6 @@ export class View extends ViewEventHandler implements editorBrowser.IView, IDisp
StyleMutator.setWidth(this.linesContentContainer, layoutInfo.contentWidth + layoutInfo.minimapWidth);
StyleMutator.setHeight(this.linesContentContainer, layoutInfo.contentHeight);
this.outgoingEvents.emitViewLayoutChanged(layoutInfo);
return false;
}
public onConfigurationChanged(e: editorCommon.IConfigurationChangedEvent): boolean {
if (e.viewInfo.editorClassName) {
......@@ -496,10 +497,13 @@ export class View extends ViewEventHandler implements editorBrowser.IView, IDisp
if (e.viewInfo.ariaLabel) {
this.textArea.setAttribute('aria-label', this._context.configuration.editor.viewInfo.ariaLabel);
}
if (e.layoutInfo) {
this._setLayout();
}
this.layoutProvider.onConfigurationChanged(e);
return false;
}
public onScrollChanged(e: editorCommon.IScrollEvent): boolean {
public onScrollChanged(e: ScrollEvent): boolean {
this.outgoingEvents.emitScrollChanged(e);
return false;
}
......@@ -749,7 +753,7 @@ export class View extends ViewEventHandler implements editorBrowser.IView, IDisp
if (zonesHaveChanged) {
this.layoutProvider.onHeightMaybeChanged();
this._context.privateViewEventBus.emit(editorCommon.EventType.ViewZonesChanged, null);
this._context.privateViewEventBus.emit(viewEvents.ViewEventNames.ZonesChanged, null);
}
});
return zonesHaveChanged;
......@@ -824,11 +828,17 @@ export class View extends ViewEventHandler implements editorBrowser.IView, IDisp
throw new Error('ViewImpl.render: View is disposed');
}
if (everything) {
// Force a render with a layout event
this.layoutProvider.emitLayoutChangedEvent();
// Force everything to render...
this.viewLines.forceShouldRender();
for (let i = 0, len = this.viewParts.length; i < len; i++) {
let viewPart = this.viewParts[i];
viewPart.forceShouldRender();
}
}
if (now) {
this._flushAccumulatedAndRenderNow();
} else {
this._scheduleRender();
}
}
......@@ -925,7 +935,7 @@ export class View extends ViewEventHandler implements editorBrowser.IView, IDisp
private _setHasFocus(newHasFocus: boolean): void {
if (this.hasFocus !== newHasFocus) {
this.hasFocus = newHasFocus;
this._context.privateViewEventBus.emit(editorCommon.EventType.ViewFocusChanged, this.hasFocus);
this._context.privateViewEventBus.emit(viewEvents.ViewEventNames.ViewFocusChanged, this.hasFocus);
}
}
}
......
......@@ -10,6 +10,7 @@ import { FastDomNode, createFastDomNode } from 'vs/base/browser/styleMutator';
import { ViewContext } from 'vs/editor/common/view/viewContext';
import { ViewportData } from 'vs/editor/common/viewLayout/viewLinesViewportData';
import * as viewEvents from 'vs/editor/common/view/viewEvents';
import { ScrollEvent } from 'vs/base/common/scrollable';
/**
* Represents a visible line
......@@ -281,11 +282,11 @@ export abstract class ViewLayer<T extends IVisibleLine> extends ViewPart {
// ---- begin view event handlers
public onLayoutChanged(layoutInfo: editorCommon.EditorLayoutInfo): boolean {
return true;
public onConfigurationChanged(e: editorCommon.IConfigurationChangedEvent): boolean {
return e.layoutInfo;
}
public onScrollChanged(e: editorCommon.IScrollEvent): boolean {
public onScrollChanged(e: ScrollEvent): boolean {
return e.scrollTopChanged;
}
......
......@@ -10,9 +10,10 @@ import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { Position } from 'vs/editor/common/core/position';
import { Range } from 'vs/editor/common/core/range';
import { IViewModel } from 'vs/editor/common/viewModel/viewModel';
import { EventType, EditorLayoutInfo, IScrollEvent, MouseTargetType } from 'vs/editor/common/editorCommon';
import { EventType, IScrollEvent, MouseTargetType } from 'vs/editor/common/editorCommon';
import { IEditorMouseEvent, IMouseTarget } from 'vs/editor/browser/editorBrowser';
import { MouseTarget } from 'vs/editor/browser/controller/mouseTarget';
import { ScrollEvent } from 'vs/base/common/scrollable';
export class ViewOutgoingEvents extends Disposable {
......@@ -33,12 +34,8 @@ export class ViewOutgoingEvents extends Disposable {
return this._actual.deferredEmit(callback);
}
public emitViewLayoutChanged(layoutInfo: EditorLayoutInfo): void {
this._actual.emit(EventType.ViewLayoutChanged, layoutInfo);
}
public emitScrollChanged(e: IScrollEvent): void {
this._actual.emit('scroll', e);
public emitScrollChanged(e: ScrollEvent): void {
this._actual.emit('scroll', <IScrollEvent>e);
}
public emitViewFocusGained(): void {
......
......@@ -5,7 +5,7 @@
'use strict';
import { FastDomNode, createFastDomNode } from 'vs/base/browser/styleMutator';
import { IScrollEvent, IConfiguration, IConfigurationChangedEvent, EditorLayoutInfo } from 'vs/editor/common/editorCommon';
import { IConfiguration, IConfigurationChangedEvent } from 'vs/editor/common/editorCommon';
import * as editorBrowser from 'vs/editor/browser/editorBrowser';
import { IVisibleLine, ViewLayer } from 'vs/editor/browser/view/viewLayer';
import { DynamicViewOverlay } from 'vs/editor/browser/view/dynamicViewOverlay';
......@@ -13,6 +13,7 @@ import { Configuration } from 'vs/editor/browser/config/configuration';
import { ViewContext } from 'vs/editor/common/view/viewContext';
import { IRenderingContext, IRestrictedRenderingContext } from 'vs/editor/common/view/renderingContext';
import { ViewportData } from 'vs/editor/common/viewLayout/viewLinesViewportData';
import { ScrollEvent } from 'vs/base/common/scrollable';
export class ViewOverlays extends ViewLayer<ViewOverlayLine> {
......@@ -192,7 +193,7 @@ export class ContentViewOverlays extends ViewOverlays {
}
return super.onConfigurationChanged(e);
}
public onScrollChanged(e: IScrollEvent): boolean {
public onScrollChanged(e: ScrollEvent): boolean {
return super.onScrollChanged(e) || e.scrollWidthChanged;
}
......@@ -211,8 +212,8 @@ export class MarginViewOverlays extends ViewOverlays {
constructor(context: ViewContext) {
super(context);
this._contentLeft = context.configuration.editor.layoutInfo.contentLeft;
this._canUseTranslate3d = context.configuration.editor.viewInfo.canUseTranslate3d;
this._contentLeft = this._context.configuration.editor.layoutInfo.contentLeft;
this._canUseTranslate3d = this._context.configuration.editor.viewInfo.canUseTranslate3d;
this.domNode.setClassName(editorBrowser.ClassNames.MARGIN_VIEW_OVERLAYS);
this.domNode.setWidth(1);
......@@ -220,30 +221,31 @@ export class MarginViewOverlays extends ViewOverlays {
Configuration.applyFontInfo(this.domNode, this._context.configuration.editor.fontInfo);
}
public onScrollChanged(e: IScrollEvent): boolean {
public onScrollChanged(e: ScrollEvent): boolean {
return super.onScrollChanged(e) || e.scrollHeightChanged;
}
public onLayoutChanged(layoutInfo: EditorLayoutInfo): boolean {
this._contentLeft = layoutInfo.contentLeft;
return super.onLayoutChanged(layoutInfo) || true;
}
public onConfigurationChanged(e: IConfigurationChangedEvent): boolean {
let shouldRender = false;
if (e.fontInfo) {
Configuration.applyFontInfo(this.domNode, this._context.configuration.editor.fontInfo);
shouldRender = true;
}
if (e.viewInfo.canUseTranslate3d) {
this._canUseTranslate3d = this._context.configuration.editor.viewInfo.canUseTranslate3d;
shouldRender = true;
}
return super.onConfigurationChanged(e);
if (e.layoutInfo) {
this._contentLeft = this._context.configuration.editor.layoutInfo.contentLeft;
shouldRender = true;
}
return super.onConfigurationChanged(e) || shouldRender;
}
_viewOverlaysRender(ctx: IRestrictedRenderingContext): void {
super._viewOverlaysRender(ctx);
let height = Math.min(ctx.scrollHeight, 1000000);
this.domNode.setHeight(height);
this.domNode.setWidth(this._contentLeft);
}
}
\ No newline at end of file
}
......@@ -35,7 +35,7 @@ export class LayoutProvider extends Disposable implements IViewLayout {
height: configuration.editor.layoutInfo.contentHeight
});
this._register(this._scrollable.onScroll((e: ScrollEvent) => {
this._privateViewEventBus.emit(editorCommon.EventType.ViewScrollChanged, e);
this._privateViewEventBus.emit(viewEvents.ViewEventNames.ViewScrollChanged, e);
}));
this._updateHeight();
......@@ -79,7 +79,6 @@ export class LayoutProvider extends Disposable implements IViewLayout {
width: this._configuration.editor.layoutInfo.contentWidth,
height: this._configuration.editor.layoutInfo.contentHeight
});
this._emitLayoutChangedEvent();
}
this._updateHeight();
}
......@@ -129,14 +128,6 @@ export class LayoutProvider extends Disposable implements IViewLayout {
);
}
private _emitLayoutChangedEvent(): void {
this._privateViewEventBus.emit(editorCommon.EventType.ViewLayoutChanged, this._configuration.editor.layoutInfo);
}
public emitLayoutChangedEvent(): void {
this._emitLayoutChangedEvent();
}
private _computeScrollWidth(maxLineWidth: number, viewportWidth: number): number {
let isViewportWrapping = this._configuration.editor.wrappingInfo.isViewportWrapping;
if (!isViewportWrapping) {
......
......@@ -14,6 +14,7 @@ import { ViewContext } from 'vs/editor/common/view/viewContext';
import { IRenderingContext, IRestrictedRenderingContext } from 'vs/editor/common/view/renderingContext';
import { Position } from 'vs/editor/common/core/position';
import * as viewEvents from 'vs/editor/common/view/viewEvents';
import { ScrollEvent } from 'vs/base/common/scrollable';
interface IWidgetData {
allowEditorOverflow: boolean;
......@@ -61,8 +62,8 @@ export class ViewContentWidgets extends ViewPart {
this._viewDomNode = viewDomNode;
this._widgets = {};
this._contentWidth = 0;
this._contentLeft = 0;
this._contentWidth = this._context.configuration.editor.layoutInfo.contentWidth;
this._contentLeft = this._context.configuration.editor.layoutInfo.contentLeft;
this._lineHeight = this._context.configuration.editor.lineHeight;
this._renderData = {};
......@@ -114,31 +115,29 @@ export class ViewContentWidgets extends ViewPart {
if (e.lineHeight) {
this._lineHeight = this._context.configuration.editor.lineHeight;
}
return true;
}
public onLayoutChanged(layoutInfo: editorCommon.EditorLayoutInfo): boolean {
this._contentLeft = layoutInfo.contentLeft;
if (this._contentWidth !== layoutInfo.contentWidth) {
this._contentWidth = layoutInfo.contentWidth;
// update the maxWidth on widgets nodes, such that `onReadAfterForcedLayout`
// below can read out the adjusted width/height of widgets
let keys = Object.keys(this._widgets);
for (let i = 0, len = keys.length; i < len; i++) {
const widgetId = keys[i];
const widgetData = this._widgets[widgetId];
const widget = widgetData.widget;
const maxWidth = widgetData.allowEditorOverflow
? window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth
: this._contentWidth;
StyleMutator.setMaxWidth(widget.getDomNode(), maxWidth);
if (e.layoutInfo) {
this._contentLeft = this._context.configuration.editor.layoutInfo.contentLeft;
if (this._contentWidth !== this._context.configuration.editor.layoutInfo.contentWidth) {
this._contentWidth = this._context.configuration.editor.layoutInfo.contentWidth;
// update the maxWidth on widgets nodes, such that `onReadAfterForcedLayout`
// below can read out the adjusted width/height of widgets
let keys = Object.keys(this._widgets);
for (let i = 0, len = keys.length; i < len; i++) {
const widgetId = keys[i];
const widgetData = this._widgets[widgetId];
const widget = widgetData.widget;
const maxWidth = widgetData.allowEditorOverflow
? window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth
: this._contentWidth;
StyleMutator.setMaxWidth(widget.getDomNode(), maxWidth);
}
}
}
return true;
}
public onScrollChanged(e: editorCommon.IScrollEvent): boolean {
public onScrollChanged(e: ScrollEvent): boolean {
return true;
}
public onZonesChanged(): boolean {
......
......@@ -11,6 +11,7 @@ import { DynamicViewOverlay } from 'vs/editor/browser/view/dynamicViewOverlay';
import { ViewContext } from 'vs/editor/common/view/viewContext';
import { IRenderingContext } from 'vs/editor/common/view/renderingContext';
import * as viewEvents from 'vs/editor/common/view/viewEvents';
import { ScrollEvent } from 'vs/base/common/scrollable';
export class CurrentLineHighlightOverlay extends DynamicViewOverlay {
private _context: ViewContext;
......@@ -93,10 +94,7 @@ export class CurrentLineHighlightOverlay extends DynamicViewOverlay {
}
return true;
}
public onLayoutChanged(layoutInfo: editorCommon.EditorLayoutInfo): boolean {
return true;
}
public onScrollChanged(e: editorCommon.IScrollEvent): boolean {
public onScrollChanged(e: ScrollEvent): boolean {
return e.scrollWidthChanged;
}
public onZonesChanged(): boolean {
......
......@@ -75,9 +75,6 @@ export class CurrentLineMarginHighlightOverlay extends DynamicViewOverlay {
}
return true;
}
public onLayoutChanged(layoutInfo: editorCommon.EditorLayoutInfo): boolean {
return true;
}
public onZonesChanged(): boolean {
return true;
}
......
......@@ -13,6 +13,7 @@ import { ViewContext } from 'vs/editor/common/view/viewContext';
import { IRenderingContext } from 'vs/editor/common/view/renderingContext';
import { ViewModelDecoration } from 'vs/editor/common/viewModel/viewModel';
import * as viewEvents from 'vs/editor/common/view/viewEvents';
import { ScrollEvent } from 'vs/base/common/scrollable';
export class DecorationsOverlay extends DynamicViewOverlay {
......@@ -67,10 +68,7 @@ export class DecorationsOverlay extends DynamicViewOverlay {
}
return true;
}
public onLayoutChanged(layoutInfo: editorCommon.EditorLayoutInfo): boolean {
return true;
}
public onScrollChanged(e: editorCommon.IScrollEvent): boolean {
public onScrollChanged(e: ScrollEvent): boolean {
return e.scrollTopChanged || e.scrollWidthChanged;
}
public onZonesChanged(): boolean {
......
......@@ -11,6 +11,7 @@ import { DynamicViewOverlay } from 'vs/editor/browser/view/dynamicViewOverlay';
import { ViewContext } from 'vs/editor/common/view/viewContext';
import { IRenderingContext } from 'vs/editor/common/view/renderingContext';
import * as viewEvents from 'vs/editor/common/view/viewEvents';
import { ScrollEvent } from 'vs/base/common/scrollable';
export class DecorationToRender {
_decorationToRenderBrand: void;
......@@ -89,8 +90,8 @@ export class GlyphMarginOverlay extends DedupOverlay {
this._context = context;
this._lineHeight = this._context.configuration.editor.lineHeight;
this._glyphMargin = this._context.configuration.editor.viewInfo.glyphMargin;
this._glyphMarginLeft = 0;
this._glyphMarginWidth = 0;
this._glyphMarginLeft = this._context.configuration.editor.layoutInfo.glyphMarginLeft;
this._glyphMarginWidth = this._context.configuration.editor.layoutInfo.glyphMarginWidth;
this._renderResult = null;
this._context.addEventHandler(this);
}
......@@ -134,14 +135,13 @@ export class GlyphMarginOverlay extends DedupOverlay {
if (e.viewInfo.glyphMargin) {
this._glyphMargin = this._context.configuration.editor.viewInfo.glyphMargin;
}
if (e.layoutInfo) {
this._glyphMarginLeft = this._context.configuration.editor.layoutInfo.glyphMarginLeft;
this._glyphMarginWidth = this._context.configuration.editor.layoutInfo.glyphMarginWidth;
}
return true;
}
public onLayoutChanged(layoutInfo: editorCommon.EditorLayoutInfo): boolean {
this._glyphMarginLeft = layoutInfo.glyphMarginLeft;
this._glyphMarginWidth = layoutInfo.glyphMarginWidth;
return true;
}
public onScrollChanged(e: editorCommon.IScrollEvent): boolean {
public onScrollChanged(e: ScrollEvent): boolean {
return e.scrollTopChanged;
}
public onZonesChanged(): boolean {
......
......@@ -11,6 +11,7 @@ import { DynamicViewOverlay } from 'vs/editor/browser/view/dynamicViewOverlay';
import { ViewContext } from 'vs/editor/common/view/viewContext';
import { IRenderingContext } from 'vs/editor/common/view/renderingContext';
import * as viewEvents from 'vs/editor/common/view/viewEvents';
import { ScrollEvent } from 'vs/base/common/scrollable';
export class IndentGuidesOverlay extends DynamicViewOverlay {
......@@ -62,10 +63,7 @@ export class IndentGuidesOverlay extends DynamicViewOverlay {
}
return true;
}
public onLayoutChanged(layoutInfo: editorCommon.EditorLayoutInfo): boolean {
return true;
}
public onScrollChanged(e: editorCommon.IScrollEvent): boolean {
public onScrollChanged(e: ScrollEvent): boolean {
return e.scrollTopChanged;// || e.scrollWidthChanged;
}
public onZonesChanged(): boolean {
......
......@@ -13,6 +13,7 @@ import { ClassNames } from 'vs/editor/browser/editorBrowser';
import { ViewContext } from 'vs/editor/common/view/viewContext';
import { IRenderingContext } from 'vs/editor/common/view/renderingContext';
import * as viewEvents from 'vs/editor/common/view/viewEvents';
import { ScrollEvent } from 'vs/base/common/scrollable';
export class LineNumbersOverlay extends DynamicViewOverlay {
......@@ -30,8 +31,8 @@ export class LineNumbersOverlay extends DynamicViewOverlay {
this._lineHeight = this._context.configuration.editor.lineHeight;
this._renderLineNumbers = this._context.configuration.editor.viewInfo.renderLineNumbers;
this._renderRelativeLineNumbers = this._context.configuration.editor.viewInfo.renderRelativeLineNumbers;
this._lineNumbersLeft = 0;
this._lineNumbersWidth = 0;
this._lineNumbersLeft = this._context.configuration.editor.layoutInfo.lineNumbersLeft;
this._lineNumbersWidth = this._context.configuration.editor.layoutInfo.lineNumbersWidth;
this._renderResult = null;
this._context.addEventHandler(this);
}
......@@ -81,14 +82,13 @@ export class LineNumbersOverlay extends DynamicViewOverlay {
if (e.viewInfo.renderRelativeLineNumbers) {
this._renderRelativeLineNumbers = this._context.configuration.editor.viewInfo.renderRelativeLineNumbers;
}
if (e.layoutInfo) {
this._lineNumbersLeft = this._context.configuration.editor.layoutInfo.lineNumbersLeft;
this._lineNumbersWidth = this._context.configuration.editor.layoutInfo.lineNumbersWidth;
}
return true;
}
public onLayoutChanged(layoutInfo: editorCommon.EditorLayoutInfo): boolean {
this._lineNumbersLeft = layoutInfo.lineNumbersLeft;
this._lineNumbersWidth = layoutInfo.lineNumbersWidth;
return true;
}
public onScrollChanged(e: editorCommon.IScrollEvent): boolean {
public onScrollChanged(e: ScrollEvent): boolean {
return e.scrollTopChanged;
}
public onZonesChanged(): boolean {
......
......@@ -20,6 +20,7 @@ import { IViewLines, VisibleRange, LineVisibleRanges } from 'vs/editor/common/vi
import { IViewLayout } from 'vs/editor/common/viewModel/viewModel';
import { PartFingerprint, PartFingerprints } from 'vs/editor/browser/view/viewPart';
import * as viewEvents from 'vs/editor/common/view/viewEvents';
import { ScrollEvent } from 'vs/base/common/scrollable';
class LastRenderedData {
......@@ -148,13 +149,11 @@ export class ViewLines extends ViewLayer<ViewLine> implements IViewLines {
}
}
return true;
}
if (e.layoutInfo) {
this._maxLineWidth = 0;
}
public onLayoutChanged(layoutInfo: editorCommon.EditorLayoutInfo): boolean {
let shouldRender = super.onLayoutChanged(layoutInfo);
this._maxLineWidth = 0;
return shouldRender;
return true;
}
public onModelFlushed(): boolean {
......@@ -198,7 +197,7 @@ export class ViewLines extends ViewLayer<ViewLine> implements IViewLines {
return true;
}
public onScrollChanged(e: editorCommon.IScrollEvent): boolean {
public onScrollChanged(e: ScrollEvent): boolean {
this.domNode.setWidth(e.scrollWidth);
return super.onScrollChanged(e) || true;
}
......
......@@ -11,6 +11,7 @@ import { DecorationToRender, DedupOverlay } from 'vs/editor/browser/viewParts/gl
import { ViewContext } from 'vs/editor/common/view/viewContext';
import { IRenderingContext } from 'vs/editor/common/view/renderingContext';
import * as viewEvents from 'vs/editor/common/view/viewEvents';
import { ScrollEvent } from 'vs/base/common/scrollable';
export class LinesDecorationsOverlay extends DedupOverlay {
......@@ -23,8 +24,8 @@ export class LinesDecorationsOverlay extends DedupOverlay {
constructor(context: ViewContext) {
super();
this._context = context;
this._decorationsLeft = 0;
this._decorationsWidth = 0;
this._decorationsLeft = this._context.configuration.editor.layoutInfo.decorationsLeft;
this._decorationsWidth = this._context.configuration.editor.layoutInfo.decorationsWidth;
this._renderResult = null;
this._context.addEventHandler(this);
}
......@@ -62,14 +63,13 @@ export class LinesDecorationsOverlay extends DedupOverlay {
return false;
}
public onConfigurationChanged(e: editorCommon.IConfigurationChangedEvent): boolean {
if (e.layoutInfo) {
this._decorationsLeft = this._context.configuration.editor.layoutInfo.decorationsLeft;
this._decorationsWidth = this._context.configuration.editor.layoutInfo.decorationsWidth;
}
return true;
}
public onLayoutChanged(layoutInfo: editorCommon.EditorLayoutInfo): boolean {
this._decorationsLeft = layoutInfo.decorationsLeft;
this._decorationsWidth = layoutInfo.decorationsWidth;
return true;
}
public onScrollChanged(e: editorCommon.IScrollEvent): boolean {
public onScrollChanged(e: ScrollEvent): boolean {
return e.scrollTopChanged;
}
public onZonesChanged(): boolean {
......
......@@ -11,6 +11,7 @@ import { ClassNames } from 'vs/editor/browser/editorBrowser';
import { ViewPart } from 'vs/editor/browser/view/viewPart';
import { ViewContext } from 'vs/editor/common/view/viewContext';
import { IRenderingContext, IRestrictedRenderingContext } from 'vs/editor/common/view/renderingContext';
import { ScrollEvent } from 'vs/base/common/scrollable';
export class Margin extends ViewPart {
public domNode: HTMLElement;
......@@ -55,19 +56,17 @@ export class Margin extends ViewPart {
this._canUseTranslate3d = this._context.configuration.editor.viewInfo.canUseTranslate3d;
}
return super.onConfigurationChanged(e);
}
if (e.layoutInfo) {
this._contentLeft = this._context.configuration.editor.layoutInfo.contentLeft;
this._glyphMarginLeft = this._context.configuration.editor.layoutInfo.glyphMarginLeft;
this._glyphMarginWidth = this._context.configuration.editor.layoutInfo.glyphMarginWidth;
}
public onScrollChanged(e: editorCommon.IScrollEvent): boolean {
return super.onScrollChanged(e) || e.scrollTopChanged;
return true;
}
public onLayoutChanged(layoutInfo: editorCommon.EditorLayoutInfo): boolean {
this._contentLeft = layoutInfo.contentLeft;
this._glyphMarginLeft = layoutInfo.glyphMarginLeft;
this._glyphMarginWidth = layoutInfo.glyphMarginWidth;
return super.onLayoutChanged(layoutInfo) || true;
public onScrollChanged(e: ScrollEvent): boolean {
return super.onScrollChanged(e) || e.scrollTopChanged;
}
// --- end event handlers
......
......@@ -11,6 +11,7 @@ import { DecorationToRender, DedupOverlay } from 'vs/editor/browser/viewParts/gl
import { ViewContext } from 'vs/editor/common/view/viewContext';
import { IRenderingContext } from 'vs/editor/common/view/renderingContext';
import * as viewEvents from 'vs/editor/common/view/viewEvents';
import { ScrollEvent } from 'vs/base/common/scrollable';
export class MarginViewLineDecorationsOverlay extends DedupOverlay {
private _context: ViewContext;
......@@ -58,10 +59,7 @@ export class MarginViewLineDecorationsOverlay extends DedupOverlay {
public onConfigurationChanged(e: editorCommon.IConfigurationChangedEvent): boolean {
return true;
}
public onLayoutChanged(layoutInfo: editorCommon.EditorLayoutInfo): boolean {
return true;
}
public onScrollChanged(e: editorCommon.IScrollEvent): boolean {
public onScrollChanged(e: ScrollEvent): boolean {
return e.scrollTopChanged;
}
public onZonesChanged(): boolean {
......
......@@ -24,6 +24,7 @@ import { RenderedLinesCollection, ILine } from 'vs/editor/browser/view/viewLayer
import { Range } from 'vs/editor/common/core/range';
import { RGBA } from 'vs/base/common/color';
import * as viewEvents from 'vs/editor/common/view/viewEvents';
import { ScrollEvent } from 'vs/base/common/scrollable';
const enum RenderMinimap {
None = 0,
......@@ -516,10 +517,7 @@ export class Minimap extends ViewPart {
public onConfigurationChanged(e: editorCommon.IConfigurationChangedEvent): boolean {
return this._onOptionsMaybeChanged();
}
public onLayoutChanged(layoutInfo: editorCommon.EditorLayoutInfo): boolean {
return this._onOptionsMaybeChanged();
}
public onScrollChanged(e: editorCommon.IScrollEvent): boolean {
public onScrollChanged(e: ScrollEvent): boolean {
return e.scrollTopChanged || e.scrollHeightChanged;
}
public onZonesChanged(): boolean {
......
......@@ -7,7 +7,7 @@
import 'vs/css!./overlayWidgets';
import { StyleMutator } from 'vs/base/browser/styleMutator';
import { EditorLayoutInfo } from 'vs/editor/common/editorCommon';
import { IConfigurationChangedEvent } from 'vs/editor/common/editorCommon';
import { ClassNames, IOverlayWidget, OverlayWidgetPositionPreference } from 'vs/editor/browser/editorBrowser';
import { ViewPart, PartFingerprint, PartFingerprints } from 'vs/editor/browser/view/viewPart';
import { ViewContext } from 'vs/editor/common/view/viewContext';
......@@ -36,10 +36,10 @@ export class ViewOverlayWidgets extends ViewPart {
super(context);
this._widgets = {};
this._verticalScrollbarWidth = 0;
this._horizontalScrollbarHeight = 0;
this._editorHeight = 0;
this._editorWidth = 0;
this._verticalScrollbarWidth = this._context.configuration.editor.layoutInfo.verticalScrollbarWidth;
this._horizontalScrollbarHeight = this._context.configuration.editor.layoutInfo.horizontalScrollbarHeight;
this._editorHeight = this._context.configuration.editor.layoutInfo.height;
this._editorWidth = this._context.configuration.editor.layoutInfo.width;
this.domNode = document.createElement('div');
PartFingerprints.write(this.domNode, PartFingerprint.OverlayWidgets);
......@@ -53,12 +53,15 @@ export class ViewOverlayWidgets extends ViewPart {
// ---- begin view event handlers
public onLayoutChanged(layoutInfo: EditorLayoutInfo): boolean {
this._verticalScrollbarWidth = layoutInfo.verticalScrollbarWidth;
this._horizontalScrollbarHeight = layoutInfo.horizontalScrollbarHeight;
this._editorHeight = layoutInfo.height;
this._editorWidth = layoutInfo.width;
return true;
public onConfigurationChanged(e: IConfigurationChangedEvent): boolean {
if (e.layoutInfo) {
this._verticalScrollbarWidth = this._context.configuration.editor.layoutInfo.verticalScrollbarWidth;
this._horizontalScrollbarHeight = this._context.configuration.editor.layoutInfo.horizontalScrollbarHeight;
this._editorHeight = this._context.configuration.editor.layoutInfo.height;
this._editorWidth = this._context.configuration.editor.layoutInfo.width;
return true;
}
return false;
}
// ---- end view event handlers
......
......@@ -14,6 +14,7 @@ import { Position } from 'vs/editor/common/core/position';
import { TokenizationRegistry } from 'vs/editor/common/modes';
import { IDisposable } from 'vs/base/common/lifecycle';
import * as viewEvents from 'vs/editor/common/view/viewEvents';
import { ScrollEvent } from 'vs/base/common/scrollable';
export class DecorationsOverviewRuler extends ViewPart {
......@@ -51,6 +52,7 @@ export class DecorationsOverviewRuler extends ViewPart {
this._overviewRuler.setLanesCount(this._context.configuration.editor.viewInfo.overviewRulerLanes, false);
let theme = this._context.configuration.editor.viewInfo.theme;
this._overviewRuler.setUseDarkColor(!themes.isLightTheme(theme), false);
this._overviewRuler.setLayout(this._context.configuration.editor.layoutInfo.overviewRuler, false);
this._updateBackground(false);
this._tokensColorTrackerListener = TokenizationRegistry.onDidChange((e) => {
......@@ -127,12 +129,12 @@ export class DecorationsOverviewRuler extends ViewPart {
shouldRender = true;
}
return shouldRender;
}
if (e.layoutInfo) {
this._overviewRuler.setLayout(this._context.configuration.editor.layoutInfo.overviewRuler, false);
shouldRender = true;
}
public onLayoutChanged(layoutInfo: editorCommon.EditorLayoutInfo): boolean {
this._overviewRuler.setLayout(layoutInfo.overviewRuler, false);
return true;
return shouldRender;
}
public onZonesChanged(): boolean {
......@@ -150,7 +152,7 @@ export class DecorationsOverviewRuler extends ViewPart {
return true;
}
public onScrollChanged(e: editorCommon.IScrollEvent): boolean {
public onScrollChanged(e: ScrollEvent): boolean {
this._overviewRuler.setScrollHeight(e.scrollHeight, false);
return super.onScrollChanged(e) || e.scrollHeightChanged;
}
......
......@@ -4,11 +4,12 @@
*--------------------------------------------------------------------------------------------*/
'use strict';
import { IConfigurationChangedEvent, OverviewRulerPosition, OverviewRulerZone, IScrollEvent } from 'vs/editor/common/editorCommon';
import { IConfigurationChangedEvent, OverviewRulerPosition, OverviewRulerZone } from 'vs/editor/common/editorCommon';
import { ViewEventHandler } from 'vs/editor/common/viewModel/viewEventHandler';
import { IOverviewRuler } from 'vs/editor/browser/editorBrowser';
import { OverviewRulerImpl } from 'vs/editor/browser/viewParts/overviewRuler/overviewRulerImpl';
import { ViewContext } from 'vs/editor/common/view/viewContext';
import { ScrollEvent } from 'vs/base/common/scrollable';
export class OverviewRuler extends ViewEventHandler implements IOverviewRuler {
......@@ -51,7 +52,7 @@ export class OverviewRuler extends ViewEventHandler implements IOverviewRuler {
return true;
}
public onScrollChanged(e: IScrollEvent): boolean {
public onScrollChanged(e: ScrollEvent): boolean {
this._overviewRuler.setScrollHeight(e.scrollHeight, true);
return super.onScrollChanged(e) || e.scrollHeightChanged;
}
......
......@@ -11,6 +11,7 @@ import * as editorCommon from 'vs/editor/common/editorCommon';
import { ViewPart } from 'vs/editor/browser/view/viewPart';
import { ViewContext } from 'vs/editor/common/view/viewContext';
import { IRenderingContext, IRestrictedRenderingContext } from 'vs/editor/common/view/renderingContext';
import { ScrollEvent } from 'vs/base/common/scrollable';
export class Rulers extends ViewPart {
......@@ -43,7 +44,7 @@ export class Rulers extends ViewPart {
}
return false;
}
public onScrollChanged(e: editorCommon.IScrollEvent): boolean {
public onScrollChanged(e: ScrollEvent): boolean {
return super.onScrollChanged(e) || e.scrollHeightChanged;
}
......
......@@ -8,11 +8,12 @@
import 'vs/css!./scrollDecoration';
import * as dom from 'vs/base/browser/dom';
import { StyleMutator } from 'vs/base/browser/styleMutator';
import { IConfigurationChangedEvent, EditorLayoutInfo, IScrollEvent } from 'vs/editor/common/editorCommon';
import { IConfigurationChangedEvent } from 'vs/editor/common/editorCommon';
import { ClassNames } from 'vs/editor/browser/editorBrowser';
import { ViewPart } from 'vs/editor/browser/view/viewPart';
import { ViewContext } from 'vs/editor/common/view/viewContext';
import { IRenderingContext, IRestrictedRenderingContext } from 'vs/editor/common/view/renderingContext';
import { ScrollEvent } from 'vs/base/common/scrollable';
export class ScrollDecorationViewPart extends ViewPart {
......@@ -26,7 +27,7 @@ export class ScrollDecorationViewPart extends ViewPart {
super(context);
this._scrollTop = 0;
this._width = 0;
this._width = this._context.configuration.editor.layoutInfo.width;
this._shouldShow = false;
this._useShadows = this._context.configuration.editor.viewInfo.scrollbar.useShadows;
this._domNode = document.createElement('div');
......@@ -48,19 +49,19 @@ export class ScrollDecorationViewPart extends ViewPart {
// --- begin event handlers
public onConfigurationChanged(e: IConfigurationChangedEvent): boolean {
let shouldRender = false;
if (e.viewInfo.scrollbar) {
this._useShadows = this._context.configuration.editor.viewInfo.scrollbar.useShadows;
}
return this._updateShouldShow();
}
public onLayoutChanged(layoutInfo: EditorLayoutInfo): boolean {
if (this._width !== layoutInfo.width) {
this._width = layoutInfo.width;
return true;
if (e.layoutInfo) {
if (this._width !== this._context.configuration.editor.layoutInfo.width) {
this._width = this._context.configuration.editor.layoutInfo.width;
shouldRender = true;
}
}
return false;
return this._updateShouldShow() || shouldRender;
}
public onScrollChanged(e: IScrollEvent): boolean {
public onScrollChanged(e: ScrollEvent): boolean {
this._scrollTop = e.scrollTop;
return this._updateShouldShow();
}
......
......@@ -13,6 +13,7 @@ import { HorizontalRange, LineVisibleRanges, IRenderingContext } from 'vs/editor
import { Range } from 'vs/editor/common/core/range';
import * as browser from 'vs/base/browser/browser';
import * as viewEvents from 'vs/editor/common/view/viewEvents';
import { ScrollEvent } from 'vs/base/common/scrollable';
const enum CornerStyle {
EXTERN,
......@@ -135,10 +136,7 @@ export class SelectionsOverlay extends DynamicViewOverlay {
}
return true;
}
public onLayoutChanged(layoutInfo: editorCommon.EditorLayoutInfo): boolean {
return true;
}
public onScrollChanged(e: editorCommon.IScrollEvent): boolean {
public onScrollChanged(e: ScrollEvent): boolean {
return e.scrollTopChanged;
}
public onZonesChanged(): boolean {
......
......@@ -16,6 +16,7 @@ import { IRenderingContext, IRestrictedRenderingContext } from 'vs/editor/common
import { FastDomNode, createFastDomNode } from 'vs/base/browser/styleMutator';
import { TimeoutTimer } from 'vs/base/common/async';
import * as viewEvents from 'vs/editor/common/view/viewEvents';
import { ScrollEvent } from 'vs/base/common/scrollable';
export class ViewCursors extends ViewPart {
......@@ -172,10 +173,7 @@ export class ViewCursors extends ViewPart {
}
return true;
}
public onLayoutChanged(layoutInfo: editorCommon.EditorLayoutInfo): boolean {
return true;
}
public onScrollChanged(e: editorCommon.IScrollEvent): boolean {
public onScrollChanged(e: ScrollEvent): boolean {
return true;
}
public onZonesChanged(): boolean {
......
......@@ -14,6 +14,7 @@ import { Position } from 'vs/editor/common/core/position';
import { IRenderingContext, IRestrictedRenderingContext } from 'vs/editor/common/view/renderingContext';
import { IViewLayout } from 'vs/editor/common/viewModel/viewModel';
import * as viewEvents from 'vs/editor/common/view/viewEvents';
import { ScrollEvent } from 'vs/base/common/scrollable';
export interface IMyViewZone {
whitespaceId: number;
......@@ -101,18 +102,14 @@ export class ViewZones extends ViewPart {
this._contentLeft = this._context.configuration.editor.layoutInfo.contentLeft;
}
return false;
return true;
}
public onLineMappingChanged(): boolean {
return this._recomputeWhitespacesProps();
}
public onLayoutChanged(layoutInfo: editorCommon.EditorLayoutInfo): boolean {
return true;
}
public onScrollChanged(e: editorCommon.IScrollEvent): boolean {
public onScrollChanged(e: ScrollEvent): boolean {
return e.scrollTopChanged || e.scrollWidthChanged;
}
......
......@@ -116,6 +116,10 @@ export abstract class CommonCodeEditor extends EventEmitter implements editorCom
this._configuration = this._createConfiguration(options);
this._lifetimeDispose.push(this._configuration.onDidChange((e) => {
this.emit(editorCommon.EventType.ConfigurationChanged, e);
if (e.layoutInfo) {
this.emit(editorCommon.EventType.EditorLayout, this._configuration.editor.layoutInfo);
}
}));
this._contextKeyService = contextKeyService.createScoped(this.domElement);
......@@ -882,10 +886,6 @@ export abstract class CommonCodeEditor extends EventEmitter implements editorCom
this.emit(editorCommon.EventType.KeyDown, e);
break;
case editorCommon.EventType.ViewLayoutChanged:
this.emit(editorCommon.EventType.EditorLayout, e);
break;
default:
// console.warn("Unhandled view event: ", e);
}
......
......@@ -4128,12 +4128,8 @@ export var EventType = {
ViewFocusGained: 'focusGained',
ViewFocusLost: 'focusLost',
ViewFocusChanged: 'focusChanged',
ViewScrollChanged: 'scrollChanged',
ViewZonesChanged: 'zonesChanged',
ViewLayoutChanged: 'viewLayoutChanged',
ContextMenu: 'contextMenu',
MouseDown: 'mousedown',
MouseUp: 'mouseup',
......
......@@ -20,7 +20,11 @@ export const ViewEventNames = {
CursorSelectionChangedEvent: 'cursorSelectionChangedEvent',
RevealRangeEvent: 'revealRangeEvent',
LineMappingChangedEvent: 'lineMappingChangedEvent',
ScrollRequestEvent: 'scrollRequestEvent'
ScrollRequestEvent: 'scrollRequestEvent',
ViewScrollChanged: 'scrollChanged',
ViewFocusChanged: 'focusChanged',
ZonesChanged: 'viewZonesChanged',
};
export interface IViewDecorationsChangedEvent {
......
......@@ -7,6 +7,7 @@
import { EmitterEvent } from 'vs/base/common/eventEmitter';
import * as editorCommon from 'vs/editor/common/editorCommon';
import * as viewEvents from 'vs/editor/common/view/viewEvents';
import { ScrollEvent } from 'vs/base/common/scrollable';
export class ViewEventHandler {
......@@ -20,6 +21,10 @@ export class ViewEventHandler {
return this._shouldRender;
}
public forceShouldRender(): void {
this._shouldRender = true;
}
protected setShouldRender(): void {
this._shouldRender = true;
}
......@@ -66,10 +71,7 @@ export class ViewEventHandler {
public onConfigurationChanged(e: editorCommon.IConfigurationChangedEvent): boolean {
return false;
}
public onLayoutChanged(layoutInfo: editorCommon.EditorLayoutInfo): boolean {
return false;
}
public onScrollChanged(e: editorCommon.IScrollEvent): boolean {
public onScrollChanged(e: ScrollEvent): boolean {
return false;
}
public onZonesChanged(): boolean {
......@@ -163,25 +165,19 @@ export class ViewEventHandler {
}
break;
case editorCommon.EventType.ViewLayoutChanged:
if (this.onLayoutChanged(<editorCommon.EditorLayoutInfo>data)) {
shouldRender = true;
}
break;
case editorCommon.EventType.ViewScrollChanged:
if (this.onScrollChanged(<editorCommon.IScrollEvent>data)) {
case viewEvents.ViewEventNames.ViewScrollChanged:
if (this.onScrollChanged(<ScrollEvent>data)) {
shouldRender = true;
}
break;
case editorCommon.EventType.ViewZonesChanged:
case viewEvents.ViewEventNames.ZonesChanged:
if (this.onZonesChanged()) {
shouldRender = true;
}
break;
case editorCommon.EventType.ViewFocusChanged:
case viewEvents.ViewEventNames.ViewFocusChanged:
if (this.onViewFocusChanged(<boolean>data)) {
shouldRender = true;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册