diff options
-rw-r--r-- | src/macosx/classes/com/apple/laf/AquaPanelUI.java | 10 | ||||
-rw-r--r-- | src/macosx/classes/com/apple/laf/AquaRootPaneUI.java | 8 | ||||
-rw-r--r-- | src/macosx/classes/com/apple/laf/AquaToolBarUI.java | 12 | ||||
-rw-r--r-- | src/macosx/classes/com/apple/laf/AquaUtils.java | 50 | ||||
-rw-r--r-- | src/macosx/classes/sun/lwawt/LWWindowPeer.java | 34 | ||||
-rw-r--r-- | src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java | 6 | ||||
-rw-r--r-- | src/share/classes/javax/swing/JViewport.java | 10 |
7 files changed, 116 insertions, 14 deletions
diff --git a/src/macosx/classes/com/apple/laf/AquaPanelUI.java b/src/macosx/classes/com/apple/laf/AquaPanelUI.java index 07a758f7d..960705b8e 100644 --- a/src/macosx/classes/com/apple/laf/AquaPanelUI.java +++ b/src/macosx/classes/com/apple/laf/AquaPanelUI.java @@ -32,10 +32,20 @@ import javax.swing.plaf.basic.BasicPanelUI; import com.apple.laf.AquaUtils.RecyclableSingleton; import com.apple.laf.AquaUtils.RecyclableSingletonFromDefaultConstructor; +import java.awt.Graphics; + public class AquaPanelUI extends BasicPanelUI { static RecyclableSingleton<AquaPanelUI> instance = new RecyclableSingletonFromDefaultConstructor<AquaPanelUI>(AquaPanelUI.class); public static ComponentUI createUI(final JComponent c) { return instance.get(); } + + @Override + public final void update(final Graphics g, final JComponent c) { + if (c.isOpaque()) { + AquaUtils.fillRect(g, c); + } + paint(g, c); + } } diff --git a/src/macosx/classes/com/apple/laf/AquaRootPaneUI.java b/src/macosx/classes/com/apple/laf/AquaRootPaneUI.java index e7277128f..6f3c1f253 100644 --- a/src/macosx/classes/com/apple/laf/AquaRootPaneUI.java +++ b/src/macosx/classes/com/apple/laf/AquaRootPaneUI.java @@ -319,4 +319,12 @@ public class AquaRootPaneUI extends BasicRootPaneUI implements AncestorListener, updateComponentTreeUIActivation(element, active); } } + + @Override + public final void update(final Graphics g, final JComponent c) { + if (c.isOpaque()) { + AquaUtils.fillRect(g, c); + } + paint(g, c); + } } diff --git a/src/macosx/classes/com/apple/laf/AquaToolBarUI.java b/src/macosx/classes/com/apple/laf/AquaToolBarUI.java index 660cff318..bf87e2d1b 100644 --- a/src/macosx/classes/com/apple/laf/AquaToolBarUI.java +++ b/src/macosx/classes/com/apple/laf/AquaToolBarUI.java @@ -73,9 +73,7 @@ public class AquaToolBarUI extends BasicToolBarUI implements SwingConstants { g.translate(x, y); if (c.isOpaque()) { - final Color background = c.getBackground(); - g.setColor(background); - g.fillRect(0, 0, w - 1, h - 1); + AquaUtils.fillRect(g, c, c.getBackground(), 0, 0, w - 1, h - 1); } final Color oldColor = g.getColor(); @@ -137,4 +135,12 @@ public class AquaToolBarUI extends BasicToolBarUI implements SwingConstants { return true; } } + + @Override + public final void update(final Graphics g, final JComponent c) { + if (c.isOpaque()) { + AquaUtils.fillRect(g, c); + } + paint(g, c); + } } diff --git a/src/macosx/classes/com/apple/laf/AquaUtils.java b/src/macosx/classes/com/apple/laf/AquaUtils.java index 58b0d1efb..0592da714 100644 --- a/src/macosx/classes/com/apple/laf/AquaUtils.java +++ b/src/macosx/classes/com/apple/laf/AquaUtils.java @@ -28,18 +28,19 @@ package com.apple.laf; import java.awt.*; import java.awt.image.*; import java.lang.ref.SoftReference; -import java.lang.ref.WeakReference; import java.lang.reflect.Method; import java.security.PrivilegedAction; import java.util.*; import javax.swing.*; import javax.swing.border.Border; +import javax.swing.plaf.UIResource; import sun.awt.AppContext; import sun.lwawt.macosx.CImage; import sun.lwawt.macosx.CImage.Creator; +import sun.lwawt.macosx.CPlatformWindow; import sun.swing.SwingUtilities2; import com.apple.laf.AquaImageFactory.SlicedImageControl; @@ -389,4 +390,51 @@ public class AquaUtils { return false; } } + + protected static boolean isWindowTextured(final Component c) { + if (!(c instanceof JComponent)) { + return false; + } + final JRootPane pane = ((JComponent) c).getRootPane(); + if (pane == null) { + return false; + } + Object prop = pane.getClientProperty( + CPlatformWindow.WINDOW_BRUSH_METAL_LOOK); + if (prop != null) { + return Boolean.parseBoolean(prop.toString()); + } + prop = pane.getClientProperty(CPlatformWindow.WINDOW_STYLE); + return prop != null && "textured".equals(prop); + } + + private static Color resetAlpha(final Color color) { + return new Color(color.getRed(), color.getGreen(), color.getBlue(), 0); + } + + protected static void fillRect(final Graphics g, final Component c) { + fillRect(g, c, c.getBackground(), 0, 0, c.getWidth(), c.getHeight()); + } + + protected static void fillRect(final Graphics g, final Component c, + final Color color, final int x, final int y, + final int w, final int h) { + if (!(g instanceof Graphics2D)) { + return; + } + final Graphics2D cg = (Graphics2D) g.create(); + try { + if (color instanceof UIResource && isWindowTextured(c) + && color.equals(SystemColor.window)) { + cg.setComposite(AlphaComposite.Src); + cg.setColor(resetAlpha(color)); + } else { + cg.setColor(color); + } + cg.fillRect(x, y, w, h); + } finally { + cg.dispose(); + } + } } + diff --git a/src/macosx/classes/sun/lwawt/LWWindowPeer.java b/src/macosx/classes/sun/lwawt/LWWindowPeer.java index c78582f32..dd20e8713 100644 --- a/src/macosx/classes/sun/lwawt/LWWindowPeer.java +++ b/src/macosx/classes/sun/lwawt/LWWindowPeer.java @@ -112,6 +112,8 @@ public class LWWindowPeer private static final Color nonOpaqueBackground = new Color(0, 0, 0, 0); + private volatile boolean textured; + /** * Current modal blocker or null. * @@ -442,9 +444,23 @@ public class LWWindowPeer public void updateWindow() { } + public final boolean isTextured() { + return textured; + } + + public final void setTextured(final boolean isTextured) { + textured = isTextured; + } + public final boolean isTranslucent() { synchronized (getStateLock()) { - return !isOpaque || isShaped(); + /* + * Textured window is a special case of translucent window. + * The difference is only in nswindow background. So when we set + * texture property our peer became fully translucent. It doesn't + * fill background, create non opaque backbuffers and layer etc. + */ + return !isOpaque || isShaped() || isTextured(); } } @@ -613,11 +629,13 @@ public class LWWindowPeer g.setColor(nonOpaqueBackground); g.fillRect(0, 0, w, h); } - if (g instanceof SunGraphics2D) { - SG2DConstraint((SunGraphics2D) g, getRegion()); + if (!isTextured()) { + if (g instanceof SunGraphics2D) { + SG2DConstraint((SunGraphics2D) g, getRegion()); + } + g.setColor(getBackground()); + g.fillRect(0, 0, w, h); } - g.setColor(getBackground()); - g.fillRect(0, 0, w, h); } finally { g.dispose(); } @@ -982,8 +1000,10 @@ public class LWWindowPeer if (g instanceof SunGraphics2D) { SG2DConstraint((SunGraphics2D) g, getRegion()); } - g.setColor(getBackground()); - g.fillRect(0, 0, r.width, r.height); + if (!isTextured()) { + g.setColor(getBackground()); + g.fillRect(0, 0, r.width, r.height); + } if (oldBB != null) { // Draw the old back buffer to the new one g.drawImage(oldBB, 0, 0, null); diff --git a/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java b/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java index cdb84b9f5..46fece1de 100644 --- a/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java +++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java @@ -298,7 +298,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo // If the target is a dialog, popup or tooltip we want it to ignore the brushed metal look. if (isPopup) { - styleBits = SET(styleBits, TEXTURED, true); + styleBits = SET(styleBits, TEXTURED, false); // Popups in applets don't activate applet's process styleBits = SET(styleBits, NONACTIVATING, true); } @@ -372,6 +372,8 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo } } + peer.setTextured(IS(TEXTURED, styleBits)); + return styleBits; } @@ -733,7 +735,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo @Override public void setOpaque(boolean isOpaque) { CWrapper.NSWindow.setOpaque(getNSWindowPtr(), isOpaque); - if (!isOpaque) { + if (!isOpaque && !peer.isTextured()) { long clearColor = CWrapper.NSColor.clearColor(); CWrapper.NSWindow.setBackgroundColor(getNSWindowPtr(), clearColor); } diff --git a/src/share/classes/javax/swing/JViewport.java b/src/share/classes/javax/swing/JViewport.java index 51975d7cd..c2ea60bf0 100644 --- a/src/share/classes/javax/swing/JViewport.java +++ b/src/share/classes/javax/swing/JViewport.java @@ -1586,10 +1586,18 @@ public class JViewport extends JComponent implements Accessible int bdx = blitToX - blitFromX; int bdy = blitToY - blitFromY; + Composite oldComposite = null; // Shift the scrolled region + if (g instanceof Graphics2D) { + Graphics2D g2d = (Graphics2D) g; + oldComposite = g2d.getComposite(); + g2d.setComposite(AlphaComposite.Src); + } rm.copyArea(this, g, blitFromX, blitFromY, blitW, blitH, bdx, bdy, false); - + if (oldComposite != null) { + ((Graphics2D) g).setComposite(oldComposite); + } // Paint the newly exposed region. int x = view.getX(); int y = view.getY(); |