Life restriction that prevents drawing inside a selection on mirrored Layers

This commit is contained in:
Igor Zinken
2025-03-15 19:20:03 +01:00
parent c8b8826216
commit 8c99aa2e41
3 changed files with 4 additions and 11 deletions

View File

@@ -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 [
{

View File

@@ -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

View File

@@ -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;