From 4477087083e84026ba1260266ebd0efe06027ad4 Mon Sep 17 00:00:00 2001 From: Vladimir Privezenov Date: Mon, 25 Aug 2025 16:38:57 +0300 Subject: [PATCH] Draw dropdown last --- common/Charts/DrawingArea.js | 56 ++++++++++++++++++----------- common/Charts/DrawingObjects.js | 4 +++ common/Drawings/CommonController.js | 10 ++++++ common/Drawings/Format/Controls.js | 36 +++++++++++-------- 4 files changed, 72 insertions(+), 34 deletions(-) diff --git a/common/Charts/DrawingArea.js b/common/Charts/DrawingArea.js index d867c9626b..0f8b173ea3 100755 --- a/common/Charts/DrawingArea.js +++ b/common/Charts/DrawingArea.js @@ -527,15 +527,17 @@ function FrozenPlace(ws, type) { // этот рестор нужен для восстановления сложных вложенных клипов canvas.m_oContext.restore(); }; - - _this.drawObject = function(object, oRect) { - - var oUpdateRect = _this.worksheet.rangeToRectAbs(_this.range, 3); + _this.getUpdateRect = function (oRect) { + let oUpdateRect = _this.worksheet.rangeToRectAbs(_this.range, 3); if(oRect) { oUpdateRect = oUpdateRect.intersection(oRect); - if(!oUpdateRect) { - return; - } + } + return oUpdateRect; + } + _this._updateGraphicCanvas = function (fCallback, oRect) { + var oUpdateRect = _this.getUpdateRect(oRect); + if (!oUpdateRect) { + return; } var canvas = _this.worksheet.objectRender.getDrawingCanvas(); _this.setTransform(canvas.shapeCtx, canvas.shapeOverlayCtx, canvas.autoShapeTrack); @@ -555,22 +557,31 @@ function FrozenPlace(ws, type) { _this.clip(canvas.shapeCtx, oClipRect); canvas.shapeCtx.updatedRect = oUpdateRect; - object.draw(canvas.shapeCtx); + fCallback(canvas.shapeCtx); canvas.shapeCtx.updatedRect = null; - // Lock - if ( (object.graphicObject.lockType !== undefined) && (object.graphicObject.lockType !== AscCommon.c_oAscLockTypes.kLockTypeNone) ) { - var oApi = Asc['editor']; - if(oApi){ - if (!oApi.collaborativeEditing.getFast() || object.graphicObject.lockType !== AscCommon.c_oAscLockTypes.kLockTypeMine){ - canvas.shapeCtx.SetIntegerGrid(false); - canvas.shapeCtx.transform3(object.graphicObject.transform, false); - canvas.shapeCtx.DrawLockObjectRect(object.graphicObject.lockType, 0, 0, object.graphicObject.extX, object.graphicObject.extY ); - canvas.shapeCtx.reset(); - canvas.shapeCtx.SetIntegerGrid(true); + _this.restore(canvas.shapeCtx); + } + _this.drawObject = function(object, oRect) { + this._updateGraphicCanvas(function (graphics) { + object.draw(graphics); + if ( (object.graphicObject.lockType !== undefined) && (object.graphicObject.lockType !== AscCommon.c_oAscLockTypes.kLockTypeNone) ) { + var oApi = Asc['editor']; + if(oApi){ + if (!oApi.collaborativeEditing.getFast() || object.graphicObject.lockType !== AscCommon.c_oAscLockTypes.kLockTypeMine){ + graphics.SetIntegerGrid(false); + graphics.transform3(object.graphicObject.transform, false); + graphics.DrawLockObjectRect(object.graphicObject.lockType, 0, 0, object.graphicObject.extX, object.graphicObject.extY ); + graphics.reset(); + graphics.SetIntegerGrid(true); + } } } - } - _this.restore(canvas.shapeCtx); + }, oRect); + }; + _this.drawDropDown = function(object, oRect) { + this._updateGraphicCanvas(function (graphics) { + object.drawDropDown(graphics); + }); }; _this.updateRange = function(object, oRange) { @@ -810,6 +821,11 @@ DrawingArea.prototype.drawObject = function(object, oRect) { } } }; + DrawingArea.prototype.drawDropDown = function(object, oRect) { + for ( var i = 0; i < this.frozenPlaces.length; i++ ) { + this.frozenPlaces[i].drawDropDown(object, oRect); + } + }; DrawingArea.prototype.updateRange = function(object, oRange) { for ( var i = 0; i < this.frozenPlaces.length; i++ ) { if ( this.frozenPlaces[i].isObjectInside(object) ) { diff --git a/common/Charts/DrawingObjects.js b/common/Charts/DrawingObjects.js index 35d750e248..f5f4676112 100644 --- a/common/Charts/DrawingObjects.js +++ b/common/Charts/DrawingObjects.js @@ -2333,6 +2333,10 @@ CSparklineView.prototype.setMinMaxValAx = function(minVal, maxVal, oSparklineGro for (var nDrawing = 0; nDrawing < aObjects.length; nDrawing++) { _this.drawingArea.drawObject(aObjects[nDrawing], oUpdateRect); } + const aDropDowns = _this.controller.dropDowns; + for (var nDrawing = 0; nDrawing < aDropDowns.length; nDrawing++) { + _this.drawingArea.drawDropDown(aDropDowns[nDrawing], oUpdateRect); + } _this.OnUpdateOverlay(); _this.controller.updateSelectionState(true); AscCommon.CollaborativeEditing.Update_ForeignCursorsPositions(); diff --git a/common/Drawings/CommonController.js b/common/Drawings/CommonController.js index c0516a07a9..f02a0b7d1e 100644 --- a/common/Drawings/CommonController.js +++ b/common/Drawings/CommonController.js @@ -706,6 +706,7 @@ this.lastCursorInfo = null; + this.dropDowns = []; } function CanStartEditText(oController) { @@ -6191,6 +6192,9 @@ }, onMouseWheel: function (deltaX, deltaY) { + for (let i = 0; i < this.dropDowns.length; i += 1) { + this.dropDowns[i].forceUpdate(); + } var aSelection = this.getSelectedArray(); if (aSelection.length === 1 && aSelection[0].getObjectType() === AscDFH.historyitem_type_SlicerView) { @@ -6198,6 +6202,12 @@ } return false; }, + addDropDown: function(oDropDown) { + this.dropDowns.push(oDropDown); + }, + resetDropDowns: function() { + this.dropDowns.length = 0; + }, /*onKeyPress: function(e) { diff --git a/common/Drawings/Format/Controls.js b/common/Drawings/Format/Controls.js index 53d3ed0600..71df825446 100644 --- a/common/Drawings/Format/Controls.js +++ b/common/Drawings/Format/Controls.js @@ -336,6 +336,12 @@ function getFlatPenColor() { return true; } CControl.prototype.draw = function (graphics, transform, transformText, pageIndex, opt) { + const oUR = graphics.updatedRect; + if (oUR && this.bounds) { + if (!oUR.isIntersectOther(this.bounds)) { + return; + } + } this.controller.draw(graphics, transform, transformText, pageIndex, opt); }; CControl.prototype.hitInInnerArea = function (x, y) { @@ -353,17 +359,17 @@ function getFlatPenColor() { } CControl.prototype.onMouseDown = function (e, nX, nY, nPageIndex, oDrawingController) { const bRet = this.controller.onMouseDown(e, nX, nY, nPageIndex, oDrawingController); - this.controller.updateControl(); + this.controller.update(); return bRet; } CControl.prototype.onMouseMove = function (e, nX, nY, nPageIndex, oDrawingController) { const bRet = this.controller.onMouseMove(e, nX, nY, nPageIndex, oDrawingController); - this.controller.updateControl(); + this.controller.update(); return bRet; } CControl.prototype.onMouseUp = function (e, nX, nY, nPageIndex, oDrawingController) { const bRet = this.controller.onMouseUp(e, nX, nY, nPageIndex, oDrawingController); - this.controller.updateControl(); + this.controller.update(); return bRet; } CControl.prototype.getCursorInfo = function (e, nX, nY) { @@ -571,14 +577,15 @@ function getFlatPenColor() { CControlControllerBase.prototype.checkNeedUpdate = function() { this.isNeedUpdate = true; }; - CControlControllerBase.prototype.updateControl = function() { + CControlControllerBase.prototype.update = function() { if (this.isNeedUpdate) { this.isNeedUpdate = false; this.control.onUpdate(); + this.forceUpdate(); } }; - CControlControllerBase.prototype.isNeedWriteShape = function() { - return false; + CControlControllerBase.prototype.forceUpdate = function() { + this.control.onUpdate(); }; const CHECKBOX_SIDE_SIZE = 3; @@ -2384,7 +2391,7 @@ function getFlatPenColor() { oThis.selectedText = oThis.listBox.listItems[nIndex].text; oThis.updateLinkedCell(); oThis.updateSelectionInFormControl(); - oThis.closeDropdown(); + oThis.closeDropdown(oDrawingController); }, [], undefined, AscDFH.historydescription_Spreadsheet_SelectListBox, [], true); }; }; @@ -2421,20 +2428,20 @@ function getFlatPenColor() { } }; - CComboBoxController.prototype.openDropdown = function () { + CComboBoxController.prototype.openDropdown = function (oDrawingController) { if (!this.isDropdownOpen) { this.isDropdownOpen = true; this.dropButton.setIsHold(true); - Asc.editor && Asc.editor.addDropDown(this); + oDrawingController.addDropDown(this); this.checkNeedUpdate(); } }; - CComboBoxController.prototype.closeDropdown = function () { + CComboBoxController.prototype.closeDropdown = function (oDrawingController) { if (this.isDropdownOpen) { this.dropButton.setIsHold(false); this.isDropdownOpen = false; - Asc.editor && Asc.editor.resetDropDowns(); + oDrawingController.resetDropDowns(); this.checkNeedUpdate(); } }; @@ -2517,11 +2524,12 @@ function getFlatPenColor() { } if (this.isDropdownOpen) { - this.listBox.onMouseDown(e, nX, nY, nPageIndex, oDrawingController); - this.closeDropdown(); + if (!this.listBox.onMouseDown(e, nX, nY, nPageIndex, oDrawingController)) { + this.closeDropdown(oDrawingController); + } return oControl.hit(nX, nY); } else if (oControl.hit(nX, nY)) { - this.openDropdown(); + this.openDropdown(oDrawingController); return true; } return false;