Commit 623d7f56 authored by Oleg Korshul's avatar Oleg Korshul

retinaPixelRatio for coll smartphones)

parent 90074813
......@@ -3594,6 +3594,7 @@ var editor;
prot["asc_InputClearKeyboardElement"] = prot.asc_InputClearKeyboardElement;
prot["asc_OnHideContextMenu"] = prot.asc_OnHideContextMenu;
prot["asc_OnHideContextMenu"] = prot.asc_OnShowContextMenu;
// mobile
prot["asc_Remove"] = prot.asc_Remove;
......
......@@ -232,8 +232,8 @@ function CControl()
var _W = ((_r - _x) * g_dKoef_mm_to_pix + 0.5) >> 0;
var _H = ((_b - _y) * g_dKoef_mm_to_pix + 0.5) >> 0;
this.HtmlElement.width = _W << 1;
this.HtmlElement.height = _H << 1;
this.HtmlElement.width = _W *= AscCommon.AscBrowser.retinaPixelRatio;
this.HtmlElement.height = _H *= AscCommon.AscBrowser.retinaPixelRatio;
}
else
{
......
......@@ -151,7 +151,7 @@ COverlay.prototype =
SetBaseTransform : function()
{
if (this.IsRetina)
this.m_oContext.setTransform(2, 0, 0, 2, 0, 0);
this.m_oContext.setTransform(AscCommon.AscBrowser.retinaPixelRatio, 0, 0, AscCommon.AscBrowser.retinaPixelRatio, 0, 0);
else
this.m_oContext.setTransform(1, 0, 0, 1, 0, 0);
},
......@@ -590,7 +590,7 @@ CAutoshapeTrack.prototype =
this.Graphics = new AscCommon.CGraphics();
var _scale = this.m_oOverlay.IsRetina? 2 : 1;
var _scale = this.m_oOverlay.IsRetina? AscCommon.AscBrowser.retinaPixelRatio : 1;
this.Graphics.init(this.m_oContext, _scale * (r - x), _scale * (b - y), w_mm, h_mm);
......@@ -779,7 +779,7 @@ CAutoshapeTrack.prototype =
this.Graphics = new AscCommon.CGraphics();
var _scale = this.m_oOverlay.IsRetina? 2 : 1;
var _scale = this.m_oOverlay.IsRetina? AscCommon.AscBrowser.retinaPixelRatio : 1;
this.Graphics.init(this.m_oContext, _scale * (drawPage.right - drawPage.left), _scale * (drawPage.bottom - drawPage.top), oPage.width_mm, oPage.height_mm);
......
......@@ -469,7 +469,7 @@
var _w = this.HtmlPage.m_oEditor.HtmlElement.width;
if (this.HtmlPage.bIsRetinaSupport)
{
_w >>= 1;
_w /= AscCommon.AscBrowser.retinaPixelRatio;
}
Zoom = 100 * _w * AscCommon.g_dKoef_pix_to_mm / this.HtmlPage.m_dDocumentPageWidth;
}
......@@ -648,8 +648,8 @@
if (AscCommon.AscBrowser.isRetina)
{
window.g_table_track_mobile_move.width = 40;
window.g_table_track_mobile_move.height = 40;
window.g_table_track_mobile_move.width = (20 * AscCommon.AscBrowser.retinaPixelRatio) >> 0;
window.g_table_track_mobile_move.height = (20 * AscCommon.AscBrowser.retinaPixelRatio) >> 0;
}
else
......@@ -1713,7 +1713,7 @@
ctx.lineWidth = 1 / dKoef;
if (overlay.IsRetina)
dKoef *= 2;
dKoef *= AscCommon.AscBrowser.retinaPixelRatio;
var _coord_transform = new AscCommon.CMatrix();
_coord_transform.sx = dKoef;
......@@ -1724,10 +1724,10 @@
var _diamond_size = AscCommon.MOBILE_TABLE_RULER_DIAMOND;
if (overlay.IsRetina)
{
_coord_transform.tx *= 2;
_coord_transform.ty *= 2;
_coord_transform.tx *= AscCommon.AscBrowser.retinaPixelRatio;
_coord_transform.ty *= AscCommon.AscBrowser.retinaPixelRatio;
_diamond_size *= 2;
_diamond_size *= AscCommon.AscBrowser.retinaPixelRatio;
}
ctx.save();
......@@ -1743,8 +1743,8 @@
var _offset = (_epsRects + _rectWidth) / dKoef;
if (overlay.IsRetina)
{
_rectW *= 2;
_offset *= 2;
_rectW *= AscCommon.AscBrowser.retinaPixelRatio;
_offset *= AscCommon.AscBrowser.retinaPixelRatio;
}
if (this.delegate.Name != "slide")
......
......@@ -1283,6 +1283,9 @@
baseEditorsApi.prototype.asc_OnHideContextMenu = function()
{
};
baseEditorsApi.prototype.asc_OnShowContextMenu = function()
{
};
//----------------------------------------------------------export----------------------------------------------------
window['AscCommon'] = window['AscCommon'] || {};
......
......@@ -54,7 +54,8 @@ var AscBrowser = {
isArm : false,
isMozilla : false,
isRetina : false,
isLinuxOS : false
isLinuxOS : false,
retinaPixelRatio : 1
};
// user agent lower case
......@@ -121,6 +122,7 @@ AscBrowser.checkZoom = function()
AscBrowser.zoom = 1.0;
AscBrowser.isRetina = false;
AscBrowser.retinaPixelRatio = 1;
if (AscBrowser.isChrome && !AscBrowser.isOpera && !AscBrowser.isMobile && document && document.firstElementChild && document.body)
{
......@@ -174,10 +176,19 @@ AscBrowser.checkZoom = function()
else
document.firstElementChild.style.zoom = "normal";
}
if (AscBrowser.isRetina)
AscBrowser.retinaPixelRatio = 2;
}
else
{
AscBrowser.isRetina = (Math.abs(2 - (window.devicePixelRatio / AscBrowser.zoom)) < 0.01);
if (AscBrowser.isMobile)
{
AscBrowser.isRetina = (window.devicePixelRatio >= 1.9);
AscBrowser.retinaPixelRatio = window.devicePixelRatio;
}
}
};
......
......@@ -6862,6 +6862,7 @@ background-repeat: no-repeat;\
asc_docs_api.prototype["can_CopyCut"] = asc_docs_api.prototype.can_CopyCut;
asc_docs_api.prototype["asc_OnHideContextMenu"] = asc_docs_api.prototype.asc_OnHideContextMenu;
asc_docs_api.prototype["asc_OnShowContextMenu"] = asc_docs_api.prototype.asc_OnShowContextMenu;
window['Asc']['asc_CCommentData'] = window['Asc'].asc_CCommentData = asc_CCommentData;
......
......@@ -2425,8 +2425,8 @@ function CDrawingDocument()
if (this.m_oWordControl.bIsRetinaSupport)
{
w *= 2;
h *= 2;
w *= AscCommon.AscBrowser.retinaPixelRatio;
h *= AscCommon.AscBrowser.retinaPixelRatio;
}
var _check = this.CheckPagesSizeMaximum(w, h);
......@@ -3277,8 +3277,8 @@ function CDrawingDocument()
var _hh = this.m_oWordControl.m_oEditor.HtmlElement.height;
if (this.m_oWordControl.bIsRetinaSupport)
{
_ww >>= 1;
_hh >>= 1;
_ww /= AscCommon.AscBrowser.retinaPixelRatio;
_hh /= AscCommon.AscBrowser.retinaPixelRatio;
}
var boxX = 0;
......@@ -3394,8 +3394,8 @@ function CDrawingDocument()
var _hh = this.m_oWordControl.m_oEditor.HtmlElement.height;
if (this.m_oWordControl.bIsRetinaSupport)
{
_ww >>= 1;
_hh >>= 1;
_ww /= AscCommon.AscBrowser.retinaPixelRatio;
_hh /= AscCommon.AscBrowser.retinaPixelRatio;
}
// �������, ����� �� ������ �� ������
......@@ -5174,7 +5174,7 @@ function CDrawingDocument()
{
var pixHeigth = this.m_oWordControl.m_oEditor.HtmlElement.height;
if (this.m_oWordControl.bIsRetinaSupport)
pixHeigth >>= 1;
pixHeigth /= AscCommon.AscBrowser.retinaPixelRatio;
var pixBetweenPages = 20 * (this.m_lDrawingEnd - this.m_lDrawingFirst);
return (pixHeigth - pixBetweenPages) * g_dKoef_pix_to_mm * 100 / this.m_oWordControl.m_nZoomValue;
......@@ -5871,8 +5871,8 @@ function CDrawingDocument()
}
else
{
_canvas_tables.width = (TABLE_STYLE_WIDTH_PIX << 1);
_canvas_tables.height = (TABLE_STYLE_HEIGHT_PIX << 1);
_canvas_tables.width = (TABLE_STYLE_WIDTH_PIX * AscCommon.AscBrowser.retinaPixelRatio);
_canvas_tables.height = (TABLE_STYLE_HEIGHT_PIX * AscCommon.AscBrowser.retinaPixelRatio);
}
}
......@@ -6611,8 +6611,8 @@ CStylesPainter.prototype =
{
if (_api.WordControl.bIsRetinaSupport)
{
this.STYLE_THUMBNAIL_WIDTH <<= 1;
this.STYLE_THUMBNAIL_HEIGHT <<= 1;
this.STYLE_THUMBNAIL_WIDTH *= AscCommon.AscBrowser.retinaPixelRatio;
this.STYLE_THUMBNAIL_HEIGHT *= AscCommon.AscBrowser.retinaPixelRatio;
this.IsRetinaEnabled = true;
}
......@@ -6678,8 +6678,8 @@ CStylesPainter.prototype =
if (_api.WordControl.bIsRetinaSupport)
{
this.STYLE_THUMBNAIL_WIDTH >>= 1;
this.STYLE_THUMBNAIL_HEIGHT >>= 1;
this.STYLE_THUMBNAIL_WIDTH /= AscCommon.AscBrowser.retinaPixelRatio;
this.STYLE_THUMBNAIL_HEIGHT /= AscCommon.AscBrowser.retinaPixelRatio;
}
// export
......@@ -6709,7 +6709,9 @@ CStylesPainter.prototype =
}
else
{
graphics.init(ctx, _canvas.width, _canvas.height, _canvas.width * g_dKoef_pix_to_mm / 2, _canvas.height * g_dKoef_pix_to_mm / 2);
graphics.init(ctx, _canvas.width, _canvas.height,
_canvas.width * g_dKoef_pix_to_mm / AscCommon.AscBrowser.retinaPixelRatio,
_canvas.height * g_dKoef_pix_to_mm / AscCommon.AscBrowser.retinaPixelRatio);
}
graphics.m_oFontManager = AscCommon.g_fontManager;
......@@ -6761,7 +6763,9 @@ CStylesPainter.prototype =
}
else
{
graphics.init(ctx, _canvas.width, _canvas.height, _canvas.width * g_dKoef_pix_to_mm / 2, _canvas.height * g_dKoef_pix_to_mm / 2);
graphics.init(ctx, _canvas.width, _canvas.height,
_canvas.width * g_dKoef_pix_to_mm / AscCommon.AscBrowser.retinaPixelRatio,
_canvas.height * g_dKoef_pix_to_mm / AscCommon.AscBrowser.retinaPixelRatio);
}
graphics.m_oFontManager = AscCommon.g_fontManager;
......@@ -6849,7 +6853,7 @@ CStylesPainter.prototype =
var dKoefToMM = g_dKoef_pix_to_mm;
if (this.IsRetinaEnabled)
dKoefToMM /= 2;
dKoefToMM /= AscCommon.AscBrowser.retinaPixelRatio;
if (window["flat_desine"] !== true)
{
......
......@@ -1320,8 +1320,8 @@ CGraphics.prototype =
var _yPxOffset = 5;
if (AscBrowser.isRetina)
{
_xPxOffset <<= 1;
_yPxOffset <<= 1;
_xPxOffset *= AscCommon.AscBrowser.retinaPixelRatio;
_yPxOffset *= AscCommon.AscBrowser.retinaPixelRatio;
}
var __x = this.m_oFullTransform.TransformPointX(x, y) >> 0;
......@@ -1378,8 +1378,8 @@ CGraphics.prototype =
var _yPxOffset = 5;
if (AscBrowser.isRetina)
{
_xPxOffset <<= 1;
_yPxOffset <<= 1;
_xPxOffset *= AscCommon.AscBrowser.retinaPixelRatio;
_yPxOffset *= AscCommon.AscBrowser.retinaPixelRatio;
}
var __x = this.m_oFullTransform.TransformPointX(this.m_dWidthMM - x, y) >> 0;
......@@ -1468,8 +1468,8 @@ CGraphics.prototype =
if (_isRetina)
{
_w1 <<= 1;
_w2 <<= 1;
_w1 *= AscCommon.AscBrowser.retinaPixelRatio;
_w2 *= AscCommon.AscBrowser.retinaPixelRatio;
}
var bIsNoIntGrid = this.m_bIntegerGrid;
......@@ -1506,10 +1506,11 @@ CGraphics.prototype =
}
}
this.DrawStringASCII("Courier New", _isRetina ? 18 : 9, false, false, _header_text, 2, yPos, true);
var _fontSize = _isRetina ? (9 * AscCommon.AscBrowser.retinaPixelRatio) : 9;
this.DrawStringASCII("Courier New", _fontSize, false, false, _header_text, 2, yPos, true);
if (bIsRepeat)
this.DrawStringASCII2("Courier New", _isRetina ? 18 : 9, false, false, "Same as Previous", 2, yPos, true);
this.DrawStringASCII2("Courier New", _fontSize, false, false, "Same as Previous", 2, yPos, true);
if (false == bIsNoIntGrid)
this.SetIntegerGrid(false);
......@@ -1568,8 +1569,8 @@ CGraphics.prototype =
if (_isRetina)
{
_w1 <<= 1;
_w2 <<= 1;
_w1 *= AscCommon.AscBrowser.retinaPixelRatio;
_w2 *= AscCommon.AscBrowser.retinaPixelRatio;
}
var _wmax = this.m_lWidthPix;
......@@ -1608,10 +1609,11 @@ CGraphics.prototype =
}
}
this.DrawStringASCII("Courier New", _isRetina ? 18 : 9, false, false, _header_text, 2, yPos, false);
var _fontSize = _isRetina ? (9 * AscCommon.AscBrowser.retinaPixelRatio) : 9;
this.DrawStringASCII("Courier New", _fontSize, false, false, _header_text, 2, yPos, false);
if (bIsRepeat)
this.DrawStringASCII2("Courier New", _isRetina ? 18 : 9, false, false, "Same as Previous", 2, yPos, false);
this.DrawStringASCII2("Courier New", _fontSize, false, false, "Same as Previous", 2, yPos, false);
if (false == bIsNoIntGrid)
this.SetIntegerGrid(false);
......
......@@ -861,7 +861,7 @@ function CEditorPage(api)
var _w = this.m_oEditor.HtmlElement.width;
if (this.bIsRetinaSupport)
{
_w >>= 1;
_w /= AscCommon.AscBrowser.retinaPixelRatio;
}
Zoom = 100 * _w * g_dKoef_pix_to_mm / this.m_dDocumentPageWidth;
}
......@@ -898,8 +898,8 @@ function CEditorPage(api)
if (this.bIsRetinaSupport)
{
w >>= 1;
h >>= 1;
w /= AscCommon.AscBrowser.retinaPixelRatio;
h /= AscCommon.AscBrowser.retinaPixelRatio;
}
var _hor_Zoom = 100;
......@@ -1235,7 +1235,7 @@ function CEditorPage(api)
var _ctx = this.m_oLeftRuler_buttonsTabs.HtmlElement.getContext('2d');
if (this.bIsRetinaSupport)
{
_ctx.setTransform(2, 0, 0, 2, 0, 0);
_ctx.setTransform(AscCommon.AscBrowser.retinaPixelRatio, 0, 0, AscCommon.AscBrowser.retinaPixelRatio, 0, 0);
}
else
{
......@@ -1435,7 +1435,7 @@ function CEditorPage(api)
// делаем заглушку
var minPosY = 20;
if (oThis.bIsRetinaSupport)
minPosY *= 2;
minPosY *= AscCommon.AscBrowser.retinaPixelRatio;
if (positionMinY < minPosY)
positionMinY = minPosY;
......@@ -2556,8 +2556,8 @@ function CEditorPage(api)
if (this.bIsRetinaSupport)
{
settings.screenW /= 2;
settings.screenH /= 2;
settings.screenW /= AscCommon.AscBrowser.retinaPixelRatio;
settings.screenH /= AscCommon.AscBrowser.retinaPixelRatio;
}
if (this.m_oScrollHor_)
......@@ -2747,7 +2747,7 @@ function CEditorPage(api)
var _editor_width = this.m_oEditor.HtmlElement.width;
if (this.bIsRetinaSupport)
_editor_width /= 2;
_editor_width /= AscCommon.AscBrowser.retinaPixelRatio;
var oldVisible = this.m_bIsHorScrollVisible;
if (this.m_dDocumentWidth <= _editor_width)
......@@ -3057,8 +3057,8 @@ function CEditorPage(api)
if (this.bIsRetinaSupport)
{
_width >>= 1;
_height >>= 1;
_width /= AscCommon.AscBrowser.retinaPixelRatio;
_height /= AscCommon.AscBrowser.retinaPixelRatio;
}
var bIsFoundFirst = false;
......@@ -3179,10 +3179,10 @@ function CEditorPage(api)
else
{
var _cur_page_rect = new AscCommon._rect();
_cur_page_rect.x = drawPage.left << 1;
_cur_page_rect.y = drawPage.top << 1;
_cur_page_rect.w = (drawPage.right << 1) - _cur_page_rect.x;
_cur_page_rect.h = (drawPage.bottom << 1) - _cur_page_rect.y;
_cur_page_rect.x = drawPage.left * AscCommon.AscBrowser.retinaPixelRatio;
_cur_page_rect.y = drawPage.top * AscCommon.AscBrowser.retinaPixelRatio;
_cur_page_rect.w = (drawPage.right * AscCommon.AscBrowser.retinaPixelRatio) - _cur_page_rect.x;
_cur_page_rect.h = (drawPage.bottom * AscCommon.AscBrowser.retinaPixelRatio) - _cur_page_rect.y;
rectsPages.push(_cur_page_rect);
}
......@@ -3212,10 +3212,10 @@ function CEditorPage(api)
}
else
{
var __x = drawPage.left << 1;
var __y = drawPage.top << 1;
var __w = (drawPage.right << 1) - __x;
var __h = (drawPage.bottom << 1) - __y;
var __x = drawPage.left * AscCommon.AscBrowser.retinaPixelRatio;
var __y = drawPage.top * AscCommon.AscBrowser.retinaPixelRatio;
var __w = (drawPage.right * AscCommon.AscBrowser.retinaPixelRatio) - __x;
var __h = (drawPage.bottom * AscCommon.AscBrowser.retinaPixelRatio) - __y;
this.m_oDrawingDocument.m_arrPages[i].Draw(context, __x, __y, __w, __h);
//this.m_oBoundsController.CheckRect(__x, __y, __w, __h);
}
......@@ -3244,10 +3244,10 @@ function CEditorPage(api)
var __h = drawPage.bottom - __y;
if (this.bIsRetinaSupport)
{
__x <<= 1;
__y <<= 1;
__w <<= 1;
__h <<= 1;
__x *= AscCommon.AscBrowser.retinaPixelRatio;
__y *= AscCommon.AscBrowser.retinaPixelRatio;
__w *= AscCommon.AscBrowser.retinaPixelRatio;
__h *= AscCommon.AscBrowser.retinaPixelRatio;
}
this.m_oDrawingDocument.CheckRecalculatePage(__w, __h, i);
......
......@@ -768,8 +768,8 @@ CShapeDrawer.prototype =
if (editor.WordControl.bIsRetinaSupport)
{
koefX /= 2;
koefY /= 2;
koefX /= AscCommon.AscBrowser.retinaPixelRatio;
koefY /= AscCommon.AscBrowser.retinaPixelRatio;
}
}
......
......@@ -7502,6 +7502,13 @@ background-repeat: no-repeat;\
this.WordControl.MobileTouchManager.showKeyboard();
}
};
asc_docs_api.prototype.asc_OnShowContextMenu = function()
{
if (this.WordControl.MobileTouchManager)
{
}
};
// desktop editor spellcheck
function CSpellCheckApi_desktop()
......@@ -8049,6 +8056,7 @@ background-repeat: no-repeat;\
asc_docs_api.prototype["asc_GetDefaultTableStyles"] = asc_docs_api.prototype.asc_GetDefaultTableStyles;
asc_docs_api.prototype["asc_Remove"] = asc_docs_api.prototype.asc_Remove;
asc_docs_api.prototype["asc_OnHideContextMenu"] = asc_docs_api.prototype.asc_OnHideContextMenu;
asc_docs_api.prototype["asc_OnShowContextMenu"] = asc_docs_api.prototype.asc_OnShowContextMenu;
CDocInfoProp.prototype['get_PageCount'] = CDocInfoProp.prototype.get_PageCount;
CDocInfoProp.prototype['put_PageCount'] = CDocInfoProp.prototype.put_PageCount;
......
......@@ -1316,8 +1316,8 @@
}
else
{
_canvas.width = (TABLE_STYLE_WIDTH_PIX << 1);
_canvas.height = (TABLE_STYLE_HEIGHT_PIX << 1);
_canvas.width = (TABLE_STYLE_WIDTH_PIX * AscCommon.AscBrowser.retinaPixelRatio);
_canvas.height = (TABLE_STYLE_HEIGHT_PIX * AscCommon.AscBrowser.retinaPixelRatio);
}
var ctx = _canvas.getContext('2d');
......
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