Skip to content

Commit

Permalink
Add support asc_setViewerTargetType method in slides
Browse files Browse the repository at this point in the history
  • Loading branch information
K0R0L committed Nov 9, 2024
1 parent a0b481d commit 022757a
Show file tree
Hide file tree
Showing 2 changed files with 124 additions and 1 deletion.
112 changes: 112 additions & 0 deletions slide/Drawing/HtmlPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,8 @@ function CEditorPage(api)

this.paintMessageLoop = new AscCommon.PaintMessageLoop(40);

this.MouseHandObject = null;

this.m_oApi = api;
var oThis = this;

Expand Down Expand Up @@ -603,6 +605,11 @@ function CEditorPage(api)
this.m_oOverlay.Anchor = (g_anchor_left | g_anchor_top | g_anchor_right | g_anchor_bottom);
this.m_oMainView.AddControl(this.m_oOverlay);

if (!this.m_oApi.isReporterMode)
{
this.setMouseMode(this.m_oApi.mouseMode);
}

if (this.m_oApi.isReporterMode)
{
var _documentParent = document.createElement("div");
Expand Down Expand Up @@ -3254,6 +3261,28 @@ function CEditorPage(api)
return oThis.m_oNotesApi.onMouseUp(e);
};

this.setMouseMode = function(mouseMode)
{
switch (mouseMode)
{
case "hand":
{
this.MouseHandObject = {
check : function(_this, _pos) {
return true;
}
};
break;
}
case "select":
default:
{
this.MouseHandObject = null;
}

}
};

this.onMouseDown = function(e)
{
if (oThis.MobileTouchManager && oThis.MobileTouchManager.checkTouchEvent(e))
Expand Down Expand Up @@ -3326,6 +3355,21 @@ function CEditorPage(api)
if (pos.Page == -1)
return;

if (oWordControl.MouseHandObject)
{
if (oWordControl.MouseHandObject.check(oWordControl, pos))
{
oWordControl.MouseHandObject.X = global_mouseEvent.X;
oWordControl.MouseHandObject.Y = global_mouseEvent.Y;
oWordControl.MouseHandObject.Active = true;
oWordControl.MouseHandObject.ScrollX = oWordControl.m_dScrollX;
oWordControl.MouseHandObject.ScrollY = oWordControl.m_dScrollY;
oWordControl.m_oDrawingDocument.SetCursorType(AscCommon.Cursors.Grabbing);
AscCommon.stopEvent(e);
return;
}
}

var ret = oWordControl.m_oDrawingDocument.checkMouseDown_Drawing(pos);
if (ret === true)
{
Expand Down Expand Up @@ -3392,6 +3436,52 @@ function CEditorPage(api)

AscCommon.check_MouseMoveEvent(e);
var pos = oWordControl.m_oDrawingDocument.ConvertCoordsFromCursor2(global_mouseEvent.X, global_mouseEvent.Y);

if (oWordControl.MouseHandObject)
{
if (oWordControl.MouseHandObject.Active)
{
oWordControl.m_oDrawingDocument.SetCursorType(AscCommon.Cursors.Grabbing);

var scrollX = global_mouseEvent.X - oWordControl.MouseHandObject.X;
var scrollY = global_mouseEvent.Y - oWordControl.MouseHandObject.Y;

if (oWordControl.m_bIsHorScrollVisible)
{
let scrollPosX = oWordControl.MouseHandObject.ScrollX - scrollX;
if (scrollPosX < 0)
scrollPosX = 0;
if (scrollPosX > oWordControl.m_dScrollX_max)
scrollPosX = oWordControl.m_dScrollX_max;
oWordControl.m_oScrollHorApi.scrollToX(scrollPosX);
}

let scrollPosY = oWordControl.MouseHandObject.ScrollY - scrollY;
if (scrollPosY < oWordControl.SlideScrollMIN)
scrollPosY = oWordControl.SlideScrollMIN;
if (scrollPosY > oWordControl.SlideScrollMAX)
scrollPosY = oWordControl.SlideScrollMAX;
oWordControl.m_oScrollVerApi.scrollToY(scrollPosY);
return;
}
else if (!global_mouseEvent.IsLocked)
{
if (oWordControl.MouseHandObject.check(oWordControl, pos))
{
oThis.m_oApi.sync_MouseMoveStartCallback();
oThis.m_oApi.sync_MouseMoveCallback(new AscCommon.CMouseMoveData());
oThis.m_oApi.sync_MouseMoveEndCallback();

oWordControl.m_oDrawingDocument.SetCursorType(AscCommon.Cursors.Grab);

oWordControl.StartUpdateOverlay();
oWordControl.OnUpdateOverlay();
oWordControl.EndUpdateOverlay();
return;
}
}
}

if (pos.Page == -1)
return;

Expand Down Expand Up @@ -3497,6 +3587,14 @@ function CEditorPage(api)

AscCommon.check_MouseUpEvent(e);

if (oWordControl.MouseHandObject && oWordControl.MouseHandObject.Active)
{
oWordControl.MouseHandObject.Active = false;
oWordControl.m_oDrawingDocument.SetCursorType(AscCommon.Cursors.Grab);
oWordControl.m_bIsMouseLock = false;
return;
}

if (oWordControl.m_oDrawingDocument.IsEmptyPresentation)
return;

Expand Down Expand Up @@ -3578,6 +3676,12 @@ function CEditorPage(api)
clearInterval(oWordControl.m_oTimerScrollSelect);
oWordControl.m_oTimerScrollSelect = -1;
}

if (oWordControl.MouseHandObject && oWordControl.MouseHandObject.Active)
{
oWordControl.MouseHandObject.Active = false;
oWordControl.m_oDrawingDocument.SetCursorType(AscCommon.Cursors.Grab);
}
};

