Skip to content

Commit

Permalink
split selection tool into dedicated tools
Browse files Browse the repository at this point in the history
  • Loading branch information
lbalazscs committed Jan 10, 2025
1 parent 286f042 commit 085ed92
Show file tree
Hide file tree
Showing 34 changed files with 1,272 additions and 588 deletions.
6 changes: 3 additions & 3 deletions src/main/java/pixelitor/colors/FgBgColorSelector.java
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,9 @@ private void updateBgButtonColor(Color newColor) {
}

private void setupKeyboardShortcuts() {
GlobalEvents.registerHotKey('D', resetToDefaultAction);
GlobalEvents.registerHotKey('X', swapColorsAction);
GlobalEvents.registerHotKey('R', randomizeColorsAction);
GlobalEvents.registerHotkey('D', resetToDefaultAction);
GlobalEvents.registerHotkey('X', swapColorsAction);
GlobalEvents.registerHotkey('R', randomizeColorsAction);
}

public void maskEditingChanged(boolean maskEditing) {
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/pixelitor/filters/Kuwahara.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,9 @@ private static float rgbToBightness(int rgb) {
private static int hsvToRgb(float[] hsv) {
return Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]);
}

@Override
public boolean supportsGray() {
return false;
}
}
12 changes: 6 additions & 6 deletions src/main/java/pixelitor/gui/GlobalEvents.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 Laszlo Balazs-Csiki and Contributors
* Copyright 2025 Laszlo Balazs-Csiki and Contributors
*
* This file is part of Pixelitor. Pixelitor is free software: you
* can redistribute it and/or modify it under the terms of the GNU
Expand Down Expand Up @@ -103,11 +103,11 @@ private GlobalEvents() {
// Private constructor to prevent instantiation of utility class
}

public static void registerHotKey(char key, Action action) {
registerHotKey(key, action, false);
public static void registerHotkey(char key, Action action) {
registerHotkey(key, action, false);
}

private static void registerHotKey(char key, Action action, boolean caseSensitive) {
private static void registerHotkey(char key, Action action, boolean caseSensitive) {
if (!caseSensitive) {
assert Character.isUpperCase(key) : "Non-case-sensitive keys must be uppercase";

Expand Down Expand Up @@ -157,8 +157,8 @@ private static void configureFocusTraversal(KeyboardFocusManager keyboardFocusMa
}

private static void registerBrushSizeShortcuts() {
registerHotKey(']', INCREASE_BRUSH_SIZE_ACTION, true);
registerHotKey('[', DECREASE_BRUSH_SIZE_ACTION, true);
registerHotkey(']', INCREASE_BRUSH_SIZE_ACTION, true);
registerHotkey('[', DECREASE_BRUSH_SIZE_ACTION, true);
}

private static void keyPressed(KeyEvent e) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/pixelitor/selection/SelectionType.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import pixelitor.Composition;
import pixelitor.gui.View;
import pixelitor.layers.Drawable;
import pixelitor.tools.SelectionTool;
import pixelitor.tools.selection.MagicWandSelectionTool;
import pixelitor.tools.util.Drag;
import pixelitor.tools.util.PMouseEvent;
import pixelitor.utils.ImageUtils;
Expand Down Expand Up @@ -118,7 +118,7 @@ private Area selectPixelsInColorRange(PMouseEvent pm) {
x -= tx;
y -= ty;

int colorTolerance = SelectionTool.getTolerance();
int colorTolerance = MagicWandSelectionTool.getTolerance();

BufferedImage image = dr.getImage();
int imgHeight = image.getHeight();
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/pixelitor/tools/AbstractBrushTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ public abstract class AbstractBrushTool extends Tool {
private final BrushOutlinePainter brushPainter = new BrushOutlinePainter(DEFAULT_BRUSH_RADIUS);
private boolean brushPainted = false;

AbstractBrushTool(String name, char activationKey, String toolMessage,
AbstractBrushTool(String name, char hotKey, String toolMessage,
Cursor cursor, boolean supportsSymmetry) {
super(name, activationKey, toolMessage, cursor);
super(name, hotKey, toolMessage, cursor);
this.supportsSymmetry = supportsSymmetry;
if (supportsSymmetry) {
symmetryModel = new EnumComboBoxModel<>(Symmetry.class);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/pixelitor/tools/BlendingModeBrushTool.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 Laszlo Balazs-Csiki and Contributors
* Copyright 2025 Laszlo Balazs-Csiki and Contributors
*
* This file is part of Pixelitor. Pixelitor is free software: you
* can redistribute it and/or modify it under the terms of the GNU
Expand Down Expand Up @@ -37,9 +37,9 @@ public abstract class BlendingModeBrushTool extends AbstractBrushTool {
private BlendingModePanel blendingModePanel;
private boolean maskEditing;

protected BlendingModeBrushTool(String name, char activationKey, String toolMessage,
protected BlendingModeBrushTool(String name, char hotKey, String toolMessage,
Cursor cursor, boolean addSymmetry) {
super(name, activationKey, toolMessage, cursor, addSymmetry);
super(name, hotKey, toolMessage, cursor, addSymmetry);
drawTarget = DrawTarget.DIRECT;
maskEditing = false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/pixelitor/tools/DragTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ public abstract class DragTool extends Tool {
// of 45 degree angles when Shift is pressed
private final boolean shiftConstrains;

protected DragTool(String name, char activationKey, String toolMessage,
protected DragTool(String name, char hotKey, String toolMessage,
Cursor cursor, boolean shiftConstrains) {

super(name, activationKey, toolMessage, cursor);
super(name, hotKey, toolMessage, cursor);

this.shiftConstrains = shiftConstrains;
}
Expand Down
Loading

0 comments on commit 085ed92

Please sign in to comment.