Add splitCoordinate to global variables.
Fix getViewRectangles function - it's used now. Remove "_cellCursor" usage from CalcTileLayer. Modify tests for the new changes. Signed-off-by: Gökay Şatır <gokaysatir@gmail.com> Change-Id: Ia5ec5a6e89d7d64df2041112936a16ec06c4da93pull/8801/head
parent
ce36339b35
commit
9eeed4d950
|
@ -1,4 +1,5 @@
|
|||
/// <reference path="./refs/globals.ts"/>
|
||||
/// <reference path="../src/core/geometry.ts" />
|
||||
/// <reference path="../src/geometry/Point.ts" />
|
||||
/// <reference path="../src/geometry/Bounds.ts" />
|
||||
/// <reference path="./helper/canvasContainerSetup.ts" />
|
||||
|
@ -12,6 +13,8 @@ var dom = new jsdom.JSDOM(canvasDomString());
|
|||
global.window = dom.window;
|
||||
global.document = dom.window.document;
|
||||
|
||||
app.canvasSize = new cool.SimplePoint(0, 0);
|
||||
|
||||
const canvasWidth = 1024;
|
||||
const canvasHeight = 768;
|
||||
const halfWidth = Math.floor(canvasWidth / 2);
|
||||
|
|
|
@ -15,10 +15,10 @@ function canvasDomString() {
|
|||
}
|
||||
|
||||
function setupCanvasContainer(width: number, height: number): CanvasSectionContainer {
|
||||
const canvas = <HTMLCanvasElement>document.getElementById('document-canvas');
|
||||
const canvas = <HTMLCanvasElement>document.getElementById('document-canvas');
|
||||
|
||||
const sectionContainer = new CanvasSectionContainer(canvas, true /* disableDrawing? */);
|
||||
sectionContainer.onResize(width, height); // Set canvas size.
|
||||
const sectionContainer = new CanvasSectionContainer(canvas, true /* disableDrawing? */);
|
||||
sectionContainer.onResize(width, height); // Set canvas size.
|
||||
|
||||
return sectionContainer;
|
||||
return sectionContainer;
|
||||
}
|
||||
|
|
|
@ -4,5 +4,7 @@ var L: any = {
|
|||
};
|
||||
|
||||
var app: any = {
|
||||
roundedDpiScale : 1
|
||||
roundedDpiScale : 1,
|
||||
canvasSize: null,
|
||||
definitions: {}
|
||||
};
|
||||
|
|
|
@ -25,7 +25,8 @@ window.app = {
|
|||
cellAddress: null, // To be assigned SimplePoint.
|
||||
cellCursorVisible: false,
|
||||
cellCursorRectangle: null, // To be assigned SimpleRectangle.
|
||||
otherCellCursors: {}
|
||||
otherCellCursors: {},
|
||||
splitCoordinate: null, // SimplePoint.
|
||||
},
|
||||
map: null, // Make map object a part of this.
|
||||
dispatcher: null, // A Dispatcher class instance is assigned to this.
|
||||
|
|
|
@ -23,6 +23,7 @@ window.addEventListener('load', function () {
|
|||
0,
|
||||
);
|
||||
app.calc.cellAddress = new app.definitions.simplePoint(0, 0);
|
||||
app.calc.splitCoordinate = new app.definitions.simplePoint(0, 0);
|
||||
app.canvasSize = new app.definitions.simplePoint(0, 0);
|
||||
app.file.viewedRectangle = new app.definitions.simpleRectangle(0, 0, 0, 0);
|
||||
app.file.cursor.rectangle = new app.definitions.simpleRectangle(0, 0, 0, 0);
|
||||
|
|
|
@ -113,6 +113,7 @@ export class SplitPanesContext {
|
|||
changed = true;
|
||||
}
|
||||
|
||||
app.calc.splitCoordinate.pX = newX;
|
||||
this._updateXSplitter();
|
||||
|
||||
if (!noFire)
|
||||
|
@ -139,6 +140,7 @@ export class SplitPanesContext {
|
|||
changed = true;
|
||||
}
|
||||
|
||||
app.calc.splitCoordinate.pY = newY;
|
||||
this._updateYSplitter();
|
||||
|
||||
if (!noFire)
|
||||
|
@ -213,36 +215,45 @@ export class SplitPanesContext {
|
|||
*/
|
||||
|
||||
if (this._splitPos.x) { // Vertical split.
|
||||
const topRightPane: cool.SimpleRectangle = viewRectangles[0].clone();
|
||||
topRightPane.pX1 = this._splitPos.x;
|
||||
viewRectangles.push(topRightPane);
|
||||
|
||||
// There is vertical split, narrow down the initial view.
|
||||
viewRectangles[0].pX1 = 0;
|
||||
viewRectangles[0].pX2 = this._splitPos.x;
|
||||
|
||||
const topRightPane: cool.SimpleRectangle = app.file.viewedRectangle.clone();
|
||||
const width = app.file.viewedRectangle.pWidth - viewRectangles[0].pWidth;
|
||||
topRightPane.pX1 = app.file.viewedRectangle.pX2 - width;
|
||||
topRightPane.pWidth = width;
|
||||
viewRectangles.push(topRightPane);
|
||||
}
|
||||
|
||||
if (this._splitPos.y) {
|
||||
const bottomLeftPane = viewRectangles[0].clone();
|
||||
bottomLeftPane.pY1 = this._splitPos.y;
|
||||
|
||||
// There is a horizontal split, narrow down the initial view.
|
||||
viewRectangles[0].pY1 = 0;
|
||||
viewRectangles[0].pY2 = this._splitPos.y;
|
||||
|
||||
const bottomLeftPane = app.file.viewedRectangle.clone();
|
||||
const height = app.file.viewedRectangle.pHeight - viewRectangles[0].pHeight;
|
||||
bottomLeftPane.pY1 = app.file.viewedRectangle.pY2 - height;
|
||||
bottomLeftPane.pHeight = height;
|
||||
viewRectangles.push(bottomLeftPane);
|
||||
}
|
||||
|
||||
// If both splitters are active, don't let them overlap and add the bottom right pane.
|
||||
if (this._splitPos.x && this._splitPos.y) {
|
||||
const bottomRightPane = viewRectangles[0].clone();
|
||||
bottomRightPane.pX1 = this._splitPos.x;
|
||||
bottomRightPane.pY1 = this._splitPos.y;
|
||||
|
||||
viewRectangles[1].pY1 = 0;
|
||||
viewRectangles[1].pY2 = this._splitPos.y;
|
||||
|
||||
viewRectangles[2].pX1 = 0;
|
||||
viewRectangles[2].pX2 = this._splitPos.x;
|
||||
|
||||
const bottomRightPane = app.file.viewedRectangle.clone();
|
||||
const width = app.file.viewedRectangle.pWidth - viewRectangles[0].pWidth;
|
||||
const height = app.file.viewedRectangle.pHeight - viewRectangles[0].pHeight;
|
||||
bottomRightPane.pX1 = app.file.viewedRectangle.pX2 - width;
|
||||
bottomRightPane.pWidth = width;
|
||||
bottomRightPane.pY1 = app.file.viewedRectangle.pY2 - height;
|
||||
bottomRightPane.pHeight = height;
|
||||
|
||||
viewRectangles.push(bottomRightPane);
|
||||
}
|
||||
|
||||
|
|
|
@ -1095,72 +1095,63 @@ L.CalcTileLayer = L.CanvasTileLayer.extend({
|
|||
},
|
||||
|
||||
_calculateScrollForNewCellCursor: function () {
|
||||
|
||||
var scroll = new L.LatLng(0, 0);
|
||||
var scroll = new app.definitions.simplePoint(0, 0);
|
||||
|
||||
if (!app.calc.cellCursorVisible) {
|
||||
return scroll;
|
||||
return new L.LatLng(0, 0);
|
||||
}
|
||||
|
||||
var map = this._map;
|
||||
var paneRectsInLatLng = this.getPaneLatLngRectangles();
|
||||
|
||||
if (this._cellCursor.isInAny(paneRectsInLatLng)) {
|
||||
return scroll; // no scroll needed.
|
||||
let paneRectangles = this._splitPanesContext.getViewRectangles(); // SimpleRectangle array.
|
||||
let contained = false;
|
||||
for (let i = 0; i < paneRectangles.length; i++) {
|
||||
if (paneRectangles[i].containsRectangle(app.calc.cellCursorRectangle.toArray()))
|
||||
contained = true;
|
||||
}
|
||||
|
||||
var noSplit = !this._splitPanesContext
|
||||
|| this._splitPanesContext.getSplitPos().equals(new L.Point(0, 0));
|
||||
if (contained)
|
||||
return new L.LatLng(0, 0); // No scroll needed.
|
||||
|
||||
var cellWidth = this._cellCursor.getWidth();
|
||||
var cellHeight = this._cellCursor.getHeight();
|
||||
var noSplit = this._splitPanesContext.getSplitPos().equals(new L.Point(0, 0));
|
||||
|
||||
// No split panes. Check if target cell is bigger than screen but partially visible.
|
||||
if (noSplit && this._cellCursor.intersects(paneRectsInLatLng[0])) {
|
||||
var paneWidth = paneRectsInLatLng[0].getWidth();
|
||||
var paneHeight = paneRectsInLatLng[0].getHeight();
|
||||
|
||||
if (cellWidth > paneWidth || cellHeight > paneHeight)
|
||||
return scroll; // no scroll needed.
|
||||
if (noSplit && app.calc.cellCursorRectangle.intersectsRectangle(paneRectangles[0].toArray())) {
|
||||
if (app.calc.cellCursorRectangle.width > paneRectangles[0].width || app.calc.cellCursorRectangle.height > paneRectangles[0].height)
|
||||
return new L.LatLng(0, 0); // no scroll needed.
|
||||
}
|
||||
|
||||
var freePaneBounds = paneRectsInLatLng[paneRectsInLatLng.length - 1];
|
||||
var splitPoint = map.unproject(this._splitPanesContext ? this._splitPanesContext.getSplitPos() : new L.Point(0, 0));
|
||||
let freePane = paneRectangles[paneRectangles.length - 1]; // Last pane, this should be the scrollable - not frozen one.
|
||||
|
||||
// Horizontal split
|
||||
if (this._cellCursor.getEast() > splitPoint.lng) {
|
||||
var freePaneWidth = freePaneBounds.getWidth();
|
||||
var cellWidth = this._cellCursor.getWidth();
|
||||
if (app.calc.cellCursorRectangle.x2 > app.calc.splitCoordinate.x) {
|
||||
if (app.calc.cellCursorRectangle.width > freePane.width)
|
||||
return new L.LatLng(0, 0); // no scroll needed.
|
||||
|
||||
if (cellWidth > freePaneWidth)
|
||||
return scroll; // no scroll needed.
|
||||
var spacingX = app.calc.cellCursorRectangle.width / 4.0;
|
||||
|
||||
var spacingX = cellWidth / 4.0;
|
||||
|
||||
if (this._cellCursor.getWest() < freePaneBounds.getWest()) {
|
||||
scroll.lng = this._cellCursor.getWest() - freePaneBounds.getWest() - spacingX;
|
||||
if (app.calc.cellCursorRectangle.x1 < freePane.x1) {
|
||||
scroll.x = app.calc.cellCursorRectangle.x1 - freePane.x1 - spacingX;
|
||||
}
|
||||
else if (cellWidth < freePaneWidth && this._cellCursor.getEast() > freePaneBounds.getEast()) {
|
||||
scroll.lng = this._cellCursor.getEast() - freePaneBounds.getEast() + spacingX;
|
||||
else if (app.calc.cellCursorRectangle.x2 > freePane.x2) {
|
||||
scroll.x = app.calc.cellCursorRectangle.x2 - freePane.x2 + spacingX;
|
||||
}
|
||||
}
|
||||
|
||||
// Vertical split
|
||||
if (this._cellCursor.getSouth() < splitPoint.lat) {
|
||||
var freePaneHeight = freePaneBounds.getHeight();
|
||||
if (app.calc.cellCursorRectangle.y2 > app.calc.splitCoordinate.y) {
|
||||
if (app.calc.cellCursorRectangle.height > freePane.height)
|
||||
return new L.LatLng(0, 0); // no scroll needed.
|
||||
|
||||
if (cellHeight > freePaneHeight)
|
||||
return scroll; // no scroll needed.
|
||||
|
||||
var spacingY = cellHeight / 4.0;
|
||||
if (this._cellCursor.getNorth() > freePaneBounds.getNorth()) {
|
||||
scroll.lat = this._cellCursor.getNorth() - freePaneBounds.getNorth() + spacingY;
|
||||
var spacingY = app.calc.cellCursorRectangle.height / 4.0;
|
||||
if (app.calc.cellCursorRectangle.y1 < freePane.y1) {
|
||||
scroll.y = app.calc.cellCursorRectangle.y1 - freePane.y1 - spacingY;
|
||||
}
|
||||
else if (this._cellCursor.getSouth() < freePaneBounds.getSouth()) {
|
||||
scroll.lat = this._cellCursor.getSouth() - freePaneBounds.getSouth() - spacingY;
|
||||
else if (app.calc.cellCursorRectangle.y2 > freePane.y2) {
|
||||
scroll.y = app.calc.cellCursorRectangle.y2 - freePane.y2 + spacingY;
|
||||
}
|
||||
}
|
||||
|
||||
scroll = this._twipsToLatLng(scroll, this._map.getZoom()); // Simple point is also converted to L.Point by the converter.
|
||||
|
||||
return scroll;
|
||||
},
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ interface SectionCallbacks {
|
|||
onDrawArea?: (area?: cool.Bounds, paneTopLeft?: cool.Point, canvasContext?: CanvasRenderingContext2D) => void;
|
||||
onNewDocumentTopLeft?: (size: Array<number>) => void;
|
||||
onRemove?: () => void;
|
||||
onCursorPositionChanged?: (newPosition: cool.SimpleRectangle) => void;
|
||||
onCursorPositionChanged?: (newPosition: any) => void;
|
||||
onCellAddressChanged?: () => void;
|
||||
onAnimationEnded?: (frameCount: number, elapsedTime: number) => void;
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ class CanvasSectionObject {
|
|||
return this.callbacks.onInitialize();
|
||||
}
|
||||
|
||||
onCursorPositionChanged(newPosition: cool.SimpleRectangle) {
|
||||
onCursorPositionChanged(newPosition: any) {
|
||||
if (this.callbacks.onCursorPositionChanged)
|
||||
return this.callbacks.onCursorPositionChanged(newPosition);
|
||||
}
|
||||
|
@ -908,10 +908,10 @@ class CanvasSectionContainer {
|
|||
this.documentBottomRight[0] = Math.round(points[2]);
|
||||
this.documentBottomRight[1] = Math.round(points[3]);
|
||||
|
||||
app.file.viewedRectangle.pX = this.documentTopLeft[0];
|
||||
app.file.viewedRectangle.pY = this.documentTopLeft[1];
|
||||
app.file.viewedRectangle.pWidth = this.documentTopLeft[2];
|
||||
app.file.viewedRectangle.pHeight = this.documentTopLeft[3];
|
||||
app.file.viewedRectangle.pX1 = points[0];
|
||||
app.file.viewedRectangle.pY1 = points[1];
|
||||
app.file.viewedRectangle.pWidth = points[2] - points[0];
|
||||
app.file.viewedRectangle.pHeight = points[3] - points[1];
|
||||
|
||||
for (var i: number = 0; i < this.sections.length; i++) {
|
||||
var section: CanvasSectionObject = this.sections[i];
|
||||
|
|
|
@ -29,7 +29,7 @@ class CellCursorSection extends CanvasSectionObject {
|
|||
this.documentObject = true;
|
||||
|
||||
this.sectionProperties.viewId = viewId;
|
||||
this.sectionProperties.cursorWeight = 2;
|
||||
this.sectionProperties.cursorWeight = 2;
|
||||
}
|
||||
|
||||
public getViewId(): number {
|
||||
|
|
|
@ -19,10 +19,10 @@ describe(['tagdesktop', 'tagnextcloud', 'tagproxy'], 'Test jumping on large cell
|
|||
});
|
||||
|
||||
it('No jump on long merged cell', function() {
|
||||
desktopHelper.assertScrollbarPosition('horizontal', 210, 315);
|
||||
desktopHelper.assertScrollbarPosition('horizontal', 205, 315);
|
||||
calcHelper.clickOnFirstCell(true, false, false);
|
||||
cy.cGet('input#addressInput').should('have.prop', 'value', 'A1:Z1');
|
||||
desktopHelper.assertScrollbarPosition('horizontal', 210, 315);
|
||||
desktopHelper.assertScrollbarPosition('horizontal', 205, 315);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue