Browse Source

Fixed incorrect popup background for undecorated popups.

pull/170/head
weisj 5 years ago
parent
commit
75af4e0dd7
  1. 15
      core/src/main/java/com/github/weisj/darklaf/ui/DarkPopupFactory.java
  2. 1
      core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkTooltipUI.java
  3. 2
      windows/src/main/cpp/Decorations.cpp

15
core/src/main/java/com/github/weisj/darklaf/ui/DarkPopupFactory.java

@ -30,6 +30,8 @@ import javax.swing.*;
import com.github.weisj.darklaf.platform.DecorationsHandler;
import com.github.weisj.darklaf.ui.rootpane.DarkRootPaneUI;
import com.github.weisj.darklaf.uiresource.DarkColorUIResource;
import com.github.weisj.darklaf.util.ColorUtil;
import com.github.weisj.darklaf.util.DarkUIUtil;
import com.github.weisj.darklaf.util.Pair;
import com.github.weisj.darklaf.util.PropertyUtil;
@ -95,13 +97,13 @@ public class DarkPopupFactory extends PopupFactory {
final boolean isFocusable, final boolean startHidden) {
boolean noDecorations = PropertyUtil.getBooleanProperty(contents, KEY_NO_DECORATION);
boolean opaque = PropertyUtil.getBooleanProperty(contents, KEY_OPAQUE);
setupWindowBackground(window, opaque);
setupWindowBackground(window, opaque, !noDecorations);
setupWindowFocusableState(isFocusable, window);
setupWindowDecorations(window, noDecorations);
setupWindowOpacity(contents, startHidden, window);
}
protected void setupWindowBackground(final Window window, final boolean opaque) {
protected void setupWindowBackground(final Window window, final boolean opaque, final boolean decorations) {
// Sometimes the background is java.awt.SystemColor[i=7]
// It results in a flash of white background, that is repainted with
// the proper popup background later.
@ -112,7 +114,8 @@ public class DarkPopupFactory extends PopupFactory {
if (opaque) {
window.setBackground(rootPane.getBackground());
} else {
window.setBackground(getTranslucentPopupBackground());
Color bg = getTranslucentPopupBackground(decorations);
window.setBackground(bg);
}
}
}
@ -154,8 +157,10 @@ public class DarkPopupFactory extends PopupFactory {
return heavyWeightParent;
}
protected Color getTranslucentPopupBackground() {
return UIManager.getColor("PopupMenu.translucentBackground");
protected Color getTranslucentPopupBackground(final boolean decorated) {
Color c = UIManager.getColor("PopupMenu.translucentBackground");
if (!decorated) c = new DarkColorUIResource(ColorUtil.toAlpha(c, 0));
return c;
}
private static class HeavyWeightParent extends JComponent {

1
core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkTooltipUI.java

@ -122,6 +122,7 @@ public class DarkTooltipUI extends BasicToolTipUI implements PropertyChangeListe
toolTip.putClientProperty(DarkPopupFactory.KEY_NO_DECORATION, true);
toolTip.putClientProperty(DarkPopupFactory.KEY_START_HIDDEN, true);
toolTip.putClientProperty(DarkPopupFactory.KEY_FORCE_HEAVYWEIGHT, true);
// toolTip.putClientProperty(DarkPopupFactory.KEY_OPAQUE, false);
fadeAnimator = new FadeInAnimator();
c.setOpaque(false);
DarkTooltipBorder border = new DarkTooltipBorder();

2
windows/src/main/cpp/Decorations.cpp

@ -320,7 +320,7 @@ LRESULT CALLBACK WindowWrapper::WindowProc(_In_ HWND hwnd, _In_ UINT uMsg, _In_
case WM_PAINT:
if (!wrapper->bgBrush)
break;
if (!wrapper->moving)
if (!wrapper->moving || wrapper->popup_menu)
PaintBackground(hwnd, wParam, wrapper);
if (uMsg == WM_ERASEBKGND)
return TRUE;

Loading…
Cancel
Save