Commit 5c55cbcc authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

Добавил поддержку ретины.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@56606 954022d7-b5bf-4e40-9824-e11837661b57
parent 693f0c23
......@@ -420,6 +420,12 @@ function DrawingContext(settings) {
.appendTo("body");
this.ppiX = asc_round(ppiTest[0] ? (ppiTest[0].offsetWidth * 0.1) : 96);
this.ppiY = asc_round(ppiTest[0] ? (ppiTest[0].offsetHeight * 0.1) : 96);
if (AscBrowser.isRetina) {
this.ppiX <<= 1;
this.ppiY <<= 1;
}
ppiTest.remove();
this._mct = new Matrix(); // units transform
......@@ -437,12 +443,16 @@ function DrawingContext(settings) {
this.changeUnits(undefined !== settings.units ? settings.units : this.units);
this.fmgrGraphics = undefined !== settings.fmgrGraphics ? settings.fmgrGraphics : null;
if (null === this.fmgrGraphics) {return null;}
if (null === this.fmgrGraphics) {
throw "Can not set graphics in DrawingContext";
}
/** @type FontProperties */
this.font = undefined !== settings.font ? settings.font : null;
// Font должен быть передан (он общий для всех DrawingContext, т.к. может возникнуть ситуация как в баге http://bugzserver/show_bug.cgi?id=19784)
if (null === this.font) {return null;}
if (null === this.font) {
throw "Can not set font in DrawingContext";
}
// CColor
this.fillColor = new CColor(255, 255, 255);
......
......@@ -935,18 +935,36 @@
CellEditor.prototype._adjustCanvas = function () {
var t = this;
var z = t.defaults.canvasZIndex;
var left = t.left * t.kx;
var top = t.top * t.ky;
var widthStyle = (t.right - t.left) * t.kx - 1;
var heightStyle = (t.bottom - t.top) * t.ky - 1;
var isRetina = AscBrowser.isRetina;
var width = widthStyle, height = heightStyle;
t.canvasOuterStyle.left = (t.left * t.kx) + "px";
t.canvasOuterStyle.top = (t.top * t.ky) + "px";
t.canvasOuterStyle.width = ((t.right - t.left) * t.kx - 1) + "px";
t.canvasOuterStyle.height = ((t.bottom - t.top) * t.ky - 1) + "px";
if (isRetina) {
left >>= 1;
top >>= 1;
widthStyle >>= 1;
heightStyle >>= 1;
}
t.canvasOuterStyle.left = left + 'px';
t.canvasOuterStyle.top = top + 'px';
t.canvasOuterStyle.width = widthStyle + 'px';
t.canvasOuterStyle.height = heightStyle + 'px';
t.canvasOuterStyle.zIndex = t.top <= 0 ? -1 : z;
t.canvas.width = t.canvasOverlay.width = (t.right - t.left) * t.kx - 1;
t.canvas.height = t.canvasOverlay.height = (t.bottom - t.top) * t.ky - 1;
t.canvas.width = t.canvasOverlay.width = width;
t.canvas.height = t.canvasOverlay.height = height;
if (isRetina) {
t.canvas.style.width = t.canvasOverlay.style.width = widthStyle + 'px';
t.canvas.style.height = t.canvasOverlay.style.height = heightStyle + 'px';
}
// show
t.canvasOuterStyle.display = "block";
t.canvasOuterStyle.display = 'block';
};
CellEditor.prototype._renderText = function (dy) {
......
......@@ -1549,6 +1549,13 @@
var offs = $(this.element).offset();
var x = event.pageX - offs.left;
var y = event.pageY - offs.top;
// ToDo возможно стоит переделать
if (AscBrowser.isRetina) {
x <<= 1;
y <<= 1;
}
return {x: x, y: y};
};
......
......@@ -182,11 +182,16 @@
this.canvasGraphicOverlay = document.getElementById("ws-canvas-graphic-overlay");
}
// Для мобильных не поддерживаем ретину
if (this.Api.isMobileVersion) {
AscBrowser.isRetina = false;
}
this.buffers.main = asc_DC({canvas: this.canvas, units: 1/*pt*/, fmgrGraphics: this.fmgrGraphics, font: this.m_oFont});
this.buffers.overlay = asc_DC({canvas: this.canvasOverlay, units: 1/*pt*/, fmgrGraphics: this.fmgrGraphics, font: this.m_oFont});
this.buffers.mainGraphic = asc_DC({canvas: this.canvasGraphic, units: 1/*pt*/, fmgrGraphics: this.fmgrGraphics, font: this.m_oFont});
this.buffers.overlayGraphic = asc_DC({canvas: this.canvasGraphicOverlay, units: 1/*pt*/, fmgrGraphics: this.fmgrGraphics, font: this.m_oFont});
this.buffers.overlayGraphic = asc_DC({canvas: this.canvasGraphicOverlay, units: 1/*pt*/, fmgrGraphics: this.fmgrGraphics, font: this.m_oFont});
this.drawingCtx = this.buffers.main;
this.overlayCtx = this.buffers.overlay;
......@@ -468,7 +473,7 @@
this.fReplaceCallback = function () {self._replaceCellTextCallback.apply(self, arguments);};
if (this.Api.isMobileVersion){
if (this.Api.isMobileVersion) {
this.MobileTouchManager = new CMobileTouchManager();
this.MobileTouchManager.Init(this);
}
......@@ -1290,12 +1295,28 @@
var oldHeight = this.canvas.height;
var width = this.element.offsetWidth - (this.Api.isMobileVersion ? 0 : this.defaults.scroll.widthPx);
var height = this.element.offsetHeight - (this.Api.isMobileVersion ? 0 : this.defaults.scroll.heightPx);
var styleWidth, styleHeight, isRetina = AscBrowser.isRetina;
if (isRetina) {
styleWidth = width;
styleHeight = height;
width <<= 1;
height <<= 1;
}
if (oldWidth === width && oldHeight === height)
return false;
this.canvas.width = this.canvasOverlay.width = this.canvasGraphic.width = this.canvasGraphicOverlay.width = width;
this.canvas.height = this.canvasOverlay.height = this.canvasGraphic.height = this.canvasGraphicOverlay.height = height;
this.canvas.width = this.canvasOverlay.width = this.canvasGraphic.width =
this.canvasGraphicOverlay.width = width;
this.canvas.height = this.canvasOverlay.height = this.canvasGraphic.height =
this.canvasGraphicOverlay.height = height;
if (isRetina) {
this.canvas.style.width = this.canvasOverlay.style.width = this.canvasGraphic.style.width
= this.canvasGraphicOverlay.style.width = styleWidth + 'px';
this.canvas.style.height = this.canvasOverlay.style.height = this.canvasGraphic.style.height
= this.canvasGraphicOverlay.style.height = styleHeight + 'px';
}
// При смене ориентации у планшета, сбрасываются флаги у canvas!
// ToDo перепроверить на новых исходниках, должно поправиться, был баг в отрисовке!!!!!!!!!!!!!
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment