mirror of
https://github.com/igorski/bitmappery.git
synced 2026-07-13 02:18:43 +02:00
Life restriction that prevents drawing inside a selection on mirrored Layers
This commit is contained in:
@@ -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 [
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user