this.onMouseUpExternal = function(x, y)
Expand All @@ -3603,6 +3707,14 @@ function CEditorPage(api)

global_mouseEvent.IsPressed = false;

if (oWordControl.MouseHandObject && oWordControl.MouseHandObject.Active)
{
oWordControl.MouseHandObject.Active = false;
oWordControl.m_oDrawingDocument.SetCursorType(AscCommon.Cursors.Grab);
oWordControl.m_bIsMouseLock = false;
return;
}

if (oWordControl.m_oDrawingDocument.IsEmptyPresentation)
return;

Expand Down
13 changes: 12 additions & 1 deletion slide/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,8 @@

this.isOnlyDemonstration = false;

this.mouseMode = "select";


this.presentationViewMode = Asc.c_oAscPresentationViewMode.normal;

Expand Down Expand Up @@ -9360,7 +9362,14 @@ background-repeat: no-repeat;\
return;
oLogicDocument.RemoveCustomProperty(idx);
};


asc_docs_api.prototype.asc_setViewerTargetType = function(mode)
{
this.mouseMode = mode;
if (this.WordControl)
this.WordControl.setMouseMode(mode);
};

//-------------------------------------------------------------export---------------------------------------------------
window['Asc'] = window['Asc'] || {};
window['AscCommonSlide'] = window['AscCommonSlide'] || {};
Expand Down Expand Up @@ -9922,6 +9931,8 @@ background-repeat: no-repeat;\
asc_docs_api.prototype["asc_CanDeleteMaster"] = asc_docs_api.prototype.asc_CanDeleteMaster;
asc_docs_api.prototype["asc_CanDeleteLayout"] = asc_docs_api.prototype.asc_CanDeleteLayout;
asc_docs_api.prototype["asc_IsMasterMode"] = asc_docs_api.prototype.asc_IsMasterMode;

asc_docs_api.prototype["asc_setViewerTargetType"] = asc_docs_api.prototype.asc_setViewerTargetType;


window['Asc']['asc_CCommentData'] = window['Asc'].asc_CCommentData = asc_CCommentData;
Expand Down

0 comments on commit 022757a

Please sign in to comment.