mirror of
https://gitee.com/hoslay/ddei-editor.git
synced 2025-12-06 17:18:36 +08:00
键盘调整位置时,快捷按钮没跟着一起;编辑文本框时,图形快捷键被激活;键盘调整位置时,快捷按钮没跟着一起;
This commit is contained in:
parent
3dc28d1284
commit
8c7b83031a
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ddei-editor",
|
"name": "ddei-editor",
|
||||||
"version": "1.2.41-5",
|
"version": "1.2.42-6",
|
||||||
"private": false,
|
"private": false,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"author": "hoslay <3697355039@qq.com>",
|
"author": "hoslay <3697355039@qq.com>",
|
||||||
|
|||||||
@ -57,37 +57,57 @@ class DDeiKeyActionAllSelect extends DDeiKeyAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ============================ 方法 ===============================
|
// ============================ 方法 ===============================
|
||||||
action(evt: Event, ddInstance: DDei): void {
|
|
||||||
|
|
||||||
|
isActive(element: object): boolean {
|
||||||
|
if (!element) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if (element.tagName == 'BODY' || element.tagName == 'HEAD' || element.tagName == 'HTML') {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
action(evt: Event, ddInstance: DDei): boolean {
|
||||||
//修改当前操作控件坐标
|
//修改当前操作控件坐标
|
||||||
if (ddInstance && ddInstance.stage) {
|
if (ddInstance && ddInstance.stage) {
|
||||||
|
//必须是canvas的子控件
|
||||||
let models = []
|
if (this.isActive(document.activeElement)) {
|
||||||
if (ddInstance.stage.selectedModels?.size > 0) {
|
let models = []
|
||||||
models = Array.from(ddInstance.stage.selectedModels?.values());
|
if (ddInstance.stage.selectedModels?.size > 0) {
|
||||||
}
|
models = Array.from(ddInstance.stage.selectedModels?.values());
|
||||||
if (models?.length == 1 && models[0].baseModelType == 'DDeiTable' && models[0].curRow != -1 && models[0].curCol != -1) {
|
}
|
||||||
//选中当前表格所有单元格
|
if (models?.length == 1 && models[0].baseModelType == 'DDeiTable' && models[0].curRow != -1 && models[0].curCol != -1) {
|
||||||
for (let i = 0; i < models[0].rows.length; i++) {
|
//选中当前表格所有单元格
|
||||||
let rowObj = models[0].rows[i];
|
for (let i = 0; i < models[0].rows.length; i++) {
|
||||||
for (let j = 0; j < rowObj.length; j++) {
|
let rowObj = models[0].rows[i];
|
||||||
rowObj[j].setState(DDeiEnumControlState.SELECTED)
|
for (let j = 0; j < rowObj.length; j++) {
|
||||||
|
rowObj[j].setState(DDeiEnumControlState.SELECTED)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//当前激活的图层
|
||||||
|
let layer = ddInstance.stage.layers[ddInstance.stage.layerIndex]
|
||||||
|
//加载事件的配置
|
||||||
|
let rsState = DDeiUtil.invokeCallbackFunc("EVENT_CONTROL_SELECT_BEFORE", DDeiEnumOperateType.SELECT, { models: Array.from(layer.models.values()) }, ddInstance, evt)
|
||||||
|
if (rsState == 0 || rsState == 1) {
|
||||||
|
ddInstance?.bus?.push(DDeiEnumBusCommandType.ModelChangeSelect, { models: layer.models, value: DDeiEnumControlState.SELECTED }, evt);
|
||||||
|
ddInstance?.bus?.push(DDeiEnumBusCommandType.StageChangeSelectModels, {}, evt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
//渲染图形
|
||||||
//当前激活的图层
|
ddInstance?.bus?.push(DDeiEnumBusCommandType.RefreshShape, null, evt);
|
||||||
let layer = ddInstance.stage.layers[ddInstance.stage.layerIndex]
|
|
||||||
//加载事件的配置
|
|
||||||
let rsState = DDeiUtil.invokeCallbackFunc("EVENT_CONTROL_SELECT_BEFORE", DDeiEnumOperateType.SELECT, { models: Array.from(layer.models.values()) }, ddInstance, evt)
|
|
||||||
if (rsState == 0 || rsState == 1) {
|
|
||||||
ddInstance?.bus?.push(DDeiEnumBusCommandType.ModelChangeSelect, { models: layer.models, value: DDeiEnumControlState.SELECTED }, evt);
|
|
||||||
ddInstance?.bus?.push(DDeiEnumBusCommandType.StageChangeSelectModels, {}, evt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//渲染图形
|
|
||||||
ddInstance?.bus?.push(DDeiEnumBusCommandType.RefreshShape, null, evt);
|
|
||||||
|
|
||||||
ddInstance?.bus?.executeAll();
|
ddInstance?.bus?.executeAll();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -56,69 +56,88 @@ class DDeiKeyActionBrushData extends DDeiKeyAction {
|
|||||||
return DDeiKeyActionBrushData;
|
return DDeiKeyActionBrushData;
|
||||||
}
|
}
|
||||||
// ============================ 方法 ===============================
|
// ============================ 方法 ===============================
|
||||||
action(evt: Event, ddInstance: DDei): void {
|
|
||||||
|
isActive(element: object): boolean {
|
||||||
|
if (!element) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if (element.tagName == 'BODY' || element.tagName == 'HEAD' || element.tagName == 'HTML') {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
action(evt: Event, ddInstance: DDei): boolean {
|
||||||
//记录当前格式信息,修改状态为刷子状态
|
//记录当前格式信息,修改状态为刷子状态
|
||||||
if (ddInstance && ddInstance.stage) {
|
if (ddInstance && ddInstance.stage) {
|
||||||
let stage = ddInstance.stage
|
//必须是canvas的子控件
|
||||||
let editor = DDeiEditor.ACTIVE_INSTANCE;
|
if (this.isActive(document.activeElement)) {
|
||||||
let models = Array.from(ddInstance.stage.selectedModels?.values());
|
let stage = ddInstance.stage
|
||||||
stage.brushData = null
|
let editor = DDeiEditor.ACTIVE_INSTANCE;
|
||||||
if (models?.length == 1) {
|
let models = Array.from(ddInstance.stage.selectedModels?.values());
|
||||||
if (models[0].baseModelType == 'DDeiTable') {
|
stage.brushData = null
|
||||||
let table = models[0]
|
if (models?.length == 1) {
|
||||||
let selectedCells = table.getSelectedCells();
|
if (models[0].baseModelType == 'DDeiTable') {
|
||||||
let minMaxColRow = table.getMinMaxRowAndCol(selectedCells);
|
let table = models[0]
|
||||||
stage.brushData = []
|
let selectedCells = table.getSelectedCells();
|
||||||
for (let i = minMaxColRow.minRow; i <= minMaxColRow.maxRow; i++) {
|
let minMaxColRow = table.getMinMaxRowAndCol(selectedCells);
|
||||||
let rowObj = table.rows[i];
|
stage.brushData = []
|
||||||
let rowData = []
|
for (let i = minMaxColRow.minRow; i <= minMaxColRow.maxRow; i++) {
|
||||||
|
let rowObj = table.rows[i];
|
||||||
|
let rowData = []
|
||||||
|
|
||||||
for (let j = minMaxColRow.minCol; j <= minMaxColRow.maxCol; j++) {
|
for (let j = minMaxColRow.minCol; j <= minMaxColRow.maxCol; j++) {
|
||||||
let cellObj = rowObj[j];
|
let cellObj = rowObj[j];
|
||||||
rowData.push(cellObj);
|
rowData.push(cellObj);
|
||||||
}
|
|
||||||
stage.brushData.push(rowData);
|
|
||||||
}
|
|
||||||
if (stage.brushData.length > 0) {
|
|
||||||
editor.changeState(DDeiEditorState.DESIGNING)
|
|
||||||
editor.bus.push(DDeiEditorEnumBusCommandType.ClearTemplateUI);
|
|
||||||
editor.bus.executeAll();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
|
|
||||||
if (editor.state == DDeiEditorState.QUICK_EDITING) {
|
|
||||||
let shadowControl = editor.ddInstance.stage.render.editorShadowControl
|
|
||||||
if (shadowControl?.render.isEditoring) {
|
|
||||||
let editorText = DDeiUtil.getEditorText();
|
|
||||||
//开始光标与结束光标
|
|
||||||
let curSIdx = -1
|
|
||||||
let curEIdx = -1
|
|
||||||
if (editorText) {
|
|
||||||
curSIdx = editorText.selectionStart
|
|
||||||
curEIdx = editorText.selectionEnd
|
|
||||||
}
|
}
|
||||||
stage.brushDataText = cloneDeep(shadowControl.getSptAllStyles(curSIdx, curEIdx))
|
stage.brushData.push(rowData);
|
||||||
|
}
|
||||||
|
if (stage.brushData.length > 0) {
|
||||||
|
editor.changeState(DDeiEditorState.DESIGNING)
|
||||||
|
editor.bus.push(DDeiEditorEnumBusCommandType.ClearTemplateUI);
|
||||||
|
editor.bus.executeAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
delete stage.brushData
|
|
||||||
editor.bus?.push(DDeiEnumBusCommandType.ChangeCursor, { image: 'cursor-brush' })
|
|
||||||
editor.bus?.executeAll();
|
|
||||||
} else {
|
} else {
|
||||||
let model = models[0]
|
|
||||||
stage.brushData = [model]
|
if (editor.state == DDeiEditorState.QUICK_EDITING) {
|
||||||
delete stage.brushDataText
|
let shadowControl = editor.ddInstance.stage.render.editorShadowControl
|
||||||
editor.changeState(DDeiEditorState.DESIGNING)
|
if (shadowControl?.render.isEditoring) {
|
||||||
editor.bus?.push(DDeiEditorEnumBusCommandType.ClearTemplateUI);
|
let editorText = DDeiUtil.getEditorText();
|
||||||
editor.bus?.push(DDeiEnumBusCommandType.ChangeCursor, { image: 'cursor-brush' })
|
//开始光标与结束光标
|
||||||
editor.bus?.executeAll();
|
let curSIdx = -1
|
||||||
|
let curEIdx = -1
|
||||||
|
if (editorText) {
|
||||||
|
curSIdx = editorText.selectionStart
|
||||||
|
curEIdx = editorText.selectionEnd
|
||||||
|
}
|
||||||
|
stage.brushDataText = cloneDeep(shadowControl.getSptAllStyles(curSIdx, curEIdx))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
delete stage.brushData
|
||||||
|
editor.bus?.push(DDeiEnumBusCommandType.ChangeCursor, { image: 'cursor-brush' })
|
||||||
|
editor.bus?.executeAll();
|
||||||
|
} else {
|
||||||
|
let model = models[0]
|
||||||
|
stage.brushData = [model]
|
||||||
|
delete stage.brushDataText
|
||||||
|
editor.changeState(DDeiEditorState.DESIGNING)
|
||||||
|
editor.bus?.push(DDeiEditorEnumBusCommandType.ClearTemplateUI);
|
||||||
|
editor.bus?.push(DDeiEnumBusCommandType.ChangeCursor, { image: 'cursor-brush' })
|
||||||
|
editor.bus?.executeAll();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
import {DDeiEditor} from "ddei-framework";
|
import { DDeiEditor, DDeiEditorUtil } from "ddei-framework";
|
||||||
import {DDei} from "ddei-framework";
|
import {DDei} from "ddei-framework";
|
||||||
import {DDeiKeyAction} from "ddei-framework";
|
import {DDeiKeyAction} from "ddei-framework";
|
||||||
import {DDeiEnumBusCommandType} from "ddei-framework";
|
import {DDeiEnumBusCommandType} from "ddei-framework";
|
||||||
import {DDeiAbstractShape} from "ddei-framework";
|
import {DDeiAbstractShape} from "ddei-framework";
|
||||||
import {DDeiEnumControlState} from "ddei-framework";
|
import {DDeiEnumControlState} from "ddei-framework";
|
||||||
import {DDeiEditorState} from "ddei-framework";
|
import { DDeiEditorState, DDeiEnumOperateType } from "ddei-framework";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 键行为:移动模型
|
* 键行为:移动模型
|
||||||
@ -33,6 +33,8 @@ class DDeiKeyActionMoveModels extends DDeiKeyAction {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
getHotKeys(editor) {
|
getHotKeys(editor) {
|
||||||
return [this];
|
return [this];
|
||||||
}
|
}
|
||||||
@ -61,134 +63,153 @@ class DDeiKeyActionMoveModels extends DDeiKeyAction {
|
|||||||
return DDeiKeyActionMoveModels;
|
return DDeiKeyActionMoveModels;
|
||||||
}
|
}
|
||||||
// ============================ 方法 ===============================
|
// ============================ 方法 ===============================
|
||||||
action(evt: Event, ddInstance: DDei,editor:DDeiEditor): void {
|
|
||||||
|
|
||||||
|
isActive(element: object): boolean {
|
||||||
|
if (!element) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if (element.tagName == 'BODY' || element.tagName == 'HEAD' || element.tagName == 'HTML') {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
action(evt: Event, ddInstance: DDei,editor:DDeiEditor): boolean {
|
||||||
//修改当前操作控件坐标
|
//修改当前操作控件坐标
|
||||||
if (ddInstance && ddInstance.stage) {
|
if (ddInstance && ddInstance.stage) {
|
||||||
let selectedModels = ddInstance.stage.selectedModels;
|
//必须是canvas的子控件
|
||||||
let models = Array.from(selectedModels.values());
|
if (this.isActive(document.activeElement)) {
|
||||||
if (models.length == 1 && models[0].baseModelType == 'DDeiTable' && models[0].curRow != -1 && models[0].curCol != -1) {
|
let selectedModels = ddInstance.stage.selectedModels;
|
||||||
|
let models = Array.from(selectedModels.values());
|
||||||
|
if (models.length == 1 && models[0].baseModelType == 'DDeiTable' && models[0].curRow != -1 && models[0].curCol != -1) {
|
||||||
|
|
||||||
//上
|
//上
|
||||||
if (evt.keyCode == 38) {
|
if (evt.keyCode == 38) {
|
||||||
if (models[0].curRow > 0) {
|
if (models[0].curRow > 0) {
|
||||||
if (models[0].tempDragCell) {
|
if (models[0].tempDragCell) {
|
||||||
models[0].tempDragCell.setState(DDeiEnumControlState.DEFAULT)
|
models[0].tempDragCell.setState(DDeiEnumControlState.DEFAULT)
|
||||||
|
}
|
||||||
|
models[0].curRow--;
|
||||||
|
models[0].tempDragCell = models[0].rows[models[0].curRow][models[0].curCol]
|
||||||
|
models[0].tempDragCell.setState(DDeiEnumControlState.SELECTED)
|
||||||
}
|
}
|
||||||
models[0].curRow--;
|
}//下
|
||||||
models[0].tempDragCell = models[0].rows[models[0].curRow][models[0].curCol]
|
else if (evt.keyCode == 40) {
|
||||||
models[0].tempDragCell.setState(DDeiEnumControlState.SELECTED)
|
if (models[0].curRow < models[0].rows.length - 1) {
|
||||||
}
|
if (models[0].tempDragCell) {
|
||||||
}//下
|
models[0].tempDragCell.setState(DDeiEnumControlState.DEFAULT)
|
||||||
else if (evt.keyCode == 40) {
|
}
|
||||||
if (models[0].curRow < models[0].rows.length - 1) {
|
models[0].curRow++;
|
||||||
if (models[0].tempDragCell) {
|
models[0].tempDragCell = models[0].rows[models[0].curRow][models[0].curCol]
|
||||||
models[0].tempDragCell.setState(DDeiEnumControlState.DEFAULT)
|
models[0].tempDragCell.setState(DDeiEnumControlState.SELECTED)
|
||||||
}
|
}
|
||||||
models[0].curRow++;
|
}//左
|
||||||
models[0].tempDragCell = models[0].rows[models[0].curRow][models[0].curCol]
|
else if (evt.keyCode == 37) {
|
||||||
models[0].tempDragCell.setState(DDeiEnumControlState.SELECTED)
|
if (models[0].curCol > 0) {
|
||||||
}
|
if (models[0].tempDragCell) {
|
||||||
}//左
|
models[0].tempDragCell.setState(DDeiEnumControlState.DEFAULT)
|
||||||
else if (evt.keyCode == 37) {
|
}
|
||||||
if (models[0].curCol > 0) {
|
models[0].curCol--;
|
||||||
if (models[0].tempDragCell) {
|
models[0].tempDragCell = models[0].rows[models[0].curRow][models[0].curCol]
|
||||||
models[0].tempDragCell.setState(DDeiEnumControlState.DEFAULT)
|
models[0].tempDragCell.setState(DDeiEnumControlState.SELECTED)
|
||||||
}
|
}
|
||||||
models[0].curCol--;
|
}//右
|
||||||
models[0].tempDragCell = models[0].rows[models[0].curRow][models[0].curCol]
|
else if (evt.keyCode == 39) {
|
||||||
models[0].tempDragCell.setState(DDeiEnumControlState.SELECTED)
|
if (models[0].curCol < models[0].cols.length - 1) {
|
||||||
}
|
if (models[0].tempDragCell) {
|
||||||
}//右
|
models[0].tempDragCell.setState(DDeiEnumControlState.DEFAULT)
|
||||||
else if (evt.keyCode == 39) {
|
}
|
||||||
if (models[0].curCol < models[0].cols.length - 1) {
|
models[0].curCol++;
|
||||||
if (models[0].tempDragCell) {
|
models[0].tempDragCell = models[0].rows[models[0].curRow][models[0].curCol]
|
||||||
models[0].tempDragCell.setState(DDeiEnumControlState.DEFAULT)
|
models[0].tempDragCell.setState(DDeiEnumControlState.SELECTED)
|
||||||
}
|
}
|
||||||
models[0].curCol++;
|
|
||||||
models[0].tempDragCell = models[0].rows[models[0].curRow][models[0].curCol]
|
|
||||||
models[0].tempDragCell.setState(DDeiEnumControlState.SELECTED)
|
|
||||||
}
|
}
|
||||||
}
|
} else if (editor.GLOBAL_KEYBOARD_ALIGN_ENABLE){
|
||||||
} else if (editor.GLOBAL_KEYBOARD_ALIGN_ENABLE){
|
let moveSize = 1;
|
||||||
let moveSize = 1;
|
|
||||||
|
|
||||||
let isShift = DDei.KEY_DOWN_STATE.get("shift");
|
let isShift = DDei.KEY_DOWN_STATE.get("shift");
|
||||||
if (!isShift) {
|
|
||||||
|
|
||||||
//辅助对齐线宽度
|
|
||||||
moveSize = 10;
|
|
||||||
}
|
|
||||||
let moveOriginLines = []
|
|
||||||
models.forEach(md => {
|
|
||||||
if (md.baseModelType == 'DDeiLine') {
|
|
||||||
moveOriginLines.push(md.id)
|
|
||||||
}
|
|
||||||
});
|
|
||||||
let outRect = DDeiAbstractShape.getOutRectByPV(models);
|
|
||||||
let deltaX, deltaY
|
|
||||||
//上
|
|
||||||
if (evt.keyCode == 38) {
|
|
||||||
let mod = 0;
|
|
||||||
//如果开启辅助对齐线,则跳回到对齐线上
|
|
||||||
if (!isShift) {
|
if (!isShift) {
|
||||||
if (outRect.y % moveSize > 0) {
|
|
||||||
mod = moveSize - (outRect.y % moveSize);
|
//辅助对齐线宽度
|
||||||
|
moveSize = 10;
|
||||||
|
}
|
||||||
|
let moveOriginLines = []
|
||||||
|
models.forEach(md => {
|
||||||
|
if (md.baseModelType == 'DDeiLine') {
|
||||||
|
moveOriginLines.push(md.id)
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
deltaY = - moveSize + mod
|
let outRect = DDeiAbstractShape.getOutRectByPV(models);
|
||||||
}
|
let deltaX, deltaY
|
||||||
//下
|
//上
|
||||||
else if (evt.keyCode == 40) {
|
if (evt.keyCode == 38) {
|
||||||
let mod = 0;
|
let mod = 0;
|
||||||
if (!isShift) {
|
//如果开启辅助对齐线,则跳回到对齐线上
|
||||||
mod = outRect.y % moveSize;
|
if (!isShift) {
|
||||||
}
|
if (outRect.y % moveSize > 0) {
|
||||||
deltaY = moveSize - mod
|
mod = moveSize - (outRect.y% moveSize);
|
||||||
}
|
}
|
||||||
//左
|
|
||||||
else if (evt.keyCode == 37) {
|
|
||||||
let mod = 0;
|
|
||||||
//如果开启辅助对齐线,则跳回到对齐线上
|
|
||||||
if (!isShift) {
|
|
||||||
if (outRect.x % moveSize > 0) {
|
|
||||||
mod = moveSize - (outRect.x % moveSize);
|
|
||||||
}
|
}
|
||||||
|
deltaY = - moveSize + mod
|
||||||
}
|
}
|
||||||
deltaX = - moveSize + mod
|
//下
|
||||||
}
|
else if (evt.keyCode == 40) {
|
||||||
//右
|
let mod = 0;
|
||||||
else if (evt.keyCode == 39) {
|
if (!isShift) {
|
||||||
let mod = 0;
|
mod = Math.round(outRect.y) % moveSize;
|
||||||
if (!isShift) {
|
}
|
||||||
mod = outRect.x % moveSize;
|
deltaY = moveSize - mod
|
||||||
}
|
}
|
||||||
deltaX = moveSize - mod
|
//左
|
||||||
|
else if (evt.keyCode == 37) {
|
||||||
|
let mod = 0;
|
||||||
|
//如果开启辅助对齐线,则跳回到对齐线上
|
||||||
|
if (!isShift) {
|
||||||
|
if (outRect.x % moveSize > 0) {
|
||||||
|
mod = moveSize - (outRect.x % moveSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
deltaX = - moveSize + mod
|
||||||
|
}
|
||||||
|
//右
|
||||||
|
else if (evt.keyCode == 39) {
|
||||||
|
let mod = 0;
|
||||||
|
if (!isShift) {
|
||||||
|
mod = Math.round(outRect.x) % moveSize;
|
||||||
|
}
|
||||||
|
deltaX = moveSize - mod
|
||||||
|
}
|
||||||
|
let stage = ddInstance.stage
|
||||||
|
|
||||||
|
DDeiAbstractShape.moveModels(models, deltaX, deltaY, moveOriginLines);
|
||||||
|
|
||||||
|
stage.layers[stage.layerIndex].opPoints = []
|
||||||
|
if (stage.layers[stage.layerIndex].opLine?.render) {
|
||||||
|
stage.layers[stage.layerIndex].opLine.render.enableRefreshShape()
|
||||||
|
}
|
||||||
|
delete stage.layers[stage.layerIndex].opLine;
|
||||||
|
stage.render.refreshJumpLine = false
|
||||||
|
ddInstance.bus.push(DDeiEnumBusCommandType.UpdateSelectorBounds);
|
||||||
|
ddInstance.bus.push(DDeiEnumBusCommandType.NodifyChange);
|
||||||
|
ddInstance.bus.push(DDeiEnumBusCommandType.AddHistroy, null, evt);
|
||||||
|
ddInstance.bus.push(DDeiEnumBusCommandType.ClearTemplateVars);
|
||||||
|
//渲染图形
|
||||||
|
ddInstance.bus.push(DDeiEnumBusCommandType.RefreshShape, null, evt);
|
||||||
|
|
||||||
|
ddInstance.bus.executeAll();
|
||||||
|
DDeiEditorUtil.invokeCallbackFunc("EVENT_CONTROL_DRAG_AFTER", DDeiEnumOperateType.DRAG, { models: models }, ddInstance, evt)
|
||||||
|
|
||||||
|
return true
|
||||||
|
|
||||||
}
|
}
|
||||||
let stage = ddInstance.stage
|
|
||||||
|
|
||||||
DDeiAbstractShape.moveModels(models, deltaX, deltaY, moveOriginLines);
|
|
||||||
|
|
||||||
stage.layers[stage.layerIndex].opPoints = []
|
|
||||||
if (stage.layers[stage.layerIndex].opLine?.render) {
|
|
||||||
stage.layers[stage.layerIndex].opLine.render.enableRefreshShape()
|
|
||||||
}
|
|
||||||
delete stage.layers[stage.layerIndex].opLine;
|
|
||||||
stage.render.refreshJumpLine = false
|
|
||||||
ddInstance.bus.push(DDeiEnumBusCommandType.UpdateSelectorBounds);
|
|
||||||
ddInstance.bus.push(DDeiEnumBusCommandType.NodifyChange);
|
|
||||||
ddInstance.bus.push(DDeiEnumBusCommandType.AddHistroy, null, evt);
|
|
||||||
ddInstance.bus.push(DDeiEnumBusCommandType.ClearTemplateVars);
|
|
||||||
//渲染图形
|
|
||||||
ddInstance.bus.push(DDeiEnumBusCommandType.RefreshShape, null, evt);
|
|
||||||
|
|
||||||
ddInstance.bus.executeAll();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -60,42 +60,62 @@ class DDeiKeyActionPushModels extends DDeiKeyAction {
|
|||||||
return DDeiKeyActionPushModels;
|
return DDeiKeyActionPushModels;
|
||||||
}
|
}
|
||||||
// ============================ 方法 ===============================
|
// ============================ 方法 ===============================
|
||||||
action(evt: Event, ddInstance: DDei): void {
|
|
||||||
|
isActive(element: object): boolean {
|
||||||
|
if (!element) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if (element.tagName == 'BODY' || element.tagName == 'HEAD' || element.tagName == 'HTML') {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
action(evt: Event, ddInstance: DDei): boolean {
|
||||||
//修改当前操作控件坐标
|
//修改当前操作控件坐标
|
||||||
if (ddInstance && ddInstance.stage) {
|
if (ddInstance && ddInstance.stage) {
|
||||||
let stageRender = ddInstance.stage.render;
|
//必须是canvas的子控件
|
||||||
let optContainer = stageRender.currentOperateContainer;
|
if (this.isActive(document.activeElement)) {
|
||||||
if (optContainer) {
|
let stageRender = ddInstance.stage.render;
|
||||||
let isCtrl = DDei.KEY_DOWN_STATE.get("ctrl");
|
let optContainer = stageRender.currentOperateContainer;
|
||||||
let isShift = DDei.KEY_DOWN_STATE.get("shift");
|
if (optContainer) {
|
||||||
//同时按下ctrl和shift
|
let isCtrl = DDei.KEY_DOWN_STATE.get("ctrl");
|
||||||
if (isCtrl && isShift) {
|
let isShift = DDei.KEY_DOWN_STATE.get("shift");
|
||||||
//上
|
//同时按下ctrl和shift
|
||||||
if (evt.keyCode == 38) {
|
if (isCtrl && isShift) {
|
||||||
ddInstance.bus.push(DDeiEnumBusCommandType.ModelPush, { container: optContainer, type: "top" }, evt);
|
//上
|
||||||
|
if (evt.keyCode == 38) {
|
||||||
|
ddInstance.bus.push(DDeiEnumBusCommandType.ModelPush, { container: optContainer, type: "top" }, evt);
|
||||||
|
}
|
||||||
|
//下
|
||||||
|
else if (evt.keyCode == 40) {
|
||||||
|
ddInstance.bus.push(DDeiEnumBusCommandType.ModelPush, { container: optContainer, type: "bottom" }, evt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//下
|
//只按下了ctrl
|
||||||
else if (evt.keyCode == 40) {
|
else if (isCtrl) {
|
||||||
ddInstance.bus.push(DDeiEnumBusCommandType.ModelPush, { container: optContainer, type: "bottom" }, evt);
|
//上
|
||||||
|
if (evt.keyCode == 38) {
|
||||||
|
ddInstance.bus.push(DDeiEnumBusCommandType.ModelPush, { container: optContainer, type: "up" }, evt);
|
||||||
|
}
|
||||||
|
//下
|
||||||
|
else if (evt.keyCode == 40) {
|
||||||
|
ddInstance.bus.push(DDeiEnumBusCommandType.ModelPush, { container: optContainer, type: "down" }, evt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//只按下了ctrl
|
//渲染图形
|
||||||
else if (isCtrl) {
|
ddInstance.bus.push(DDeiEnumBusCommandType.RefreshShape, null, evt);
|
||||||
//上
|
|
||||||
if (evt.keyCode == 38) {
|
|
||||||
ddInstance.bus.push(DDeiEnumBusCommandType.ModelPush, { container: optContainer, type: "up" }, evt);
|
|
||||||
}
|
|
||||||
//下
|
|
||||||
else if (evt.keyCode == 40) {
|
|
||||||
ddInstance.bus.push(DDeiEnumBusCommandType.ModelPush, { container: optContainer, type: "down" }, evt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//渲染图形
|
|
||||||
ddInstance.bus.push(DDeiEnumBusCommandType.RefreshShape, null, evt);
|
|
||||||
|
|
||||||
ddInstance.bus.executeAll();
|
ddInstance.bus.executeAll();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,75 +61,97 @@ class DDeiKeyActionReRevoke extends DDeiKeyAction {
|
|||||||
return DDeiKeyActionReRevoke;
|
return DDeiKeyActionReRevoke;
|
||||||
}
|
}
|
||||||
// ============================ 方法 ===============================
|
// ============================ 方法 ===============================
|
||||||
action(evt: Event, ddInstance: DDei): void {
|
|
||||||
|
isActive(element: object): boolean {
|
||||||
|
if (!element) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if (element.tagName == 'BODY' || element.tagName == 'HEAD' || element.tagName == 'HTML') {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
action(evt: Event, ddInstance: DDei): boolean {
|
||||||
let editor = DDeiEditor.ACTIVE_INSTANCE;
|
let editor = DDeiEditor.ACTIVE_INSTANCE;
|
||||||
let histype = DDeiEditorUtil.getConfigValue("HISTROY_LEVEL", editor);
|
//必须是canvas的子控件
|
||||||
if (histype == 'file') {
|
if (this.isActive(document.activeElement)) {
|
||||||
if (editor?.files.length > 0 && (editor.currentFileIndex == 0 || editor.currentFileIndex)) {
|
let histype = DDeiEditorUtil.getConfigValue("HISTROY_LEVEL", editor);
|
||||||
let file = editor?.files[editor.currentFileIndex]
|
if (histype == 'file') {
|
||||||
//从历史恢复文件
|
if (editor?.files.length > 0 && (editor.currentFileIndex == 0 || editor.currentFileIndex)) {
|
||||||
if (file?.active == DDeiActiveType.ACTIVE) {
|
let file = editor?.files[editor.currentFileIndex]
|
||||||
let hisData = file.reRevokeHistroyData();
|
//从历史恢复文件
|
||||||
if (hisData?.data) {
|
if (file?.active == DDeiActiveType.ACTIVE) {
|
||||||
let jsonData = JSON.parse(hisData?.data)
|
let hisData = file.reRevokeHistroyData();
|
||||||
if (jsonData) {
|
if (hisData?.data) {
|
||||||
let ddInstance = editor?.ddInstance;
|
let jsonData = JSON.parse(hisData?.data)
|
||||||
ddInstance.stage.destroyRender()
|
if (jsonData) {
|
||||||
let hisFile = DDeiFile.loadFromJSON(jsonData, {
|
let ddInstance = editor?.ddInstance;
|
||||||
currentDdInstance: ddInstance,
|
ddInstance.stage.destroyRender()
|
||||||
});
|
let hisFile = DDeiFile.loadFromJSON(jsonData, {
|
||||||
if (hisData.isNew == true) {
|
currentDdInstance: ddInstance,
|
||||||
file.state = DDeiFileState.NONE;
|
});
|
||||||
} else {
|
if (hisData.isNew == true) {
|
||||||
file.state = DDeiFileState.MODIFY
|
file.state = DDeiFileState.NONE;
|
||||||
}
|
} else {
|
||||||
file.name = hisFile?.name;
|
file.state = DDeiFileState.MODIFY
|
||||||
file.desc = hisFile?.desc;
|
}
|
||||||
file.lastUpdateTime = hisFile?.lastUpdateTime;
|
file.name = hisFile?.name;
|
||||||
file.sheets = hisFile?.sheets;
|
file.desc = hisFile?.desc;
|
||||||
if (file && file.sheets && ddInstance) {
|
file.lastUpdateTime = hisFile?.lastUpdateTime;
|
||||||
file.changeSheet(hisFile.currentSheetIndex);
|
file.sheets = hisFile?.sheets;
|
||||||
let stage = file.sheets[file.currentSheetIndex].stage;
|
if (file && file.sheets && ddInstance) {
|
||||||
stage.ddInstance = ddInstance;
|
file.changeSheet(hisFile.currentSheetIndex);
|
||||||
//刷新页面
|
let stage = file.sheets[file.currentSheetIndex].stage;
|
||||||
ddInstance.stage = stage;
|
stage.ddInstance = ddInstance;
|
||||||
//加载场景渲染器
|
//刷新页面
|
||||||
stage.initRender();
|
ddInstance.stage = stage;
|
||||||
ddInstance.bus.push(DDeiEnumBusCommandType.RefreshShape);
|
//加载场景渲染器
|
||||||
ddInstance.bus.push(DDeiEditorEnumBusCommandType.RefreshEditorParts)
|
stage.initRender();
|
||||||
ddInstance.bus.executeAll();
|
ddInstance.bus.push(DDeiEnumBusCommandType.RefreshShape);
|
||||||
|
ddInstance.bus.push(DDeiEditorEnumBusCommandType.RefreshEditorParts)
|
||||||
|
ddInstance.bus.executeAll();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if (histype == 'stage') {
|
||||||
} else if (histype == 'stage') {
|
//修改当前操作控件坐标
|
||||||
//修改当前操作控件坐标
|
if (ddInstance && ddInstance.stage) {
|
||||||
if (ddInstance && ddInstance.stage) {
|
let hisData = ddInstance.stage.reRevokeHistroyData();
|
||||||
let hisData = ddInstance.stage.reRevokeHistroyData();
|
if (hisData?.data) {
|
||||||
if (hisData?.data) {
|
let jsonData = JSON.parse(hisData?.data)
|
||||||
let jsonData = JSON.parse(hisData?.data)
|
if (jsonData) {
|
||||||
if (jsonData) {
|
ddInstance.stage.destroyRender()
|
||||||
ddInstance.stage.destroyRender()
|
let tempData = { "currentDdInstance": ddInstance, "currentStage": ddInstance.stage }
|
||||||
let tempData = { "currentDdInstance": ddInstance, "currentStage": ddInstance.stage }
|
tempData[ddInstance.stage.id] = ddInstance.stage
|
||||||
tempData[ddInstance.stage.id] = ddInstance.stage
|
let layers = [];
|
||||||
let layers = [];
|
jsonData.layers.forEach(layer => {
|
||||||
jsonData.layers.forEach(layer => {
|
let model = DDeiLayer.loadFromJSON(layer, tempData);
|
||||||
let model = DDeiLayer.loadFromJSON(layer, tempData);
|
layers.push(model);
|
||||||
layers.push(model);
|
})
|
||||||
})
|
ddInstance.stage.idIdx = jsonData.idIdx;
|
||||||
ddInstance.stage.idIdx = jsonData.idIdx;
|
ddInstance.stage.layers = layers
|
||||||
ddInstance.stage.layers = layers
|
ddInstance.stage.initRender();
|
||||||
ddInstance.stage.initRender();
|
//渲染图形
|
||||||
//渲染图形
|
ddInstance.bus.push(DDeiEnumBusCommandType.RefreshShape, null, evt);
|
||||||
ddInstance.bus.push(DDeiEnumBusCommandType.RefreshShape, null, evt);
|
ddInstance.bus.push(DDeiEditorEnumBusCommandType.RefreshEditorParts)
|
||||||
ddInstance.bus.push(DDeiEditorEnumBusCommandType.RefreshEditorParts)
|
ddInstance.bus.executeAll();
|
||||||
ddInstance.bus.executeAll();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,80 +61,100 @@ class DDeiKeyActionRevoke extends DDeiKeyAction {
|
|||||||
return DDeiKeyActionRevoke;
|
return DDeiKeyActionRevoke;
|
||||||
}
|
}
|
||||||
// ============================ 方法 ===============================
|
// ============================ 方法 ===============================
|
||||||
action(evt: Event, ddInstance: DDei): void {
|
|
||||||
|
isActive(element: object): boolean {
|
||||||
|
if (!element) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if (element.tagName == 'BODY' || element.tagName == 'HEAD' || element.tagName == 'HTML') {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
action(evt: Event, ddInstance: DDei): boolean {
|
||||||
let editor = DDeiEditor.ACTIVE_INSTANCE;
|
let editor = DDeiEditor.ACTIVE_INSTANCE;
|
||||||
let histype = DDeiEditorUtil.getConfigValue("HISTROY_LEVEL", editor);
|
//必须是canvas的子控件
|
||||||
if (histype == 'file') {
|
if (this.isActive(document.activeElement)) {
|
||||||
let editor = DDeiEditor.ACTIVE_INSTANCE;
|
let histype = DDeiEditorUtil.getConfigValue("HISTROY_LEVEL", editor);
|
||||||
if (editor?.files.length > 0 && (editor.currentFileIndex == 0 || editor.currentFileIndex)) {
|
if (histype == 'file') {
|
||||||
let file = editor?.files[editor.currentFileIndex]
|
let editor = DDeiEditor.ACTIVE_INSTANCE;
|
||||||
//从历史恢复文件
|
if (editor?.files.length > 0 && (editor.currentFileIndex == 0 || editor.currentFileIndex)) {
|
||||||
if (file?.active == DDeiActiveType.ACTIVE) {
|
let file = editor?.files[editor.currentFileIndex]
|
||||||
let hisData = file.revokeHistroyData();
|
//从历史恢复文件
|
||||||
if (hisData?.data) {
|
if (file?.active == DDeiActiveType.ACTIVE) {
|
||||||
let jsonData = JSON.parse(hisData?.data)
|
let hisData = file.revokeHistroyData();
|
||||||
if (jsonData) {
|
if (hisData?.data) {
|
||||||
let ddInstance = editor?.ddInstance;
|
let jsonData = JSON.parse(hisData?.data)
|
||||||
ddInstance.stage.destroyRender()
|
if (jsonData) {
|
||||||
let hisFile = DDeiFile.loadFromJSON(jsonData, {
|
let ddInstance = editor?.ddInstance;
|
||||||
currentDdInstance: ddInstance,
|
ddInstance.stage.destroyRender()
|
||||||
});
|
let hisFile = DDeiFile.loadFromJSON(jsonData, {
|
||||||
|
currentDdInstance: ddInstance,
|
||||||
|
});
|
||||||
|
|
||||||
if (hisData.isNew == true) {
|
if (hisData.isNew == true) {
|
||||||
file.state = DDeiFileState.NONE;
|
file.state = DDeiFileState.NONE;
|
||||||
} else {
|
} else {
|
||||||
file.state = DDeiFileState.MODIFY
|
file.state = DDeiFileState.MODIFY
|
||||||
}
|
}
|
||||||
file.name = hisFile?.name;
|
file.name = hisFile?.name;
|
||||||
file.desc = hisFile?.desc;
|
file.desc = hisFile?.desc;
|
||||||
file.lastUpdateTime = hisFile?.lastUpdateTime;
|
file.lastUpdateTime = hisFile?.lastUpdateTime;
|
||||||
file.sheets = hisFile?.sheets;
|
file.sheets = hisFile?.sheets;
|
||||||
if (file && file.sheets && ddInstance) {
|
if (file && file.sheets && ddInstance) {
|
||||||
file.changeSheet(hisFile.currentSheetIndex);
|
file.changeSheet(hisFile.currentSheetIndex);
|
||||||
let stage = file.sheets[file.currentSheetIndex].stage;
|
let stage = file.sheets[file.currentSheetIndex].stage;
|
||||||
stage.ddInstance = ddInstance;
|
stage.ddInstance = ddInstance;
|
||||||
//刷新页面
|
//刷新页面
|
||||||
ddInstance.stage = stage;
|
ddInstance.stage = stage;
|
||||||
//加载场景渲染器
|
//加载场景渲染器
|
||||||
stage.initRender();
|
stage.initRender();
|
||||||
|
|
||||||
ddInstance.bus.push(DDeiEnumBusCommandType.RefreshShape);
|
ddInstance.bus.push(DDeiEnumBusCommandType.RefreshShape);
|
||||||
ddInstance.bus.push(DDeiEditorEnumBusCommandType.RefreshEditorParts)
|
ddInstance.bus.push(DDeiEditorEnumBusCommandType.RefreshEditorParts)
|
||||||
ddInstance.bus.executeAll();
|
ddInstance.bus.executeAll();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if (histype == 'stage') {
|
||||||
} else if (histype == 'stage') {
|
//修改当前操作控件坐标
|
||||||
//修改当前操作控件坐标
|
if (ddInstance && ddInstance.stage) {
|
||||||
if (ddInstance && ddInstance.stage) {
|
|
||||||
|
let hisData = ddInstance.stage.revokeHistroyData();
|
||||||
let hisData = ddInstance.stage.revokeHistroyData();
|
if (hisData?.data) {
|
||||||
if (hisData?.data) {
|
let jsonData = JSON.parse(hisData?.data)
|
||||||
let jsonData = JSON.parse(hisData?.data)
|
if (jsonData) {
|
||||||
if (jsonData) {
|
ddInstance.stage.destroyRender()
|
||||||
ddInstance.stage.destroyRender()
|
let tempData = { "currentDdInstance": ddInstance, "currentStage": ddInstance.stage }
|
||||||
let tempData = { "currentDdInstance": ddInstance, "currentStage": ddInstance.stage }
|
tempData[ddInstance.stage.id] = ddInstance.stage
|
||||||
tempData[ddInstance.stage.id] = ddInstance.stage
|
let layers = [];
|
||||||
let layers = [];
|
jsonData.layers.forEach(layer => {
|
||||||
jsonData.layers.forEach(layer => {
|
let model = DDeiLayer.loadFromJSON(layer, tempData);
|
||||||
let model = DDeiLayer.loadFromJSON(layer, tempData);
|
layers.push(model);
|
||||||
layers.push(model);
|
})
|
||||||
})
|
ddInstance.stage.idIdx = jsonData.idIdx;
|
||||||
ddInstance.stage.idIdx = jsonData.idIdx;
|
ddInstance.stage.layers = layers
|
||||||
ddInstance.stage.layers = layers
|
ddInstance.stage.initRender();
|
||||||
ddInstance.stage.initRender();
|
//渲染图形
|
||||||
//渲染图形
|
ddInstance.bus.push(DDeiEnumBusCommandType.RefreshShape, null, evt);
|
||||||
ddInstance.bus.push(DDeiEnumBusCommandType.RefreshShape, null, evt);
|
ddInstance.bus.push(DDeiEditorEnumBusCommandType.RefreshEditorParts)
|
||||||
ddInstance.bus.push(DDeiEditorEnumBusCommandType.RefreshEditorParts)
|
ddInstance.bus.executeAll();
|
||||||
ddInstance.bus.executeAll();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -60,209 +60,231 @@ class DDeiKeyActionStartQuickEdit extends DDeiKeyAction {
|
|||||||
return DDeiKeyActionStartQuickEdit;
|
return DDeiKeyActionStartQuickEdit;
|
||||||
}
|
}
|
||||||
// ============================ 方法 ===============================
|
// ============================ 方法 ===============================
|
||||||
action(evt: Event, ddInstance: DDei): void {
|
|
||||||
|
isActive(element: object): boolean {
|
||||||
|
if (!element) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if (element.tagName == 'BODY' || element.tagName == 'HEAD' || element.tagName == 'HTML') {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
action(evt: Event, ddInstance: DDei): boolean {
|
||||||
//获取当前编辑控件
|
//获取当前编辑控件
|
||||||
if (ddInstance.stage?.selectedModels?.size == 1) {
|
//修改当前操作控件坐标
|
||||||
let model = Array.from(ddInstance.stage?.selectedModels.values())[0]
|
if (ddInstance && ddInstance.stage) {
|
||||||
let editor = DDeiEditor.ACTIVE_INSTANCE;
|
//必须是canvas的子控件
|
||||||
if(editor.state == DDeiEditorState.DESIGNING){
|
if (this.isActive(document.activeElement)) {
|
||||||
let rsState1 = DDeiUtil.invokeCallbackFunc("EVENT_CONTROL_VIEW", DDeiEnumOperateType.VIEW, { models: [model] }, ddInstance, null)
|
if (ddInstance.stage?.selectedModels?.size == 1) {
|
||||||
if (rsState1 == 0 || rsState1 == 1) {
|
let model = Array.from(ddInstance.stage?.selectedModels.values())[0]
|
||||||
|
let editor = DDeiEditor.ACTIVE_INSTANCE;
|
||||||
let editState = DDeiUtil.invokeCallbackFunc("EVENT_CONTROL_EDIT_BEFORE", DDeiEnumOperateType.EDIT, { models: [model] }, ddInstance, null)
|
if(editor.state == DDeiEditorState.DESIGNING){
|
||||||
if (editState == 0 || editState== 1){
|
let rsState1 = DDeiUtil.invokeCallbackFunc("EVENT_CONTROL_VIEW", DDeiEnumOperateType.VIEW, { models: [model] }, ddInstance, null)
|
||||||
let stage = ddInstance.stage;
|
if (rsState1 == 0 || rsState1 == 1) {
|
||||||
let stageRatio = stage.getStageRatio()
|
|
||||||
if (model?.render) {
|
let editState = DDeiUtil.invokeCallbackFunc("EVENT_CONTROL_EDIT_BEFORE", DDeiEnumOperateType.EDIT, { models: [model] }, ddInstance, null)
|
||||||
let ex = -1;
|
if (editState == 0 || editState== 1){
|
||||||
let ey = -1;
|
let stage = ddInstance.stage;
|
||||||
if (evt.offsetX || evt.offsetY) {
|
let stageRatio = stage.getStageRatio()
|
||||||
ex = evt.offsetX
|
if (model?.render) {
|
||||||
ey = evt.offsetY
|
let ex = -1;
|
||||||
ex /= window.remRatio
|
let ey = -1;
|
||||||
ey /= window.remRatio
|
if (evt.offsetX || evt.offsetY) {
|
||||||
ex -= stage.wpv.x;
|
ex = evt.offsetX
|
||||||
ey -= stage.wpv.y;
|
ey = evt.offsetY
|
||||||
ex = ex / stageRatio
|
ex /= window.remRatio
|
||||||
ey = ey / stageRatio
|
ey /= window.remRatio
|
||||||
|
ex -= stage.wpv.x;
|
||||||
|
ey -= stage.wpv.y;
|
||||||
|
ex = ex / stageRatio
|
||||||
|
ey = ey / stageRatio
|
||||||
|
|
||||||
}
|
|
||||||
if (model.baseModelType == 'DDeiTable') {
|
|
||||||
let selectCells = model.getSelectedCells();
|
|
||||||
if (selectCells?.length == 1) {
|
|
||||||
model = selectCells[0];
|
|
||||||
editor.quickEditorModel = model;
|
|
||||||
} else {
|
|
||||||
editor.quickEditorModel = null;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else if (model.baseModelType == 'DDeiLine') {
|
|
||||||
//计算事件发生在线的哪个位置,键盘为中间,鼠标则需要判断位置
|
|
||||||
let type = 3;
|
|
||||||
let linePoint = null;
|
|
||||||
//鼠标事件
|
|
||||||
if (evt.offsetX || evt.offsetY) {
|
|
||||||
let cdist = DDeiUtil.getPointDistance(model.pvs[0].x, model.pvs[1].y, model.pvs[model.pvs.length - 1].x, model.pvs[model.pvs.length - 1].y);
|
|
||||||
let sdist = DDeiUtil.getPointDistance(ex, ey, model.pvs[0].x, model.pvs[0].y);
|
|
||||||
let edist = DDeiUtil.getPointDistance(ex, ey, model.pvs[model.pvs.length - 1].x, model.pvs[model.pvs.length - 1].y);
|
|
||||||
//开始
|
|
||||||
if (sdist < cdist / 5) {
|
|
||||||
type = 1;
|
|
||||||
}
|
}
|
||||||
//结束
|
if (model.baseModelType == 'DDeiTable') {
|
||||||
else if (edist < cdist / 5) {
|
let selectCells = model.getSelectedCells();
|
||||||
type = 2;
|
if (selectCells?.length == 1) {
|
||||||
}
|
model = selectCells[0];
|
||||||
}
|
editor.quickEditorModel = model;
|
||||||
if (type == 1) {
|
} else {
|
||||||
linePoint = model.startPoint;
|
editor.quickEditorModel = null;
|
||||||
}
|
return;
|
||||||
else if (type == 2) {
|
|
||||||
linePoint = model.endPoint;
|
|
||||||
}
|
|
||||||
else if (type == 3) {
|
|
||||||
//奇数,取正中间
|
|
||||||
let pi = Math.floor(model.pvs.length / 2)
|
|
||||||
if (model.pvs.length % 3 == 0) {
|
|
||||||
linePoint = model.pvs[pi];
|
|
||||||
}
|
|
||||||
//偶数,取两边的中间点
|
|
||||||
else {
|
|
||||||
linePoint = {
|
|
||||||
x: (model.pvs[pi - 1].x + model.pvs[pi].x) / 2,
|
|
||||||
y: (model.pvs[pi - 1].y + model.pvs[pi].y) / 2
|
|
||||||
}
|
}
|
||||||
|
} else if (model.baseModelType == 'DDeiLine') {
|
||||||
|
//计算事件发生在线的哪个位置,键盘为中间,鼠标则需要判断位置
|
||||||
|
let type = 3;
|
||||||
|
let linePoint = null;
|
||||||
|
//鼠标事件
|
||||||
|
if (evt.offsetX || evt.offsetY) {
|
||||||
|
let cdist = DDeiUtil.getPointDistance(model.pvs[0].x, model.pvs[1].y, model.pvs[model.pvs.length - 1].x, model.pvs[model.pvs.length - 1].y);
|
||||||
|
let sdist = DDeiUtil.getPointDistance(ex, ey, model.pvs[0].x, model.pvs[0].y);
|
||||||
|
let edist = DDeiUtil.getPointDistance(ex, ey, model.pvs[model.pvs.length - 1].x, model.pvs[model.pvs.length - 1].y);
|
||||||
|
//开始
|
||||||
|
if (sdist < cdist / 5) {
|
||||||
|
type = 1;
|
||||||
|
}
|
||||||
|
//结束
|
||||||
|
else if (edist < cdist / 5) {
|
||||||
|
type = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (type == 1) {
|
||||||
|
linePoint = model.startPoint;
|
||||||
|
}
|
||||||
|
else if (type == 2) {
|
||||||
|
linePoint = model.endPoint;
|
||||||
|
}
|
||||||
|
else if (type == 3) {
|
||||||
|
//奇数,取正中间
|
||||||
|
let pi = Math.floor(model.pvs.length / 2)
|
||||||
|
if (model.pvs.length % 3 == 0) {
|
||||||
|
linePoint = model.pvs[pi];
|
||||||
|
}
|
||||||
|
//偶数,取两边的中间点
|
||||||
|
else {
|
||||||
|
linePoint = {
|
||||||
|
x: (model.pvs[pi - 1].x + model.pvs[pi].x) / 2,
|
||||||
|
y: (model.pvs[pi - 1].y + model.pvs[pi].y) / 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let realModel = null;
|
||||||
|
|
||||||
|
model.linkModels.forEach(lm => {
|
||||||
|
if (lm.type == type) {
|
||||||
|
realModel = lm.dm;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//如果控件不存在,则创建控件并创建链接
|
||||||
|
if (!realModel) {
|
||||||
|
|
||||||
|
//根据control的定义,初始化临时控件,并推送至上层Editor
|
||||||
|
let dataJson = {
|
||||||
|
|
||||||
|
modelCode: "100200",
|
||||||
|
|
||||||
|
};
|
||||||
|
let controlDefine = DDeiUtil.getControlDefine(dataJson)
|
||||||
|
for (let i in controlDefine?.define) {
|
||||||
|
dataJson[i] = controlDefine.define[i];
|
||||||
|
}
|
||||||
|
dataJson["id"] = "lsm_" + (stage.idIdx++)
|
||||||
|
dataJson["width"] = 80
|
||||||
|
dataJson["height"] = 25
|
||||||
|
dataJson["font"] = { size: 12 }
|
||||||
|
realModel = ddInstance.controlModelClasses["DDeiPolygon"].initByJSON(
|
||||||
|
dataJson,
|
||||||
|
{ currentStage: stage, currentDdInstance: ddInstance, currentContainer: model.pModel }
|
||||||
|
);
|
||||||
|
let move1Matrix = new Matrix3(
|
||||||
|
1, 0, linePoint.x,
|
||||||
|
0, 1, linePoint.y,
|
||||||
|
0, 0, 1);
|
||||||
|
realModel.transVectors(move1Matrix)
|
||||||
|
model.layer.addModel(realModel);
|
||||||
|
|
||||||
|
realModel.initRender()
|
||||||
|
let lineLink = new DDeiLineLink({
|
||||||
|
line: model,
|
||||||
|
type: type,
|
||||||
|
dm: realModel,
|
||||||
|
dx: 0,
|
||||||
|
dy: 0
|
||||||
|
})
|
||||||
|
model.linkModels.set(realModel.id, lineLink);
|
||||||
|
}
|
||||||
|
model = realModel;
|
||||||
|
editor.quickEditorModel = model;
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取控件所占区域
|
||||||
|
//判断控件是否有composes,如果被composes拦截了,则启用componses的编辑
|
||||||
|
model = DDeiAbstractShape.findBottomComponseByArea(model, ex, ey);
|
||||||
|
|
||||||
|
let fillArea = model.textArea
|
||||||
|
|
||||||
|
if (fillArea?.length > 0) {
|
||||||
|
editor.quickEditorModel = model;
|
||||||
|
let canvasPos = DDeiUtil.getDomAbsPosition(ddInstance.render.canvas);
|
||||||
|
//创建大文本框
|
||||||
|
let inputEle = DDeiUtil.getEditorText();
|
||||||
|
let rotate = model.rotate
|
||||||
|
let stageRatio = ddInstance.stage.getStageRatio();
|
||||||
|
let pos = new Vector3(model.pvs[0].x, model.pvs[0].y, 1)
|
||||||
|
if (rotate != 0) {
|
||||||
|
let pvc = new Vector3(model.cpv.x, model.cpv.y, 1);
|
||||||
|
let angle = (rotate * DDeiConfig.ROTATE_UNIT).toFixed(4);
|
||||||
|
//计算input的正确打开位置,由节点0
|
||||||
|
let move1Matrix = new Matrix3(
|
||||||
|
1, 0, -pvc.x,
|
||||||
|
0, 1, -pvc.y,
|
||||||
|
0, 0, 1);
|
||||||
|
let rotateMatrix = new Matrix3(
|
||||||
|
Math.cos(angle), Math.sin(angle), 0,
|
||||||
|
-Math.sin(angle), Math.cos(angle), 0,
|
||||||
|
0, 0, 1);
|
||||||
|
let move2Matrix = new Matrix3(
|
||||||
|
1, 0, pvc.x,
|
||||||
|
0, 1, pvc.y,
|
||||||
|
0, 0, 1);
|
||||||
|
let m1 = new Matrix3().premultiply(move1Matrix).premultiply(rotateMatrix).premultiply(move2Matrix);
|
||||||
|
pos.applyMatrix3(m1)
|
||||||
|
}
|
||||||
|
|
||||||
|
inputEle.value = model.text ? model.text : ''
|
||||||
|
inputEle.style.fontSize = (model.render.getCachedValue("font.size") * stageRatio) + "px"
|
||||||
|
inputEle.style.color = DDeiUtil.getColor(model.render.getCachedValue("font.color"))
|
||||||
|
inputEle.style.width = (fillArea.width) * stageRatio + "px";
|
||||||
|
inputEle.style.height = (fillArea.height) * stageRatio + "px";
|
||||||
|
|
||||||
|
|
||||||
|
inputEle.style.left = canvasPos.left + pos.x + ddInstance.stage.wpv.x + 1 + "px";
|
||||||
|
inputEle.style.top = canvasPos.top + pos.y + ddInstance.stage.wpv.y + 10 + "px";
|
||||||
|
// inputEle.style.transform = "rotate(" + rotate + "deg)";
|
||||||
|
// inputEle.style.backgroundColor = "grey"
|
||||||
|
inputEle.style.display = "block";
|
||||||
|
|
||||||
|
let textAreaRect = DDeiAbstractShape.pvsToOutRect(model.textArea);
|
||||||
|
inputEle.style.width = textAreaRect.width + "px"
|
||||||
|
inputEle.style.height = textAreaRect.height + "px"
|
||||||
|
//创建编辑影子元素
|
||||||
|
ddInstance.stage.render.editorShadowControl = DDeiUtil.getShadowControl(model);
|
||||||
|
//清空当前opPoints
|
||||||
|
model.layer.opPoints = [];
|
||||||
|
if (model.layer.opLine?.render) {
|
||||||
|
model.layer.opLine.render.enableRefreshShape()
|
||||||
|
}
|
||||||
|
delete model.layer.opLine;
|
||||||
|
ddInstance.stage.render.editorShadowControl.render.isEditoring = true
|
||||||
|
inputEle.focus()
|
||||||
|
|
||||||
|
inputEle.selectionStart = 0 // 选中开始位置
|
||||||
|
inputEle.selectionEnd = inputEle.value.length // 获取输入框里的长度。
|
||||||
|
//修改编辑器状态为快捷编辑中
|
||||||
|
editor.changeState(DDeiEditorState.QUICK_EDITING);
|
||||||
|
delete ddInstance.stage.brushData
|
||||||
|
delete ddInstance.stage.brushDataText
|
||||||
|
ddInstance.stage.render.operateState = DDeiEnumOperateState.QUICK_EDITING
|
||||||
|
//发出通知,选中的焦点发生变化
|
||||||
|
editor.bus.push(DDeiEnumBusCommandType.StageChangeSelectModels);
|
||||||
|
editor.bus.push(DDeiEnumBusCommandType.TextEditorChangeSelectPos);
|
||||||
|
editor.bus.push(DDeiEditorEnumBusCommandType.ClearTemplateUI);
|
||||||
|
editor.bus.executeAll();
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let realModel = null;
|
|
||||||
|
|
||||||
model.linkModels.forEach(lm => {
|
|
||||||
if (lm.type == type) {
|
|
||||||
realModel = lm.dm;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
//如果控件不存在,则创建控件并创建链接
|
|
||||||
if (!realModel) {
|
|
||||||
|
|
||||||
//根据control的定义,初始化临时控件,并推送至上层Editor
|
|
||||||
let dataJson = {
|
|
||||||
|
|
||||||
modelCode: "100200",
|
|
||||||
|
|
||||||
};
|
|
||||||
let controlDefine = DDeiUtil.getControlDefine(dataJson)
|
|
||||||
for (let i in controlDefine?.define) {
|
|
||||||
dataJson[i] = controlDefine.define[i];
|
|
||||||
}
|
|
||||||
dataJson["id"] = "lsm_" + (stage.idIdx++)
|
|
||||||
dataJson["width"] = 80
|
|
||||||
dataJson["height"] = 25
|
|
||||||
dataJson["font"] = { size: 12 }
|
|
||||||
realModel = ddInstance.controlModelClasses["DDeiPolygon"].initByJSON(
|
|
||||||
dataJson,
|
|
||||||
{ currentStage: stage, currentDdInstance: ddInstance, currentContainer: model.pModel }
|
|
||||||
);
|
|
||||||
let move1Matrix = new Matrix3(
|
|
||||||
1, 0, linePoint.x,
|
|
||||||
0, 1, linePoint.y,
|
|
||||||
0, 0, 1);
|
|
||||||
realModel.transVectors(move1Matrix)
|
|
||||||
model.layer.addModel(realModel);
|
|
||||||
|
|
||||||
realModel.initRender()
|
|
||||||
let lineLink = new DDeiLineLink({
|
|
||||||
line: model,
|
|
||||||
type: type,
|
|
||||||
dm: realModel,
|
|
||||||
dx: 0,
|
|
||||||
dy: 0
|
|
||||||
})
|
|
||||||
model.linkModels.set(realModel.id, lineLink);
|
|
||||||
}
|
|
||||||
model = realModel;
|
|
||||||
editor.quickEditorModel = model;
|
|
||||||
}
|
|
||||||
|
|
||||||
//获取控件所占区域
|
|
||||||
//判断控件是否有composes,如果被composes拦截了,则启用componses的编辑
|
|
||||||
model = DDeiAbstractShape.findBottomComponseByArea(model, ex, ey);
|
|
||||||
|
|
||||||
let fillArea = model.textArea
|
|
||||||
|
|
||||||
if (fillArea?.length > 0) {
|
|
||||||
editor.quickEditorModel = model;
|
|
||||||
let canvasPos = DDeiUtil.getDomAbsPosition(ddInstance.render.canvas);
|
|
||||||
//创建大文本框
|
|
||||||
let inputEle = DDeiUtil.getEditorText();
|
|
||||||
let rotate = model.rotate
|
|
||||||
let stageRatio = ddInstance.stage.getStageRatio();
|
|
||||||
let pos = new Vector3(model.pvs[0].x, model.pvs[0].y, 1)
|
|
||||||
if (rotate != 0) {
|
|
||||||
let pvc = new Vector3(model.cpv.x, model.cpv.y, 1);
|
|
||||||
let angle = (rotate * DDeiConfig.ROTATE_UNIT).toFixed(4);
|
|
||||||
//计算input的正确打开位置,由节点0
|
|
||||||
let move1Matrix = new Matrix3(
|
|
||||||
1, 0, -pvc.x,
|
|
||||||
0, 1, -pvc.y,
|
|
||||||
0, 0, 1);
|
|
||||||
let rotateMatrix = new Matrix3(
|
|
||||||
Math.cos(angle), Math.sin(angle), 0,
|
|
||||||
-Math.sin(angle), Math.cos(angle), 0,
|
|
||||||
0, 0, 1);
|
|
||||||
let move2Matrix = new Matrix3(
|
|
||||||
1, 0, pvc.x,
|
|
||||||
0, 1, pvc.y,
|
|
||||||
0, 0, 1);
|
|
||||||
let m1 = new Matrix3().premultiply(move1Matrix).premultiply(rotateMatrix).premultiply(move2Matrix);
|
|
||||||
pos.applyMatrix3(m1)
|
|
||||||
}
|
|
||||||
|
|
||||||
inputEle.value = model.text ? model.text : ''
|
|
||||||
inputEle.style.fontSize = (model.render.getCachedValue("font.size") * stageRatio) + "px"
|
|
||||||
inputEle.style.color = DDeiUtil.getColor(model.render.getCachedValue("font.color"))
|
|
||||||
inputEle.style.width = (fillArea.width) * stageRatio + "px";
|
|
||||||
inputEle.style.height = (fillArea.height) * stageRatio + "px";
|
|
||||||
|
|
||||||
|
|
||||||
inputEle.style.left = canvasPos.left + pos.x + ddInstance.stage.wpv.x + 1 + "px";
|
|
||||||
inputEle.style.top = canvasPos.top + pos.y + ddInstance.stage.wpv.y + 10 + "px";
|
|
||||||
// inputEle.style.transform = "rotate(" + rotate + "deg)";
|
|
||||||
// inputEle.style.backgroundColor = "grey"
|
|
||||||
inputEle.style.display = "block";
|
|
||||||
|
|
||||||
let textAreaRect = DDeiAbstractShape.pvsToOutRect(model.textArea);
|
|
||||||
inputEle.style.width = textAreaRect.width + "px"
|
|
||||||
inputEle.style.height = textAreaRect.height + "px"
|
|
||||||
//创建编辑影子元素
|
|
||||||
ddInstance.stage.render.editorShadowControl = DDeiUtil.getShadowControl(model);
|
|
||||||
//清空当前opPoints
|
|
||||||
model.layer.opPoints = [];
|
|
||||||
if (model.layer.opLine?.render) {
|
|
||||||
model.layer.opLine.render.enableRefreshShape()
|
|
||||||
}
|
|
||||||
delete model.layer.opLine;
|
|
||||||
ddInstance.stage.render.editorShadowControl.render.isEditoring = true
|
|
||||||
inputEle.focus()
|
|
||||||
|
|
||||||
inputEle.selectionStart = 0 // 选中开始位置
|
|
||||||
inputEle.selectionEnd = inputEle.value.length // 获取输入框里的长度。
|
|
||||||
//修改编辑器状态为快捷编辑中
|
|
||||||
editor.changeState(DDeiEditorState.QUICK_EDITING);
|
|
||||||
delete ddInstance.stage.brushData
|
|
||||||
delete ddInstance.stage.brushDataText
|
|
||||||
ddInstance.stage.render.operateState = DDeiEnumOperateState.QUICK_EDITING
|
|
||||||
//发出通知,选中的焦点发生变化
|
|
||||||
editor.bus.push(DDeiEnumBusCommandType.StageChangeSelectModels);
|
|
||||||
editor.bus.push(DDeiEnumBusCommandType.TextEditorChangeSelectPos);
|
|
||||||
editor.bus.push(DDeiEditorEnumBusCommandType.ClearTemplateUI);
|
|
||||||
editor.bus.executeAll();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,9 +9,14 @@ class DDeiExtSearchLifeCycle extends DDeiLifeCycle {
|
|||||||
*/
|
*/
|
||||||
static defaultIns: DDeiExtSearchLifeCycle = new DDeiExtSearchLifeCycle(null);
|
static defaultIns: DDeiExtSearchLifeCycle = new DDeiExtSearchLifeCycle(null);
|
||||||
|
|
||||||
|
// static{
|
||||||
|
// DDeiExtSearchLifeCycle.changeQuickControlDialogPos = debounce(DDeiExtSearchLifeCycle.changeQuickControlDialogPos,200)
|
||||||
|
// }
|
||||||
|
|
||||||
EVENT_MOUSE_MOVE_IN_CONTROL: DDeiFuncData | null = new DDeiFuncData("quickcontrol-ext-show", 1, this.moveInControl);
|
EVENT_MOUSE_MOVE_IN_CONTROL: DDeiFuncData | null = new DDeiFuncData("quickcontrol-ext-show", 1, this.moveInControl);
|
||||||
|
|
||||||
|
EVENT_CONTROL_DRAG_AFTER: DDeiFuncData | null = new DDeiFuncData("quickcontrol-ext-changepos", 1, this.changeQuickControlDialogPos);
|
||||||
|
|
||||||
EVENT_MOUSE_MOVE_IN_LAYER: DDeiFuncData | null = new DDeiFuncData("quickcontrol-ext-close", 1, this.closeQuickControlDialog);
|
EVENT_MOUSE_MOVE_IN_LAYER: DDeiFuncData | null = new DDeiFuncData("quickcontrol-ext-close", 1, this.closeQuickControlDialog);
|
||||||
|
|
||||||
EVENT_CONTROL_SELECT_AFTER: DDeiFuncData | null = new DDeiFuncData("quickcontrol-ext-show", 1, this.closeAndShowQuickControlDialog);
|
EVENT_CONTROL_SELECT_AFTER: DDeiFuncData | null = new DDeiFuncData("quickcontrol-ext-show", 1, this.closeAndShowQuickControlDialog);
|
||||||
@ -43,6 +48,30 @@ class DDeiExtSearchLifeCycle extends DDeiLifeCycle {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
changeQuickControlDialogPos(operateType, data, ddInstance, evt) {
|
||||||
|
if (ddInstance && ddInstance["AC_DESIGN_EDIT"] && data?.models?.length > 0) {
|
||||||
|
|
||||||
|
let editor = DDeiEditorUtil.getEditorInsByDDei(ddInstance);
|
||||||
|
if (editor.state == 'designing') {
|
||||||
|
let model = data.models[0]
|
||||||
|
|
||||||
|
//如果存在选中控件,则重新定位到选中控件
|
||||||
|
if (editor.ddInstance.stage.selectedModels?.size > 0) {
|
||||||
|
if (!editor.ddInstance.stage.selectedModels.has(model.id)) {
|
||||||
|
if (editor.ddInstance.stage.selectedModels?.size == 1) {
|
||||||
|
model = Array.from(editor.ddInstance.stage.selectedModels.values())[0]
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
data.model = model
|
||||||
|
DDeiExtSearchLifeCycle.changeQuickControlDialogPos(operateType, data, ddInstance, evt)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 正在进行鼠标操作
|
* 正在进行鼠标操作
|
||||||
*/
|
*/
|
||||||
@ -83,7 +112,7 @@ class DDeiExtSearchLifeCycle extends DDeiLifeCycle {
|
|||||||
static showQuickControlDialog(operateType, data, ddInstance, evt): DDeiFuncCallResult {
|
static showQuickControlDialog(operateType, data, ddInstance, evt): DDeiFuncCallResult {
|
||||||
if (ddInstance && ddInstance["AC_DESIGN_EDIT"] && data?.model) {
|
if (ddInstance && ddInstance["AC_DESIGN_EDIT"] && data?.model) {
|
||||||
let editor = DDeiEditorUtil.getEditorInsByDDei(ddInstance);
|
let editor = DDeiEditorUtil.getEditorInsByDDei(ddInstance);
|
||||||
if (!data.model?.rotate && data.model?.baseModelType != 'DDeiLine' && (!editor.tempPopData || !editor.tempPopData['ddei-ext-dialog-quickcontrol'] || editor.tempPopData['ddei-ext-dialog-quickcontrol'].model != data.model)){
|
if (!data.model?.rotate && data.model?.baseModelType != 'DDeiLine' && (!editor.tempPopData || !editor.tempPopData['ddei-ext-dialog-quickcontrol'] || editor.tempPopData['ddei-ext-dialog-quickcontrol'].model != data.model)) {
|
||||||
//隐藏弹出框
|
//隐藏弹出框
|
||||||
DDeiEditorUtil.closeDialog(editor, 'ddei-ext-dialog-quickcontrol', true)
|
DDeiEditorUtil.closeDialog(editor, 'ddei-ext-dialog-quickcontrol', true)
|
||||||
DDeiEditorUtil.closeDialog(editor, 'ddei-ext-dialog-quickchoosecontrol', true)
|
DDeiEditorUtil.closeDialog(editor, 'ddei-ext-dialog-quickchoosecontrol', true)
|
||||||
@ -91,33 +120,70 @@ class DDeiExtSearchLifeCycle extends DDeiLifeCycle {
|
|||||||
let editorEle = document.getElementById(editor.id);
|
let editorEle = document.getElementById(editor.id);
|
||||||
let editorDomPos = DDeiUtil.getDomAbsPosition(editorEle);
|
let editorDomPos = DDeiUtil.getDomAbsPosition(editorEle);
|
||||||
let modelPos = DDeiUtil.getModelsDomAbsPosition([data.model])
|
let modelPos = DDeiUtil.getModelsDomAbsPosition([data.model])
|
||||||
|
|
||||||
let stageRatio = ddInstance.stage.getStageRatio()
|
|
||||||
let width = 50
|
let width = 50
|
||||||
let height = 50
|
let height = 50
|
||||||
let left = modelPos.left - editorDomPos.left - width/2
|
let left = modelPos.left - editorDomPos.left - width / 2
|
||||||
let top = modelPos.top - editorDomPos.top - height/2
|
let top = modelPos.top - editorDomPos.top - height / 2
|
||||||
|
|
||||||
let offset = null
|
let offset = null
|
||||||
if (data.model.state == DDeiEnumControlState.SELECTED) {
|
if (data.model.state == DDeiEnumControlState.SELECTED) {
|
||||||
height = 70
|
height = 70
|
||||||
top-=20
|
top -= 20
|
||||||
offset = {
|
offset = {
|
||||||
'left': "margin-top:20px",
|
'left': "margin-top:20px",
|
||||||
'right': "margin-top:20px"
|
'right': "margin-top:20px"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DDeiEditorUtil.showDialog(editor, 'ddei-ext-dialog-quickcontrol', {
|
DDeiEditorUtil.showDialog(editor, 'ddei-ext-dialog-quickcontrol', {
|
||||||
group: "canvas-pop-quickcontrol",
|
group: "canvas-pop-quickcontrol",
|
||||||
model:data.model,
|
model: data.model,
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
offset:offset
|
offset: offset
|
||||||
}, { type: 99, left: left, top: top, ignoreOutSide:1, hiddenMask: true }, null, true, true)
|
}, { type: 99, left: left, top: top, ignoreOutSide: 1, hiddenMask: true }, null, true, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改坐标
|
||||||
|
*/
|
||||||
|
static changeQuickControlDialogPos(operateType, data, ddInstance, evt): DDeiFuncCallResult {
|
||||||
|
if (ddInstance && ddInstance["AC_DESIGN_EDIT"] && data?.model) {
|
||||||
|
let editor = DDeiEditorUtil.getEditorInsByDDei(ddInstance);
|
||||||
|
|
||||||
|
//显示弹出框
|
||||||
|
let editorEle = document.getElementById(editor.id);
|
||||||
|
let editorDomPos = DDeiUtil.getDomAbsPosition(editorEle);
|
||||||
|
let modelPos = DDeiUtil.getModelsDomAbsPosition([data.model])
|
||||||
|
|
||||||
|
let width = 50
|
||||||
|
let height = 50
|
||||||
|
let left = modelPos.left - editorDomPos.left - width / 2
|
||||||
|
let top = modelPos.top - editorDomPos.top - height / 2
|
||||||
|
|
||||||
|
let offset = null
|
||||||
|
if (data.model.state == DDeiEnumControlState.SELECTED) {
|
||||||
|
height = 70
|
||||||
|
top -= 20
|
||||||
|
offset = {
|
||||||
|
'left': "margin-top:20px",
|
||||||
|
'right': "margin-top:20px"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DDeiEditorUtil.displayDialog(editor, 'ddei-ext-dialog-quickcontrol', {
|
||||||
|
group: "canvas-pop-quickcontrol",
|
||||||
|
model: data.model,
|
||||||
|
width: width,
|
||||||
|
height: height,
|
||||||
|
offset: offset
|
||||||
|
}, { type: 99, left: left, top: top, ignoreOutSide: 1, hiddenMask: true }, null, true, true)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 鼠标进入画布
|
* 鼠标进入画布
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user