印花图层禁用画笔等工具

This commit is contained in:
李志鹏
2026-01-08 16:37:35 +08:00
parent 5bbc71654a
commit d863376b41
3 changed files with 39 additions and 20 deletions

View File

@@ -376,8 +376,8 @@ export class ToolManager {
// 设置工具特定的状态
const tool = this.tools[toolId];
if (tool && typeof tool.setup === "function") {
console.log(`画布切换工具:${tool.name}(${toolId})`)
this.canvas.toolId = toolId;
console.log(`画布切换工具:${tool.name}(${toolId})`)
this.canvas.toolId = toolId;
tool.setup();
}
@@ -458,11 +458,31 @@ export class ToolManager {
}
/**
* 检查当前工具是否禁止操作当前选中的对象
* @param {Boolean} isBrushTool 是否为画笔工具
* @returns {Boolean} 是否可以切换
*/
checkToolCanOperateSelectedObject(isBrushTool = false) {
const layer = this.layerManager?.getActiveLayer();
const isSpecialLayer = !!layer?.specialType;
if (isSpecialLayer) {
if(isBrushTool){
this._disableBrushIndicator();
}
this.canvas.defaultCursor = "not-allowed";
}
console.log("===========",isSpecialLayer, this.canvas.defaultCursor);
return isSpecialLayer;
}
/**
* 设置画笔工具
*/
setupBrushTool() {
if (!this.canvas) return;
if (this.checkToolCanOperateSelectedObject(true)) return;
this.canvas.isDrawingMode = true;
this.canvas.selection = false;
@@ -506,6 +526,8 @@ export class ToolManager {
*/
setupEraserTool() {
if (!this.canvas) return;
if (this.checkToolCanOperateSelectedObject(true)) return;
this.canvas.isDrawingMode = true;
this.canvas.selection = false;
@@ -654,6 +676,7 @@ export class ToolManager {
*/
setupLiquifyTool() {
if (!this.canvas || !this.layerManager) return;
if (this.checkToolCanOperateSelectedObject(true)) return;
this.canvas.isDrawingMode = false;
this.canvas.selection = false;