/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/
'use strict';

import { ViewModelDecoration } from 'vs/editor/common/viewModel/viewModel';
import { ViewLinesViewportData } from 'vs/editor/common/viewLayout/viewLinesViewportData';
import { Range } from 'vs/editor/common/core/range';
import { Position } from 'vs/editor/common/core/position';

export interface IRestrictedRenderingContext {
	linesViewportData: ViewLinesViewportData;

	scrollWidth: number;
	scrollHeight: number;

	visibleRange: Range;
	bigNumbersDelta: number;

	viewportTop: number;
	viewportWidth: number;
	viewportHeight: number;
	viewportLeft: number;

	getScrolledTopFromAbsoluteTop(absoluteTop: number): number;
	getViewportVerticalOffsetForLineNumber(lineNumber: number): number;
	lineIsVisible(lineNumber: number): boolean;

	getDecorationsInViewport(): ViewModelDecoration[];
}

export interface IRenderingContext extends IRestrictedRenderingContext {

	linesVisibleRangesForRange(range: Range, includeNewLines: boolean): LineVisibleRanges[];

	visibleRangeForPosition(position: Position): VisibleRange;
}

export class LineVisibleRanges {
	_lineVisibleRangesBrand: void;

	public lineNumber: number;
	public ranges: HorizontalRange[];

	constructor(lineNumber: number, ranges: HorizontalRange[]) {
		this.lineNumber = lineNumber;
		this.ranges = ranges;
	}
}

export class VisibleRange {
	_visibleRangeBrand: void;

	public top: number;
	public left: number;
	public width: number;

	constructor(top: number, left: number, width: number) {
		this.top = top | 0;
		this.left = left | 0;
		this.width = width | 0;
	}
}

export class HorizontalRange {
	_horizontalRangeBrand: void;

	public left: number;
	public width: number;

	constructor(left: number, width: number) {
		this.left = left | 0;
		this.width = width | 0;
	}
}
