Skip to content

Commit

Permalink
bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lbalazscs committed Apr 11, 2022
1 parent 0e402c9 commit 1a98f68
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 35 deletions.
13 changes: 8 additions & 5 deletions src/main/java/pixelitor/filters/ChannelInvert.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021 Laszlo Balazs-Csiki and Contributors
* Copyright 2022 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 All @@ -19,7 +19,6 @@

import pixelitor.filters.gui.IntChoiceParam;
import pixelitor.filters.gui.IntChoiceParam.Item;
import pixelitor.gui.GUIText;
import pixelitor.utils.ImageUtils;

import java.awt.Color;
Expand Down Expand Up @@ -54,9 +53,13 @@ public class ChannelInvert extends ParametrizedFilter {
private final Item[] invertChoices = {
new Item("Nothing", NOTHING),

new Item(GUIText.HUE, HUE_ONLY),
new Item(GUIText.SATURATION, SATURATION_ONLY),
new Item(GUIText.BRIGHTNESS, BRI_ONLY),
// new Item(GUIText.HUE, HUE_ONLY),
// new Item(GUIText.SATURATION, SATURATION_ONLY),
// new Item(GUIText.BRIGHTNESS, BRI_ONLY),

new Item("Hue", HUE_ONLY),
new Item("Saturation", SATURATION_ONLY),
new Item("Brightness", BRI_ONLY),

new Item("Hue and Saturation", HUE_SAT),
new Item("Hue and Brightness", HUE_BRI),
Expand Down
15 changes: 8 additions & 7 deletions src/main/java/pixelitor/filters/ChannelToTransparency.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,9 @@
import pixelitor.filters.gui.IntChoiceParam;
import pixelitor.filters.gui.IntChoiceParam.Item;
import pixelitor.filters.lookup.LuminanceLookup;
import pixelitor.gui.GUIText;

import java.awt.image.BufferedImage;

import static pixelitor.utils.Texts.i18n;

/**
* Makes pixels transparent proportionally to a channel value
*/
Expand All @@ -40,10 +37,14 @@ public class ChannelToTransparency extends ParametrizedFilter {
private static final int BLUE = 4;

private final IntChoiceParam channel = new IntChoiceParam("Channel", new Item[]{
new Item(GUIText.BRIGHTNESS, LUMINOSITY),
new Item(i18n("red"), RED),
new Item(i18n("green"), GREEN),
new Item(i18n("blue"), BLUE)
// new Item(GUIText.BRIGHTNESS, LUMINOSITY),
// new Item(i18n("red"), RED),
// new Item(i18n("green"), GREEN),
// new Item(i18n("blue"), BLUE)
new Item("Brightness", LUMINOSITY),
new Item("Red", RED),
new Item("Green", GREEN),
new Item("Blue", BLUE)
});
private final BooleanParam invertParam = new BooleanParam("Invert", false);
private final BooleanParam keepParam = new BooleanParam("Keep Existing Transparency", true);
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/pixelitor/filters/ShapeFilter.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021 Laszlo Balazs-Csiki and Contributors
* Copyright 2022 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 All @@ -24,7 +24,6 @@
import pixelitor.filters.gui.*;
import pixelitor.filters.gui.IntChoiceParam.Item;
import pixelitor.filters.painters.AreaEffects;
import pixelitor.gui.GUIText;
import pixelitor.io.IO;
import pixelitor.utils.ImageUtils;

Expand Down Expand Up @@ -64,14 +63,16 @@ public abstract class ShapeFilter extends ParametrizedFilter {
new Item("Black", BG_BLACK),
new Item("Original Image", BG_ORIGINAL),
new Item("Transparent", BG_TRANSPARENT),
new Item(GUIText.BG_COLOR, BG_TOOL),
// new Item(GUIText.BG_COLOR, BG_TOOL),
new Item("Background Color", BG_TOOL),
}, IGNORE_RANDOMIZE);

private final IntChoiceParam foreground = new IntChoiceParam("Foreground", new Item[]{
new Item("White", FG_WHITE),
new Item("Black", FG_BLACK),
new Item("Radial Gradient", FG_GRADIENT),
new Item(GUIText.FG_COLOR, FG_TOOL),
// new Item(GUIText.FG_COLOR, FG_TOOL),
new Item("Foreground Color", FG_TOOL),
new Item("Transparent", FG_TRANSPARENT),
}, IGNORE_RANDOMIZE);

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/pixelitor/filters/gui/FilterWithGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import pixelitor.gui.utils.DialogBuilder;
import pixelitor.layers.Drawable;
import pixelitor.menus.view.ZoomMenu;
import pixelitor.tools.Tools;

import javax.swing.*;
import java.io.Serial;
Expand Down Expand Up @@ -85,7 +86,7 @@ public String getHelpURL() {
public boolean startOn(Drawable dr, boolean reset) {
dr.startPreviewing();

// Tools.editingTargetChanged(dr.getLayer());
Tools.forceFinish();

FilterGUI gui = createGUI(dr, reset);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
* The GUI for "Mask from Color Range"
*/
public class MaskFromColorRangePanel extends JPanel {
private static final String NAME = "Mask from Color Range";
public static final String NAME = "Mask from Color Range";
private static final int DEFAULT_THUMB_SIZE = 512;
private static final String HELP_TEXT = "Select a color by clicking or dragging on the image";

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/pixelitor/menus/MenuBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ public void onActiveLayer(Layer layer) {
}
});

sub.add(new OpenViewEnabledAction("Add/Replace from Color Range...") {
sub.add(new OpenViewEnabledAction(MaskFromColorRangePanel.NAME + "...") {
@Override
protected void onClick() {
MaskFromColorRangePanel.showInDialog();
Expand All @@ -499,7 +499,7 @@ public void onActiveLayer(Layer layer) {
((ImageLayer) layer).applyLayerMask(true);

// not necessary, as the result looks the same, but still
// useful because eventual problems would be spotted early
// useful because bugs would be spotted early
layer.getComp().update();
}
});
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/pixelitor/tools/Tool.java
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,9 @@ public void editingTargetChanged(Layer layer) {
// empty by default
}

/**
* A modal dialog, such as a filter or the color selector, was shown.
*/
public void firstModalDialogShown() {
// empty by default
}
Expand Down
6 changes: 0 additions & 6 deletions src/main/java/pixelitor/tools/gradient/GradientTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -597,12 +597,6 @@ public boolean allowOnlyDrawables() {
return true;
}

@Override
public void firstModalDialogShown() {
// hide the handles when a filter with dialog starts
hideHandles(false);
}

@Override
public void saveStateTo(UserPreset preset) {
preset.put("Type", getType().toString());
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/pixelitor/tools/pen/SubPath.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package pixelitor.tools.pen;

import com.bric.geom.ShapeUtils;
import pixelitor.AppContext;
import pixelitor.Composition;
import pixelitor.gui.View;
import pixelitor.history.History;
Expand Down Expand Up @@ -119,7 +120,7 @@ public void addPoint(double x, double y) {
}

public void setMovingPoint(MovingPoint p) {
if (finished && p != null) {
if (finished && p != null && AppContext.isDevelopment()) {
throw new IllegalStateException();
}
moving = p;
Expand Down
7 changes: 0 additions & 7 deletions src/main/java/pixelitor/tools/shapes/ShapesTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -961,13 +961,6 @@ public String getStateInfo() {
+ ", state=" + state;
}

@Override
public void firstModalDialogShown() {
// Rasterize when a filter with dialog starts. This comes too
// late to influence the filter's image for an ImagePositionParam
rasterizeBox();
}

@Override
public DebugNode createDebugNode(String key) {
var node = super.createDebugNode(key);
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/pixelitor/guitest/AssertJSwingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ private void testMaskFromColorRange() {
}
log(1, "mask from color range");

runMenuCommand("Add/Replace from Color Range...");
runMenuCommand("Mask from Color Range...");

var dialog = findDialogByTitle("Mask from Color Range");

Expand Down

0 comments on commit 1a98f68

Please sign in to comment.