Skip to content

Commit

Permalink
Merge remote-tracking branch 'slimbuck/brush-wheel-fixes' into mouse-…
Browse files Browse the repository at this point in the history
…wheel-brush-size
  • Loading branch information
simonbethke committed Nov 8, 2024
2 parents cd8413f + 5abebed commit f072c2d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 24 deletions.
24 changes: 2 additions & 22 deletions src/tools/brush-selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class BrushSelection {

const prev = { x: 0, y: 0 };
let dragId: number | undefined;
let wheelModeBrushSize = false;

const update = (e: PointerEvent) => {
const x = e.offsetX;
Expand Down Expand Up @@ -106,36 +105,20 @@ class BrushSelection {
};

const wheel = (e: WheelEvent) => {
if(wheelModeBrushSize){
if(e.deltaY > 0)
radius = Math.max(1, radius * 1.05);
else
radius = Math.max(1, radius / 1.05);
circle.setAttribute('r', radius.toString());
if (e.shiftKey && e.deltaX !== 0) {
events.fire(e.deltaX > 0 ? 'tool.brushSelection.smaller' : 'tool.brushSelection.bigger');
e.preventDefault();
e.stopPropagation();
}
};

const keydown = (e: KeyboardEvent) => {
if (e.shiftKey) {
wheelModeBrushSize = true;
}
};

const keyup = (e: KeyboardEvent) => {
wheelModeBrushSize = false;
};

this.activate = () => {
svg.style.display = 'inline';
parent.style.display = 'block';
parent.addEventListener('pointerdown', pointerdown);
parent.addEventListener('pointermove', pointermove);
parent.addEventListener('pointerup', pointerup);
parent.addEventListener('wheel', wheel);
document.addEventListener('keydown', keydown);
document.addEventListener('keyup', keyup);
};

this.deactivate = () => {
Expand All @@ -149,9 +132,6 @@ class BrushSelection {
parent.removeEventListener('pointermove', pointermove);
parent.removeEventListener('pointerup', pointerup);
parent.removeEventListener('wheel', wheel);
document.removeEventListener('keydown', keydown);
document.removeEventListener('keyup', keyup);
wheelModeBrushSize = false;
};

events.on('tool.brushSelection.smaller', () => {
Expand Down
7 changes: 5 additions & 2 deletions src/ui/color-panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,15 @@ class ColorPanel extends Container {
tintClr: selected.tintClr.clone(),
brightness: selected.brightness,
blackPoint: selected.blackPoint,
whitePoint: selected.whitePoint
whitePoint: selected.whitePoint,
transparency: selected.transparency
},
oldState: {
tintClr: selected.tintClr.clone(),
brightness: selected.brightness,
blackPoint: selected.blackPoint,
whitePoint: selected.whitePoint
whitePoint: selected.whitePoint,
transparency: selected.transparency
}
});
}
Expand All @@ -233,6 +235,7 @@ class ColorPanel extends Container {
newState.brightness = brightnessSlider.value;
newState.blackPoint = blackPointSlider.value;
newState.whitePoint = whitePointSlider.value;
newState.transparency = Math.exp(transparencySlider.value);
events.fire('edit.add', op);
op = null;
}
Expand Down

0 comments on commit f072c2d

Please sign in to comment.