diff --git a/core/src/main/java/com/github/weisj/darklaf/DarkLaf.java b/core/src/main/java/com/github/weisj/darklaf/DarkLaf.java index 3672fd6e..e50970d3 100644 --- a/core/src/main/java/com/github/weisj/darklaf/DarkLaf.java +++ b/core/src/main/java/com/github/weisj/darklaf/DarkLaf.java @@ -56,11 +56,10 @@ public class DarkLaf extends BasicLookAndFeel { new IdeaDefaultsInitTask(), new FontDefaultsInitTask(), new StyleSheetInitTask(), - new UtilityDefaultsInitTask(), new SystemDefaultsInitTask(), new PlatformDefaultsInitTask(), new UserInitTask(), - }; + new UtilityDefaultsInitTask()}; /* * The base look and feel. This may vary to handle different platform support. */ diff --git a/core/src/main/java/com/github/weisj/darklaf/LafManager.java b/core/src/main/java/com/github/weisj/darklaf/LafManager.java index e7735976..400be070 100644 --- a/core/src/main/java/com/github/weisj/darklaf/LafManager.java +++ b/core/src/main/java/com/github/weisj/darklaf/LafManager.java @@ -379,8 +379,8 @@ public final class LafManager { getTheme(); UIManager.setLookAndFeel(DarkLaf.class.getCanonicalName()); updateLaf(); - eventSupport.dispatchEvent(new ThemeChangeEvent(null, getTheme()), - ThemeChangeListener::themeInstalled); + SwingUtilities.invokeLater(() -> eventSupport.dispatchEvent(new ThemeChangeEvent(null, getTheme()), + ThemeChangeListener::themeInstalled)); } catch (final ClassNotFoundException | InstantiationException | IllegalAccessException diff --git a/core/src/main/java/com/github/weisj/darklaf/components/OverlayScrollPane.java b/core/src/main/java/com/github/weisj/darklaf/components/OverlayScrollPane.java index 8d899532..8045025a 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/OverlayScrollPane.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/OverlayScrollPane.java @@ -123,7 +123,7 @@ public class OverlayScrollPane extends JLayeredPane implements PropertyChangeLis scrollPane.setRowHeader(scrollPane.getRowHeader()); } - protected JScrollBar createScrollBar(final int orientation) { + protected PopupScrollBar createScrollBar(final int orientation) { return new PopupScrollBar(orientation); } @@ -243,7 +243,7 @@ public class OverlayScrollPane extends JLayeredPane implements PropertyChangeLis }); } - private static final class PopupScrollBar extends JScrollBar { + protected static final class PopupScrollBar extends JScrollBar { private PopupScrollBar(final int direction) { super(direction); diff --git a/core/src/main/java/com/github/weisj/darklaf/graphics/ImageUtil.java b/core/src/main/java/com/github/weisj/darklaf/graphics/ImageUtil.java index ed17d4fa..e06b1fea 100644 --- a/core/src/main/java/com/github/weisj/darklaf/graphics/ImageUtil.java +++ b/core/src/main/java/com/github/weisj/darklaf/graphics/ImageUtil.java @@ -59,15 +59,15 @@ public final class ImageUtil { } public static Image createFrameIcon(final Icon icon, final JFrame c) { - return createFrameIcon(icon, c, JFrame::setIconImage); + return createWindowIcon(icon, c, JFrame::setIconImage); } public static Image createFrameIcon(final Icon icon, final JDialog c) { - return createFrameIcon(icon, c, JDialog::setIconImage); + return createWindowIcon(icon, c, JDialog::setIconImage); } - public static Image createFrameIcon(final Icon icon, final T c, - final BiConsumer iconSetter) { + private static Image createWindowIcon(final Icon icon, final T c, + final BiConsumer iconSetter) { if (icon == null) return null; if (c != null) { if (iconNeedUpdates(icon)) { diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeUI.java index f670429b..7c731461 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeUI.java @@ -414,6 +414,13 @@ public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener { TreePath path; boolean rootVisible = isRootVisible(); + final int containerWidth = tree.getParent() instanceof JViewport + ? tree.getParent().getWidth() + : tree.getWidth(); + final int xOffset = tree.getParent() instanceof JViewport + ? ((JViewport) tree.getParent()).getViewPosition().x + : 0; + // Paint row backgrounds Enumeration backgroundEnumerator = treeState.getVisiblePathsFrom(initialPath); while (backgroundEnumerator != null && backgroundEnumerator.hasMoreElements()) { @@ -428,9 +435,11 @@ public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener { } bounds = getPathBounds(path, insets, boundsBuffer); if (bounds == null) return; + bounds.x = xOffset; + bounds.width = containerWidth; if (paintBounds.intersects(bounds)) { - paintRowBackground(g, paintBounds, insets, bounds, path, - tree.getRowForPath(path), isExpanded, hasBeenExpanded, isLeaf); + paintRowBackground(g, paintBounds, bounds, path, + tree.getRowForPath(path)); } } } @@ -515,23 +524,15 @@ public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener { } protected void paintRowBackground(final Graphics g, final Rectangle clipBounds, - final Insets insets, final Rectangle bounds, final TreePath path, - final int row, final boolean isExpanded, - final boolean hasBeenExpanded, final boolean isLeaf) { - final int containerWidth = tree.getParent() instanceof JViewport - ? tree.getParent().getWidth() - : tree.getWidth(); - final int xOffset = tree.getParent() instanceof JViewport - ? ((JViewport) tree.getParent()).getViewPosition().x - : 0; - + final Rectangle bounds, final TreePath path, + final int row) { if (path != null) { boolean selected = tree.isPathSelected(path); Graphics2D rowGraphics = (Graphics2D) g.create(); rowGraphics.setClip(clipBounds); rowGraphics.setColor(CellUtil.getTreeBackground(tree, selected, row)); - rowGraphics.fillRect(xOffset, bounds.y, containerWidth, bounds.height); + rowGraphics.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); rowGraphics.dispose(); } diff --git a/core/src/test/java/ui/scrollPane/OverlayScrollPaneDemo.java b/core/src/test/java/ui/scrollPane/OverlayScrollPaneDemo.java index 620ca8db..0ec08dd9 100644 --- a/core/src/test/java/ui/scrollPane/OverlayScrollPaneDemo.java +++ b/core/src/test/java/ui/scrollPane/OverlayScrollPaneDemo.java @@ -25,15 +25,14 @@ package ui.scrollPane; import java.awt.*; +import java.util.Random; import javax.swing.*; import ui.ComponentDemo; import ui.DemoPanel; -import ui.DemoResources; import com.github.weisj.darklaf.components.OverlayScrollPane; -import com.github.weisj.darklaf.util.StringUtil; public class OverlayScrollPaneDemo implements ComponentDemo { @@ -43,8 +42,36 @@ public class OverlayScrollPaneDemo implements ComponentDemo { @Override public JComponent createComponent() { - OverlayScrollPane scrollPane = new OverlayScrollPane(new JTextArea(StringUtil.repeat(DemoResources.LOREM_IPSUM, - 5))); + JComponent component = new JComponent() { + + private final Random r = new Random(); + private final Color[][] colors = new Color[100][100]; + + { + for (int x = 0; x < 100; x++) { + for (int y = 0; y < 100; y++) { + colors[x][y] = new Color(r.nextInt()); + } + } + } + + @Override + protected void paintComponent(final Graphics g) { + super.paintComponent(g); + for (int x = 0; x < 100; x++) { + for (int y = 0; y < 100; y++) { + g.setColor(colors[x][y]); + g.fillRect(x * 10, y * 10, 10, 10); + } + } + } + + @Override + public Dimension getPreferredSize() { + return new Dimension(1000, 1000); + } + }; + OverlayScrollPane scrollPane = new OverlayScrollPane(component); return new DemoPanel(scrollPane, new BorderLayout(), 0); } diff --git a/core/src/test/java/ui/scrollPane/OverlayScrollPaneTextDemo.java b/core/src/test/java/ui/scrollPane/OverlayScrollPaneTextDemo.java new file mode 100644 index 00000000..c8ec343e --- /dev/null +++ b/core/src/test/java/ui/scrollPane/OverlayScrollPaneTextDemo.java @@ -0,0 +1,55 @@ +/* + * MIT License + * + * Copyright (c) 2020 Jannis Weis + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ +package ui.scrollPane; + +import java.awt.*; + +import javax.swing.*; + +import ui.ComponentDemo; +import ui.DemoPanel; +import ui.DemoResources; + +import com.github.weisj.darklaf.components.OverlayScrollPane; +import com.github.weisj.darklaf.util.StringUtil; + +public class OverlayScrollPaneTextDemo implements ComponentDemo { + + public static void main(final String[] args) { + ComponentDemo.showDemo(new OverlayScrollPaneTextDemo()); + } + + @Override + public JComponent createComponent() { + OverlayScrollPane scrollPane = new OverlayScrollPane(new JTextArea(StringUtil.repeat(DemoResources.LOREM_IPSUM, + 5))); + return new DemoPanel(scrollPane, new BorderLayout(), 0); + } + + @Override + public String getTitle() { + return "OverlayScrollPane Demo"; + } +} diff --git a/property-loader/src/main/java/com/github/weisj/darklaf/icons/IconColorMapper.java b/property-loader/src/main/java/com/github/weisj/darklaf/icons/IconColorMapper.java index 7298eb0c..aad42f7d 100644 --- a/property-loader/src/main/java/com/github/weisj/darklaf/icons/IconColorMapper.java +++ b/property-loader/src/main/java/com/github/weisj/darklaf/icons/IconColorMapper.java @@ -54,6 +54,7 @@ public final class IconColorMapper { public static void patchColors(final SVGIcon svgIcon, final UIDefaults defaults) { SVGUniverse universe = svgIcon.getSvgUniverse(); SVGDiagram diagram = universe.getDiagram(svgIcon.getSvgURI()); + LOGGER.fine(() -> "Patching colors of icon " + svgIcon.getSvgURI()); try { loadColors(diagram, defaults); } catch (SVGElementException e) {