Browse Source

Fixed selection painting over text when in focusable popup.

pull/127/head
weisj 5 years ago
parent
commit
067df2a3da
  1. 6
      core/src/main/java/com/github/weisj/darklaf/ui/text/DarkFormattedTextFieldUI.java
  2. 12
      core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java
  3. 12
      core/src/main/java/javax/swing/text/DefaultHighlighterDark/DarkHighlightPainter.java

6
core/src/main/java/com/github/weisj/darklaf/ui/text/DarkFormattedTextFieldUI.java

@ -30,7 +30,6 @@ import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.plaf.ComponentUI;
import javax.swing.text.Document;
import java.awt.*;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.text.ParseException;
@ -57,11 +56,6 @@ public class DarkFormattedTextFieldUI extends DarkTextFieldUI implements Propert
super.installUI(c);
}
@Override
protected void paintBackground(final Graphics graphics) {
super.paintBackground(graphics);
}
@Override
public void propertyChange(final PropertyChangeEvent evt) {
super.propertyChange(evt);

12
core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java

@ -101,7 +101,9 @@ public abstract class DarkTextUI extends BasicTextUI implements PropertyChangeLi
editor.getClass().getName())) {
editor.setBorder(null);
}
editor.putClientProperty(KEY_ROUNDED_SELECTION, UIManager.getBoolean("TextComponent.roundedSelection"));
if (editor != null) {
editor.putClientProperty(KEY_ROUNDED_SELECTION, UIManager.getBoolean("TextComponent.roundedSelection"));
}
disabledColor = UIManager.getColor(getPropertyPrefix() + ".disabledBackground");
inactiveColor = UIManager.getColor(getPropertyPrefix() + ".inactiveBackground");
}
@ -151,13 +153,13 @@ public abstract class DarkTextUI extends BasicTextUI implements PropertyChangeLi
protected void paintBackground(final Graphics g) {
if (editor.isOpaque()) {
Container parent = editor.getParent();
if (parent != null) {
g.setColor(parent.getBackground());
}
if (DarkUIUtil.isInCell(editor)) {
g.setColor(getBackground(editor));
g.fillRect(0, 0, editor.getWidth(), editor.getHeight());
} else if (parent != null && parent.isOpaque()) {
g.setColor(parent.getBackground());
g.fillRect(0, 0, editor.getWidth(), editor.getHeight());
}
g.fillRect(0, 0, editor.getWidth(), editor.getHeight());
}
Border border = editor.getBorder();

12
core/src/main/java/javax/swing/text/DefaultHighlighterDark/DarkHighlightPainter.java

@ -195,9 +195,7 @@ public class DarkHighlightPainter extends DefaultHighlighter.DefaultHighlightPai
Shape dirtyShape = null;
Graphics2D g2d = (Graphics2D) g;
GraphicsContext context = GraphicsUtil.setupAAPainting(g2d);
Insets ins = c.getInsets();
g2d.setClip(ins.left, ins.top, c.getWidth() - ins.left - ins.right,
c.getHeight() - ins.top - ins.bottom);
if (getAlpha() < 1.0f) {
g2d.setComposite(getAlphaComposite());
}
@ -205,8 +203,9 @@ public class DarkHighlightPainter extends DefaultHighlighter.DefaultHighlightPai
dirtyShape = paintLayerImpl(g2d, offs0, offs1, c);
} catch (BadLocationException ignored) {
} finally {
context.restore();
context.restoreComposite();
}
/*
* To make sure the correct part of the highlight is actually painted we manually repaint
* after the selection has changed.
@ -292,15 +291,14 @@ public class DarkHighlightPainter extends DefaultHighlighter.DefaultHighlightPai
isSecondLastLine, isSecondLine, firstLineNotPainted, lastLineNotPainted);
} else {
// Should only render part of View.
//Start/End parts of selection
// Start/End parts of selection
if (posEnd.y == posStart.y) {
Rectangle rect = alloc;
if (originalWidth < 2 * arcSize && isRounded(c)) {
suppressRounded = true;
rect = new Rectangle(originalX, alloc.y, originalWidth, alloc.height);
}
paintSelection(g2d, c, rect, selectionStart, selectionEnd);
dirtyShape = alloc;
dirtyShape = paintSelection(g2d, c, rect, selectionStart, selectionEnd);
suppressRounded = false;
} else if (selectionStart) {
dirtyShape = paintSelectionStart(g2d, alloc, c, posStart, posOffs0, endBeforeStart, isSecondLastLine,

Loading…
Cancel
Save