From 8c99aa2e41653f24e80b02740207ef920cdfe01c Mon Sep 17 00:00:00 2001 From: Igor Zinken <730069+igorski@users.noreply.github.com> Date: Sat, 15 Mar 2025 19:20:03 +0100 Subject: [PATCH] Life restriction that prevents drawing inside a selection on mirrored Layers --- src/components/toolbox/toolbox.vue | 5 ++--- src/definitions/tool-types.ts | 6 ------ src/rendering/canvas-elements/layer-sprite.ts | 4 ++-- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/components/toolbox/toolbox.vue b/src/components/toolbox/toolbox.vue index 5ec6fe4..c3a761d 100644 --- a/src/components/toolbox/toolbox.vue +++ b/src/components/toolbox/toolbox.vue @@ -103,7 +103,7 @@ import { LayerTypes } from "@/definitions/layer-types"; import { PANEL_TOOL_OPTIONS } from "@/definitions/panel-types"; import { isMobile } from "@/utils/environment-util"; import { addTextLayer } from "@/utils/layer-util"; -import ToolTypes, { canDraw, canDrawOnSelection } from "@/definitions/tool-types"; +import ToolTypes, { canDraw } from "@/definitions/tool-types"; import messages from "./messages.json"; type ToolDef = { @@ -148,8 +148,7 @@ export default { } }, tools(): ToolDef[] { - const canDrawOnContent = !!this.activeLayer && ( !this.hasSelection || canDrawOnSelection( this.activeLayer )); - const drawable = canDraw( this.activeDocument, this.activeLayer, this.activeLayerMask ) && canDrawOnContent; + const drawable = !!this.activeLayer && canDraw( this.activeDocument, this.activeLayer, this.activeLayerMask ); return [ { diff --git a/src/definitions/tool-types.ts b/src/definitions/tool-types.ts index debee2d..7b83452 100644 --- a/src/definitions/tool-types.ts +++ b/src/definitions/tool-types.ts @@ -57,12 +57,6 @@ export const canDraw = ( activeDocument: Document, activeLayer: Layer, activeLay (( !!activeLayer?.mask && activeLayer.mask === activeLayerMask ) || activeLayer?.type === LayerTypes.LAYER_GRAPHIC ); }; -// we cannot draw in selection if a layer is mirrored (see https://github.com/igorski/bitmappery/issues/5) -export const canDrawOnSelection = ( activeLayer: Layer ): boolean => { - const { effects } = activeLayer; - return !effects.mirrorX && !effects.mirrorY; -}; - export const TOOL_SRC_MERGED = "Merged"; // constant to define that a tools source context are all layers merged // UI variables diff --git a/src/rendering/canvas-elements/layer-sprite.ts b/src/rendering/canvas-elements/layer-sprite.ts index fb330fb..a2a2757 100644 --- a/src/rendering/canvas-elements/layer-sprite.ts +++ b/src/rendering/canvas-elements/layer-sprite.ts @@ -33,7 +33,7 @@ import { getSizeForBrush } from "@/definitions/brush-types"; import type { Document, Layer, Selection } from "@/definitions/document"; import type { CanvasContextPairing, CanvasDrawable, Brush, BrushToolOptions, BrushAction } from "@/definitions/editor"; import { LayerTypes } from "@/definitions/layer-types"; -import ToolTypes, { canDrawOnSelection, TOOL_SRC_MERGED } from "@/definitions/tool-types"; +import ToolTypes, { TOOL_SRC_MERGED } from "@/definitions/tool-types"; import { scaleRectangle, rotateRectangle } from "@/math/rectangle-math"; import { translatePointerRotation, rotatePointer } from "@/math/point-math"; import { fastRound } from "@/math/unit-math"; @@ -237,7 +237,7 @@ export default class LayerSprite extends ZoomableSprite { setSelection( document: Document, onlyWhenClosed = false ): void { const { activeSelection } = document; - if ( !onlyWhenClosed || ( isShapeClosed( getLastShape( activeSelection )) && canDrawOnSelection( this.layer ))) { + if ( !onlyWhenClosed || ( isShapeClosed( getLastShape( activeSelection )))) { this._selection = activeSelection?.length > 0 ? activeSelection : null; } else { this._selection = undefined;