Commit f005142d authored by Oleg Korshul's avatar Oleg Korshul

call: retina & tracks

parent bc4f79c7
...@@ -423,7 +423,10 @@ CShape.prototype.handleUpdateGeometry = function() ...@@ -423,7 +423,10 @@ CShape.prototype.handleUpdateGeometry = function()
CShape.prototype.convertPixToMM = function(pix) CShape.prototype.convertPixToMM = function(pix)
{ {
var drawingObjects = getDrawingObjects_Sp(this); var drawingObjects = getDrawingObjects_Sp(this);
return drawingObjects ? drawingObjects.convertMetric(pix, 0, 3) : 0; var val = drawingObjects ? drawingObjects.convertMetric(pix, 0, 3) : 0;
if (AscCommon.AscBrowser.isRetina)
val *= 2;
return val;
}; };
CShape.prototype.getCanvasContext = function() CShape.prototype.getCanvasContext = function()
{ {
......
...@@ -272,11 +272,6 @@ ...@@ -272,11 +272,6 @@
this.canvasGraphicOverlay = document.getElementById("ws-canvas-graphic-overlay"); this.canvasGraphicOverlay = document.getElementById("ws-canvas-graphic-overlay");
} }
// Для мобильных не поддерживаем ретину
if (this.Api.isMobileVersion) {
AscBrowser.isRetina = false;
}
this.buffers.main = new asc.DrawingContext({ this.buffers.main = new asc.DrawingContext({
canvas: this.canvas, units: 1/*pt*/, fmgrGraphics: this.fmgrGraphics, font: this.m_oFont canvas: this.canvas, units: 1/*pt*/, fmgrGraphics: this.fmgrGraphics, font: this.m_oFont
}); });
......
...@@ -47,6 +47,7 @@ function (window, undefined) ...@@ -47,6 +47,7 @@ function (window, undefined)
*/ */
function CMobileDelegateEditorCell(_manager) function CMobileDelegateEditorCell(_manager)
{ {
this.Name = "cell";
this.WB = _manager.Api.wb; this.WB = _manager.Api.wb;
this.DrawingDocument = this.WB.getWorksheet().objectRender.drawingDocument; this.DrawingDocument = this.WB.getWorksheet().objectRender.drawingDocument;
...@@ -67,6 +68,12 @@ function (window, undefined) ...@@ -67,6 +68,12 @@ function (window, undefined)
var _res = this.WB.ConvertLogicToXY(x, y); var _res = this.WB.ConvertLogicToXY(x, y);
var _point = {X: _res.X, Y: _res.Y, Page: 0, DrawPage: 0}; var _point = {X: _res.X, Y: _res.Y, Page: 0, DrawPage: 0};
if (AscBrowser.isRetina)
{
_point.X >>= 1;
_point.Y >>= 1;
}
if (isGlobal !== false) if (isGlobal !== false)
{ {
_point.X += this.Offset.X; _point.X += this.Offset.X;
...@@ -77,7 +84,16 @@ function (window, undefined) ...@@ -77,7 +84,16 @@ function (window, undefined)
}; };
CMobileDelegateEditorCell.prototype.ConvertCoordsFromCursor = function(x, y) CMobileDelegateEditorCell.prototype.ConvertCoordsFromCursor = function(x, y)
{ {
var _res = this.WB.ConvertXYToLogic(x - this.Offset.X, y - this.Offset.Y); var _x = x - this.Offset.X;
var _y = y - this.Offset.Y;
if (AscBrowser.isRetina)
{
_x <<= 1;
_y <<= 1;
}
var _res = this.WB.ConvertXYToLogic(_x, _y);
var _point = {X: _res.X, Y: _res.Y, Page: 0, DrawPage: 0}; var _point = {X: _res.X, Y: _res.Y, Page: 0, DrawPage: 0};
return _point; return _point;
}; };
...@@ -742,6 +758,8 @@ function (window, undefined) ...@@ -742,6 +758,8 @@ function (window, undefined)
ctx.fillStyle = "rgba(" + color.r + "," + color.g + "," + color.b + "," + color.a + ")"; ctx.fillStyle = "rgba(" + color.r + "," + color.g + "," + color.b + "," + color.a + ")";
} }
var _koef = AscCommon.AscBrowser.isRetina ? 2 : 1;
if (!_matrix || global_MatrixTransformer.IsIdentity(_matrix)) if (!_matrix || global_MatrixTransformer.IsIdentity(_matrix))
{ {
var pos1 = this.delegate.ConvertCoordsToCursor(this.RectSelect1.x, this.RectSelect1.y, this.PageSelect1, false); var pos1 = this.delegate.ConvertCoordsToCursor(this.RectSelect1.x, this.RectSelect1.y, this.PageSelect1, false);
...@@ -754,11 +772,11 @@ function (window, undefined) ...@@ -754,11 +772,11 @@ function (window, undefined)
{ {
ctx.beginPath(); ctx.beginPath();
ctx.moveTo(pos1.X >> 0, pos1.Y >> 0); ctx.moveTo((_koef * pos1.X) >> 0, (_koef * pos1.Y) >> 0);
ctx.lineTo(pos2.X >> 0, pos2.Y >> 0); ctx.lineTo((_koef * pos2.X) >> 0, (_koef * pos2.Y) >> 0);
ctx.moveTo(pos3.X >> 0, pos3.Y >> 0); ctx.moveTo((_koef * pos3.X) >> 0, (_koef * pos3.Y) >> 0);
ctx.lineTo(pos4.X >> 0, pos4.Y >> 0); ctx.lineTo((_koef * pos4.X) >> 0, (_koef * pos4.Y) >> 0);
ctx.lineWidth = 2; ctx.lineWidth = 2;
ctx.stroke(); ctx.stroke();
...@@ -768,8 +786,8 @@ function (window, undefined) ...@@ -768,8 +786,8 @@ function (window, undefined)
var _offset = (undefined === color) ? 5 : 0; var _offset = (undefined === color) ? 5 : 0;
overlay.AddEllipse(pos1.X, pos1.Y - _offset, AscCommon.MOBILE_SELECT_TRACK_ROUND / 2); overlay.AddEllipse(_koef * pos1.X, _koef * (pos1.Y - _offset), _koef * AscCommon.MOBILE_SELECT_TRACK_ROUND / 2);
overlay.AddEllipse(pos4.X, pos4.Y + _offset, AscCommon.MOBILE_SELECT_TRACK_ROUND / 2); overlay.AddEllipse(_koef * pos4.X, _koef * (pos4.Y + _offset), _koef * AscCommon.MOBILE_SELECT_TRACK_ROUND / 2);
ctx.fill(); ctx.fill();
ctx.beginPath(); ctx.beginPath();
...@@ -798,11 +816,11 @@ function (window, undefined) ...@@ -798,11 +816,11 @@ function (window, undefined)
{ {
ctx.beginPath(); ctx.beginPath();
ctx.moveTo(pos1.X, pos1.Y); ctx.moveTo(_koef * pos1.X, _koef * pos1.Y);
ctx.lineTo(pos2.X, pos2.Y); ctx.lineTo(_koef * pos2.X, _koef * pos2.Y);
ctx.moveTo(pos3.X, pos3.Y); ctx.moveTo(_koef * pos3.X, _koef * pos3.Y);
ctx.lineTo(pos4.X, pos4.Y); ctx.lineTo(_koef * pos4.X, _koef * pos4.Y);
ctx.lineWidth = 2; ctx.lineWidth = 2;
ctx.stroke(); ctx.stroke();
...@@ -831,13 +849,13 @@ function (window, undefined) ...@@ -831,13 +849,13 @@ function (window, undefined)
var _x2 = (pos4.X + ex) >> 0; var _x2 = (pos4.X + ex) >> 0;
var _y2 = (pos4.Y + ey) >> 0; var _y2 = (pos4.Y + ey) >> 0;
overlay.AddEllipse(_x1, _y1, AscCommon.MOBILE_SELECT_TRACK_ROUND / 2); overlay.AddEllipse(_koef * _x1, _koef * _y1, _koef * AscCommon.MOBILE_SELECT_TRACK_ROUND / 2);
overlay.AddEllipse(_x2, _y2, AscCommon.MOBILE_SELECT_TRACK_ROUND / 2); overlay.AddEllipse(_koef * _x2, _koef * _y2, _koef * AscCommon.MOBILE_SELECT_TRACK_ROUND / 2);
} }
else else
{ {
overlay.AddEllipse(pos1.X, pos1.Y, AscCommon.MOBILE_SELECT_TRACK_ROUND / 2); overlay.AddEllipse(_koef * pos1.X, _koef * pos1.Y, _koef * AscCommon.MOBILE_SELECT_TRACK_ROUND / 2);
overlay.AddEllipse(pos4.X, pos4.Y, AscCommon.MOBILE_SELECT_TRACK_ROUND / 2); overlay.AddEllipse(_koef * pos4.X, _koef * pos4.Y, _koef * AscCommon.MOBILE_SELECT_TRACK_ROUND / 2);
} }
ctx.fill(); ctx.fill();
......
...@@ -1827,6 +1827,7 @@ function DrawingObjects() { ...@@ -1827,6 +1827,7 @@ function DrawingObjects() {
shapeOverlayCtx = currentSheet.shapeOverlayCtx; shapeOverlayCtx = currentSheet.shapeOverlayCtx;
trackOverlay = new AscCommon.COverlay(); trackOverlay = new AscCommon.COverlay();
trackOverlay.IsCellEditor = true;
trackOverlay.init( shapeOverlayCtx.m_oContext, "ws-canvas-graphic-overlay", 0, 0, shapeOverlayCtx.m_lWidthPix, shapeOverlayCtx.m_lHeightPix, shapeOverlayCtx.m_dWidthMM, shapeOverlayCtx.m_dHeightMM ); trackOverlay.init( shapeOverlayCtx.m_oContext, "ws-canvas-graphic-overlay", 0, 0, shapeOverlayCtx.m_lWidthPix, shapeOverlayCtx.m_lHeightPix, shapeOverlayCtx.m_dWidthMM, shapeOverlayCtx.m_dHeightMM );
autoShapeTrack = new AscCommon.CAutoshapeTrack(); autoShapeTrack = new AscCommon.CAutoshapeTrack();
......
...@@ -88,6 +88,7 @@ function COverlay() ...@@ -88,6 +88,7 @@ function COverlay()
this.ClearAll = false; this.ClearAll = false;
this.IsRetina = false; this.IsRetina = false;
this.IsCellEditor = false;
} }
COverlay.prototype = COverlay.prototype =
...@@ -858,6 +859,29 @@ CAutoshapeTrack.prototype = ...@@ -858,6 +859,29 @@ CAutoshapeTrack.prototype =
if (true === isNoMove) if (true === isNoMove)
return; return;
var _retina = this.m_oOverlay.IsRetina;
if (!_retina && this.m_oOverlay.IsCellEditor && AscCommon.AscBrowser.isRetina)
{
this.m_oOverlay.IsRetina = true;
this.m_oOverlay.m_oContext.setTransform(1, 0, 0, 1, 0, 0);
left /= 2;
top /= 2;
width /= 2;
height /= 2;
if (matrix)
{
matrix.tx /= 2;
matrix.ty /= 2;
}
this.m_oOverlay.m_oContext.translate(this.Graphics.m_oCoordTransform.tx, this.Graphics.m_oCoordTransform.ty);
this.m_oOverlay.m_oContext.scale(2, 2);
this.m_oOverlay.m_oContext.translate(-this.Graphics.m_oCoordTransform.tx, -this.Graphics.m_oCoordTransform.ty);
}
// с самого начала нужно понять, есть ли поворот. Потому что если его нет, то можно // с самого начала нужно понять, есть ли поворот. Потому что если его нет, то можно
// (и нужно!) рисовать все по-умному // (и нужно!) рисовать все по-умному
var overlay = this.m_oOverlay; var overlay = this.m_oOverlay;
...@@ -1261,11 +1285,13 @@ CAutoshapeTrack.prototype = ...@@ -1261,11 +1285,13 @@ CAutoshapeTrack.prototype =
var _px = Math.cos(_angle); var _px = Math.cos(_angle);
var _py = Math.sin(_angle); var _py = Math.sin(_angle);
ctx.save();
ctx.translate(_xI, _yI); ctx.translate(_xI, _yI);
ctx.transform(_px, _py, -_py, _px, 0, 0); ctx.transform(_px, _py, -_py, _px, 0, 0);
ctx.drawImage(_image_track_rotate, -_w2, -_w2, _w, _w); ctx.drawImage(_image_track_rotate, -_w2, -_w2, _w, _w);
overlay.SetBaseTransform(); ctx.restore();
overlay.CheckRect(_xI - _w2, _yI - _w2, _w, _w); overlay.CheckRect(_xI - _w2, _yI - _w2, _w, _w);
} }
...@@ -1620,11 +1646,13 @@ CAutoshapeTrack.prototype = ...@@ -1620,11 +1646,13 @@ CAutoshapeTrack.prototype =
var _px = Math.cos(_angle); var _px = Math.cos(_angle);
var _py = Math.sin(_angle); var _py = Math.sin(_angle);
ctx.save();
ctx.translate(_xI, _yI); ctx.translate(_xI, _yI);
ctx.transform(_px, _py, -_py, _px, 0, 0); ctx.transform(_px, _py, -_py, _px, 0, 0);
ctx.drawImage(_image_track_rotate, -_w2, -_w2, _w, _w); ctx.drawImage(_image_track_rotate, -_w2, -_w2, _w, _w);
overlay.SetBaseTransform(); ctx.restore();
overlay.CheckRect(_xI - _w2, _yI - _w2, _w, _w); overlay.CheckRect(_xI - _w2, _yI - _w2, _w, _w);
} }
...@@ -1894,10 +1922,14 @@ CAutoshapeTrack.prototype = ...@@ -1894,10 +1922,14 @@ CAutoshapeTrack.prototype =
var _w = IMAGE_ROTATE_TRACK_W; var _w = IMAGE_ROTATE_TRACK_W;
var _w2 = IMAGE_ROTATE_TRACK_W / 2; var _w2 = IMAGE_ROTATE_TRACK_W / 2;
overlay.SetTransform(ex1, ey1, -ey1, ex1, _xI, _yI); ctx.save();
overlay.transform(ex1, ey1, -ey1, ex1, _xI, _yI);
ctx.drawImage(_image_track_rotate, -_w2, -_w2, _w, _w); ctx.drawImage(_image_track_rotate, -_w2, -_w2, _w, _w);
overlay.SetBaseTransform(); overlay.SetBaseTransform();
ctx.restore();
overlay.CheckRect(_xI - _w2, _yI - _w2, _w, _w); overlay.CheckRect(_xI - _w2, _yI - _w2, _w, _w);
} }
} }
...@@ -1948,6 +1980,18 @@ CAutoshapeTrack.prototype = ...@@ -1948,6 +1980,18 @@ CAutoshapeTrack.prototype =
} }
ctx.globalAlpha = _oldGlobalAlpha; ctx.globalAlpha = _oldGlobalAlpha;
if (!_retina && this.m_oOverlay.IsCellEditor && AscCommon.AscBrowser.isRetina)
{
this.m_oOverlay.IsRetina = false;
this.m_oOverlay.SetBaseTransform();
if (matrix)
{
matrix.tx *= 2;
matrix.ty *= 2;
}
}
}, },
DrawTrackSelectShapes : function(x, y, w, h) DrawTrackSelectShapes : function(x, y, w, h)
...@@ -2229,6 +2273,10 @@ CAutoshapeTrack.prototype = ...@@ -2229,6 +2273,10 @@ CAutoshapeTrack.prototype =
var ctx = overlay.m_oContext; var ctx = overlay.m_oContext;
var dist = TRACK_ADJUSTMENT_SIZE / 2; var dist = TRACK_ADJUSTMENT_SIZE / 2;
if (!overlay.IsRetina && overlay.IsCellEditor && AscCommon.AscBrowser.isRetina)
dist *= 2;
ctx.moveTo(cx - dist, cy); ctx.moveTo(cx - dist, cy);
ctx.lineTo(cx, cy - dist); ctx.lineTo(cx, cy - dist);
ctx.lineTo(cx + dist, cy); ctx.lineTo(cx + dist, cy);
......
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
*/ */
function CMobileDelegateEditorPresentation(_manager) function CMobileDelegateEditorPresentation(_manager)
{ {
this.Name = "slide";
CMobileDelegateEditorPresentation.superclass.constructor.call(this, _manager); CMobileDelegateEditorPresentation.superclass.constructor.call(this, _manager);
} }
AscCommon.extendClass(CMobileDelegateEditorPresentation, AscCommon.CMobileDelegateEditor); AscCommon.extendClass(CMobileDelegateEditorPresentation, AscCommon.CMobileDelegateEditor);
......
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
*/ */
function CMobileTouchManager(_config) function CMobileTouchManager(_config)
{ {
this.Name = "word";
CMobileTouchManager.superclass.constructor.call(this, _config || {}); CMobileTouchManager.superclass.constructor.call(this, _config || {});
} }
AscCommon.extendClass(CMobileTouchManager, AscCommon.CMobileTouchManagerBase); AscCommon.extendClass(CMobileTouchManager, AscCommon.CMobileTouchManagerBase);
......
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