1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-11-12 20:35:09 -05:00

Fix various Dark Mode issues

This commit is contained in:
Reinhard Pointner 2019-02-28 01:42:26 +07:00
parent 35f8317fd3
commit 8854b6707d
17 changed files with 90 additions and 54 deletions

View File

@ -63,7 +63,7 @@ public abstract class AbstractSearchPanel<S, E> extends JComponent {
tabbedPaneGroup.setBorder(createTitledBorder("Search Results"));
tabbedPaneGroup.add(tabbedPane, "grow, wrap");
setLayout(new MigLayout("nogrid, novisualpadding, fill, insets 10px 10px 15px 10px", "align 45%", "[pref!]10px[fill]"));
setLayout(new MigLayout("nogrid, novisualpadding, fill, insets 10px 10px 15px 10px", "align 45%", "[center, pref!]10px[fill]"));
add(searchTextField, "gap 0px:push");
add(new JButton(searchAction), "gap 16px, gap after 0px:push, h 2+pref!, id search, sgy button");

View File

@ -1,6 +1,7 @@
package net.filebot.ui;
import java.awt.Color;
import static net.filebot.ui.ThemeSupport.*;
import java.awt.Font;
import java.net.URI;
import java.util.ArrayList;
@ -22,7 +23,7 @@ public class HistoryPanel extends JPanel {
public HistoryPanel() {
super(new MigLayout("fillx, insets 10 30 10 50, wrap 3"));
setBackground(Color.WHITE);
setBackground(getPanelBackground());
setOpaque(true);
setupHeader();

View File

@ -1,8 +1,9 @@
package net.filebot.ui;
import static javax.swing.BorderFactory.*;
import static net.filebot.Settings.*;
import static net.filebot.ui.ThemeSupport.*;
import java.awt.Color;
import java.awt.Component;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
@ -24,13 +25,13 @@ import javax.swing.border.EmptyBorder;
import javax.swing.border.LineBorder;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.plaf.basic.BasicButtonUI;
import javax.swing.plaf.basic.BasicComboBoxUI;
import javax.swing.plaf.basic.BasicComboPopup;
import javax.swing.plaf.basic.ComboPopup;
import javax.swing.text.JTextComponent;
import net.filebot.ResourceManager;
import net.filebot.Settings;
import net.filebot.util.ui.SelectButton;
import net.filebot.util.ui.SwingUI;
import net.miginfocom.swing.MigLayout;
@ -141,15 +142,20 @@ public class SelectButtonTextField<T> extends JComponent {
public void configureArrowButton() {
super.configureArrowButton();
arrowButton.setBackground(Color.white);
arrowButton.setOpaque(true);
arrowButton.setUI(new BasicButtonUI());
arrowButton.setBackground(getPanelBackground());
arrowButton.setOpaque(false);
arrowButton.setBorder(createEmptyBorder());
arrowButton.setContentAreaFilled(false);
arrowButton.setFocusPainted(false);
arrowButton.setFocusable(false);
if (getTheme().isDark()) {
arrowButton.setBorder(createEmptyBorder(0, 1, 0, 2));
}
// fix Aqua UI
if (Settings.isMacApp()) {
if (isMacApp()) {
arrowButton.setContentAreaFilled(true);
}
}

View File

@ -18,6 +18,7 @@ import com.bulenkov.iconloader.util.ColorUtil;
import net.filebot.util.SystemProperty;
import net.filebot.util.ui.GradientStyle;
import net.filebot.util.ui.SelectionPainter;
import net.filebot.util.ui.notification.SeparatorBorder;
import net.filebot.util.ui.notification.SeparatorBorder.Position;
@ -107,6 +108,12 @@ public class ThemeSupport {
UIManager.put("List.selectionBackground", selectionBackground);
UIManager.put("ComboBox.selectionBackground", selectionBackground);
UIManager.put("Table.selectionBackground", selectionBackground);
UIManager.put("Menu.selectionBackground", selectionBackground);
UIManager.put("MenuItem.selectionBackground", selectionBackground);
UIManager.put("MenuItem.selectedBackgroundPainter", new SelectionPainter(selectionBackground));
UIManager.put("PopupMenu.selectionBackground", selectionBackground);
UIManager.put("Tree.selectionBackground", selectionBackground);
UIManager.put("Tree.selectionInactiveBackground", selectionBackground);
UIManager.put("Table.background", componentBackground);
UIManager.put("TabbedPane.selected", componentBackground);
}

View File

@ -29,8 +29,6 @@ import javax.swing.SpinnerNumberModel;
import javax.swing.TransferHandler;
import javax.swing.border.Border;
import org.fife.ui.rsyntaxtextarea.RSyntaxDocument;
import org.fife.ui.rsyntaxtextarea.SyntaxConstants;
import org.fife.ui.rtextarea.RTextScrollPane;
import com.google.common.eventbus.Subscribe;
@ -56,7 +54,7 @@ public class ListPanel extends JComponent {
public static final String DEFAULT_FILE_FORMAT = "{fn}";
public static final String DEFAULT_EPISODE_FORMAT = "{n} - {s00e00} - [{absolute}] - [{airdate}] - {t}";
private FormatExpressionTextArea editor = new FormatExpressionTextArea(new RSyntaxDocument(SyntaxConstants.SYNTAX_STYLE_GROOVY));
private FormatExpressionTextArea editor = new FormatExpressionTextArea();
private SpinnerNumberModel fromSpinnerModel = new SpinnerNumberModel(1, 0, Integer.MAX_VALUE, 1);
private SpinnerNumberModel toSpinnerModel = new SpinnerNumberModel(20, 0, Integer.MAX_VALUE, 1);

View File

@ -54,7 +54,7 @@ public class SfvPanel extends JComponent {
public SfvPanel() {
table.setTransferHandler(new DefaultTransferHandler(transferablePolicy, exportHandler));
JPanel contentPane = new JPanel(new MigLayout("insets 0, nogrid, novisualpadding, fill", "", "[fill]10px[bottom, pref!]4px"));
JPanel contentPane = new JPanel(new MigLayout("insets 0, nogrid, novisualpadding, fill", "", "[fill]10px[center, pref!]4px"));
contentPane.setBorder(new TitledBorder("SFV"));
setLayout(new MigLayout("insets dialog, fill"));

View File

@ -1,8 +1,8 @@
package net.filebot.ui.subtitle;
import static javax.swing.BorderFactory.*;
import static net.filebot.ui.ThemeSupport.*;
import java.awt.Color;
import java.awt.Rectangle;
import javax.swing.Icon;
@ -57,11 +57,11 @@ public class SimpleComboBox extends JComboBox {
super.configurePopup();
setOpaque(true);
list.setBackground(Color.white);
setBackground(Color.white);
setBackground(getPanelBackground());
list.setBackground(getBackground());
// use gray instead of black border for combobox popup
setBorder(createCompoundBorder(createLineBorder(Color.gray, 1), createEmptyBorder(1, 1, 1, 1)));
setBorder(createCompoundBorder(createLineBorder(getColor(0xEEEEEE), 1), createEmptyBorder(1, 1, 1, 1)));
}
};
}

View File

@ -5,6 +5,7 @@ import static javax.swing.JOptionPane.*;
import static net.filebot.Logging.*;
import static net.filebot.Settings.*;
import static net.filebot.subtitle.SubtitleUtilities.*;
import static net.filebot.ui.ThemeSupport.*;
import static net.filebot.util.FileUtilities.*;
import static net.filebot.util.ui.SwingUI.*;
@ -125,7 +126,7 @@ class SubtitleAutoMatchDialog extends JDialog {
table.setRowHeight(24);
table.setIntercellSpacing(new Dimension(5, 5));
table.setBackground(Color.white);
table.setBackground(getPanelBackground());
table.setAutoCreateRowSorter(true);
table.setFillsViewportHeight(true);
@ -359,7 +360,7 @@ class SubtitleAutoMatchDialog extends JDialog {
private final JComboBox optionComboBox = new SimpleComboBox(ResourceManager.getIcon("action.select"));
public SubtitleMappingOptionRenderer() {
optionComboBox.setBackground(Color.white);
optionComboBox.setBackground(getPanelBackground());
optionComboBox.setRenderer(new SubtitleOptionRenderer(false));
}

View File

@ -4,6 +4,7 @@ import static net.filebot.Logging.*;
import static net.filebot.MediaTypes.*;
import static net.filebot.Settings.*;
import static net.filebot.UserFiles.*;
import static net.filebot.ui.ThemeSupport.*;
import static net.filebot.ui.transfer.FileTransferable.*;
import static net.filebot.util.FileUtilities.*;
import static net.filebot.util.ui.SwingUI.*;
@ -56,12 +57,16 @@ abstract class SubtitleDropTarget extends JButton {
public SubtitleDropTarget() {
setHorizontalAlignment(CENTER);
setHorizontalTextPosition(CENTER);
setVerticalAlignment(CENTER);
setVerticalTextPosition(TOP);
setIconTextGap(0);
setHideActionText(true);
setContentAreaFilled(false);
setFocusPainted(false);
setBorderPainted(false);
setBackground(Color.white);
setBackground(getPanelBackground());
// initialize with default mode
setDropAction(DropAction.Accept);
@ -74,18 +79,14 @@ abstract class SubtitleDropTarget extends JButton {
new DropTarget(this, dropHandler);
}
private Color lineColor = new Color(0xD7D7D7);
private Color lineColor = getColor(0xD7D7D7);
@Override
protected void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
float w = getWidth();
float h = getHeight();
float d = Math.min(w, h) - 1f;
Shape shape = new Ellipse2D.Float((w - d) / 2, (h - d) / 2, d - 1, d - 1);
Shape shape = new Ellipse2D.Float(0, 0, getWidth() - 1, getHeight() - 1);
g2d.setColor(getBackground());
g2d.fill(shape);

View File

@ -1,7 +1,8 @@
package net.filebot.ui.subtitle;
import java.awt.Color;
import static net.filebot.ui.ThemeSupport.*;
import java.awt.Insets;
import javax.swing.Icon;
@ -29,7 +30,7 @@ class SubtitlePackageCellRenderer extends AbstractFancyListCellRenderer {
add(languageLabel, "hidemode 3, w 85px!");
add(titleLabel);
setBorder(new CompoundBorder(new DashedSeparator(2, 4, Color.lightGray, Color.white), getBorder()));
setBorder(new CompoundBorder(new DashedSeparator(2, 4, getColor(0xEEEEEE), getPanelBackground()), getBorder()));
}
@Override

View File

@ -67,11 +67,11 @@ public class SubtitlePanel extends AbstractSearchPanel<SubtitleProvider, Subtitl
// add after text field
add(languageComboBox, "gap indent, sgy button", 1);
add(createImageButton(setUserAction), "w pref!, h 2+pref!, gap rel, sgy button", 2);
add(createImageButton(setUserAction), "gap rel, sgy button", 2);
// add at the top right corner
add(uploadDropTarget, "width 54px!, height 54px!, gap before unrel", 4);
add(downloadDropTarget, "width 54px!, height 54px!, gap before rel, gap after 10px", 5);
add(downloadDropTarget, "width 54px!, height 54px!, gap before 10px, gap after 10px", 5);
}
@Subscribe

View File

@ -97,7 +97,7 @@ public class SubtitleViewer extends JFrame {
private JTable createTable(TableModel model) {
final JTable table = new JTable(model);
table.setBackground(Color.white);
table.setBackground(getPanelBackground());
table.setAutoCreateRowSorter(true);
table.setFillsViewportHeight(true);
table.setRowHeight(18);

View File

@ -4,10 +4,10 @@ import static java.util.Collections.*;
import static java.util.stream.Collectors.*;
import static net.filebot.Logging.*;
import static net.filebot.media.MediaDetection.*;
import static net.filebot.ui.ThemeSupport.*;
import static net.filebot.util.FileUtilities.*;
import static net.filebot.util.ui.SwingUI.*;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Window;
import java.awt.event.ActionEvent;
@ -78,7 +78,7 @@ public class SubtitleUploadDialog extends JDialog {
table.setRowHeight(28);
table.setIntercellSpacing(new Dimension(5, 5));
table.setBackground(Color.white);
table.setBackground(getPanelBackground());
table.setAutoCreateRowSorter(true);
table.setFillsViewportHeight(true);

View File

@ -1,6 +1,7 @@
package net.filebot.util.ui;
import static net.filebot.ui.ThemeSupport.*;
import java.awt.Color;
import java.awt.Component;
@ -13,7 +14,6 @@ import javax.swing.Icon;
import javax.swing.JTree;
import javax.swing.tree.DefaultTreeCellRenderer;
public class FancyTreeCellRenderer extends DefaultTreeCellRenderer {
private Color gradientBeginColor;
@ -23,12 +23,10 @@ public class FancyTreeCellRenderer extends DefaultTreeCellRenderer {
private Color backgroundSelectionColor;
public FancyTreeCellRenderer() {
this(GradientStyle.TOP_TO_BOTTOM);
}
public FancyTreeCellRenderer(GradientStyle gradientStyle) {
this.gradientStyle = gradientStyle;
@ -38,14 +36,13 @@ public class FancyTreeCellRenderer extends DefaultTreeCellRenderer {
setBackgroundSelectionColor(null);
}
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, false);
setIconTextGap(5);
if (selected) {
if (selected && !getTheme().isDark()) {
setPaintGradient(true);
setGradientBeginColor(backgroundSelectionColor.brighter());
setGradientEndColor(backgroundSelectionColor);
@ -56,7 +53,6 @@ public class FancyTreeCellRenderer extends DefaultTreeCellRenderer {
return this;
}
@Override
protected void paintComponent(Graphics g) {
if (isPaintGradient()) {
@ -76,7 +72,6 @@ public class FancyTreeCellRenderer extends DefaultTreeCellRenderer {
super.paintComponent(g);
}
protected int getLabelStart() {
Icon icon = getIcon();
@ -87,42 +82,34 @@ public class FancyTreeCellRenderer extends DefaultTreeCellRenderer {
return 0;
}
public Color getGradientBeginColor() {
return gradientBeginColor;
}
public void setGradientBeginColor(Color gradientBeginColor) {
this.gradientBeginColor = gradientBeginColor;
}
public boolean isPaintGradient() {
return paintGradient;
}
public void setPaintGradient(boolean gradientEnabled) {
this.paintGradient = gradientEnabled;
}
public Color getGradientEndColor() {
return gradientEndColor;
}
public void setGradientEndColor(Color gradientEndColor) {
this.gradientEndColor = gradientEndColor;
}
public GradientStyle getGradientStyle() {
return gradientStyle;
}
public void setGradientStyle(GradientStyle gradientStyle) {
this.gradientStyle = gradientStyle;
}

View File

@ -1,6 +1,7 @@
package net.filebot.util.ui;
import static javax.swing.BorderFactory.*;
import static net.filebot.ui.ThemeSupport.*;
import java.awt.Color;
import java.awt.Component;
@ -32,11 +33,11 @@ public class SelectButton<T> extends JButton {
public static final String SELECTED_VALUE = "selected value";
private final Color beginColor = new Color(0xF0EEE4);
private final Color endColor = new Color(0xE0DED4);
private final Color beginColor = getColor(0xF0EEE4);
private final Color endColor = getColor(0xE0DED4);
private final Color beginColorHover = beginColor;
private final Color endColorHover = new Color(0xD8D7CD);
private final Color endColorHover = getColor(0xD8D7CD);
private final SelectIcon selectIcon = new SelectIcon();
@ -56,7 +57,7 @@ public class SelectButton<T> extends JButton {
setHorizontalAlignment(SwingConstants.CENTER);
setVerticalAlignment(SwingConstants.CENTER);
setBorder(createLineBorder(new Color(0xA4A4A4), 1));
setBorder(createLineBorder(getColor(0xA4A4A4), 1));
setPreferredSize(new Dimension(32, 22));
addActionListener(new OpenPopupOnClick());

View File

@ -0,0 +1,33 @@
package net.filebot.util.ui;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Insets;
import javax.swing.border.Border;
public class SelectionPainter implements Border {
private Color color;
public SelectionPainter(Color color) {
this.color = color;
}
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
g.setColor(color);
g.fillRect(x, y, width, height);
}
@Override
public boolean isBorderOpaque() {
return true;
}
@Override
public Insets getBorderInsets(Component c) {
return new Insets(0, 0, 0, 0);
}
}

View File

@ -5,10 +5,10 @@
package net.filebot.util.ui.notification;
import static javax.swing.BorderFactory.*;
import static net.filebot.ui.ThemeSupport.*;
import static net.filebot.util.ui.SwingUI.*;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Font;
import java.awt.Window;
@ -34,7 +34,7 @@ public class MessageNotification extends NotificationWindow {
private int margin = 10;
private Border marginBorder = createEmptyBorder(margin, margin, margin, margin);
private Border border = createCompoundBorder(createEtchedBorder(new Color(245, 155, 15), Color.WHITE), marginBorder);
private Border border = createCompoundBorder(createEtchedBorder(getColor(0xF59B0F), getPanelBackground()), marginBorder);
private JLabel headLabel;
private JTextPane textArea;
@ -46,7 +46,7 @@ public class MessageNotification extends NotificationWindow {
JComponent c = (JComponent) getContentPane();
c.setLayout(new BorderLayout(5, 2));
c.setBackground(Color.WHITE);
c.setBackground(getPanelBackground());
c.setBorder(border);
JPanel textPanel = new JPanel(new BorderLayout());