Fix subtitle upload/download drop target looks
This commit is contained in:
parent
754a473316
commit
1fab52dbd0
|
@ -65,8 +65,8 @@ public abstract class AbstractSearchPanel<S, E> extends JComponent {
|
|||
tabbedPaneGroup.add(tabbedPane, "grow, wrap");
|
||||
setLayout(new MigLayout("nogrid, novisualpadding, fill, insets 10px 10px 15px 10px", "align 45%", "[pref!]10px[fill]"));
|
||||
|
||||
add(searchTextField);
|
||||
add(new JButton(searchAction), "gap 16px, h 2+pref!, id search, sgy button");
|
||||
add(searchTextField, "gap 0px:push");
|
||||
add(new JButton(searchAction), "gap 16px, gap after 0px:push, h 2+pref!, id search, sgy button");
|
||||
add(tabbedPaneGroup, "newline, grow");
|
||||
|
||||
searchTextField.getEditor().setAction(searchAction);
|
||||
|
|
|
@ -10,6 +10,10 @@ import static net.filebot.util.ui.SwingUI.*;
|
|||
|
||||
import java.awt.Color;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.Shape;
|
||||
import java.awt.dnd.DnDConstants;
|
||||
import java.awt.dnd.DropTarget;
|
||||
import java.awt.dnd.DropTargetAdapter;
|
||||
|
@ -18,6 +22,7 @@ import java.awt.dnd.DropTargetDropEvent;
|
|||
import java.awt.dnd.DropTargetEvent;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.geom.Ellipse2D;
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
|
@ -37,6 +42,7 @@ import net.filebot.ResourceManager;
|
|||
import net.filebot.platform.mac.MacAppUtilities;
|
||||
import net.filebot.ui.subtitle.upload.SubtitleUploadDialog;
|
||||
import net.filebot.util.FileUtilities;
|
||||
import net.filebot.util.FileUtilities.ExtensionFileFilter;
|
||||
import net.filebot.util.FileUtilities.ParentFilter;
|
||||
import net.filebot.web.OpenSubtitlesClient;
|
||||
import net.filebot.web.SubtitleProvider;
|
||||
|
@ -52,12 +58,10 @@ abstract class SubtitleDropTarget extends JButton {
|
|||
setHorizontalAlignment(CENTER);
|
||||
|
||||
setHideActionText(true);
|
||||
setBorderPainted(false);
|
||||
setContentAreaFilled(false);
|
||||
setFocusPainted(false);
|
||||
|
||||
setBorderPainted(false);
|
||||
setBackground(Color.white);
|
||||
setOpaque(false);
|
||||
|
||||
// initialize with default mode
|
||||
setDropAction(DropAction.Accept);
|
||||
|
@ -70,6 +74,28 @@ abstract class SubtitleDropTarget extends JButton {
|
|||
new DropTarget(this, dropHandler);
|
||||
}
|
||||
|
||||
private Color lineColor = new Color(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);
|
||||
|
||||
g2d.setColor(getBackground());
|
||||
g2d.fill(shape);
|
||||
|
||||
g2d.setColor(lineColor);
|
||||
g2d.draw(shape);
|
||||
|
||||
super.paintComponent(g2d);
|
||||
}
|
||||
|
||||
protected void setDropAction(DropAction dropAction) {
|
||||
setIcon(getIcon(dropAction));
|
||||
}
|
||||
|
|
|
@ -6,15 +6,10 @@ import static net.filebot.ui.LanguageComboBoxModel.*;
|
|||
import static net.filebot.util.FileUtilities.*;
|
||||
import static net.filebot.util.ui.SwingUI.*;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.Dialog.ModalityType;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.datatransfer.Transferable;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.geom.Path2D;
|
||||
import java.io.File;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
|
@ -76,8 +71,8 @@ public class SubtitlePanel extends AbstractSearchPanel<SubtitleProvider, Subtitl
|
|||
add(createImageButton(setUserAction), "w pref!, h 2+pref!, gap rel, sgy button", 2);
|
||||
|
||||
// add at the top right corner
|
||||
add(uploadDropTarget, "width 50px!, height 40px!, pos n 0% 100%-60px n", 0);
|
||||
add(downloadDropTarget, "width 50px!, height 40px!, pos n 0% 100%-5px n", 0);
|
||||
add(uploadDropTarget, "width 54px!, height 54px!", 4);
|
||||
add(downloadDropTarget, "width 54px!, height 54px!, gap after 10px", 5);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
@ -96,30 +91,6 @@ public class SubtitlePanel extends AbstractSearchPanel<SubtitleProvider, Subtitl
|
|||
public OpenSubtitlesClient getSubtitleService() {
|
||||
return WebServices.OpenSubtitles;
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
Graphics2D g2d = (Graphics2D) g.create();
|
||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
|
||||
Path2D path = new Path2D.Float();
|
||||
path.moveTo(0, 0);
|
||||
path.lineTo(0, getHeight() - 1 - 12);
|
||||
path.lineTo(12, getHeight() - 1);
|
||||
path.lineTo(getWidth() - 1 - 12, getHeight() - 1);
|
||||
path.lineTo(getWidth() - 1, getHeight() - 1 - 12);
|
||||
path.lineTo(getWidth() - 1, 0);
|
||||
|
||||
g2d.setPaint(getBackground());
|
||||
g2d.fill(path);
|
||||
|
||||
g2d.setPaint(Color.gray);
|
||||
g2d.draw(path);
|
||||
|
||||
g2d.translate(2, 0);
|
||||
super.paintComponent(g2d);
|
||||
g2d.dispose();
|
||||
}
|
||||
};
|
||||
|
||||
private final SubtitleDropTarget downloadDropTarget = new SubtitleDropTarget.Download() {
|
||||
|
@ -148,30 +119,6 @@ public class SubtitlePanel extends AbstractSearchPanel<SubtitleProvider, Subtitl
|
|||
// use currently selected language for drop target
|
||||
return languageComboBox.getModel().getSelectedItem() == ALL_LANGUAGES ? null : languageComboBox.getModel().getSelectedItem().getLocale();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
Graphics2D g2d = (Graphics2D) g.create();
|
||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
|
||||
Path2D path = new Path2D.Float();
|
||||
path.moveTo(0, 0);
|
||||
path.lineTo(0, getHeight() - 1 - 12);
|
||||
path.lineTo(12, getHeight() - 1);
|
||||
path.lineTo(getWidth() - 1 - 12, getHeight() - 1);
|
||||
path.lineTo(getWidth() - 1, getHeight() - 1 - 12);
|
||||
path.lineTo(getWidth() - 1, 0);
|
||||
|
||||
g2d.setPaint(getBackground());
|
||||
g2d.fill(path);
|
||||
|
||||
g2d.setPaint(Color.gray);
|
||||
g2d.draw(path);
|
||||
|
||||
g2d.translate(2, 0);
|
||||
super.paintComponent(g2d);
|
||||
g2d.dispose();
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue