From 10523302c8c0b7e70ba332e19b28d3f324e0bbba Mon Sep 17 00:00:00 2001 From: weisj Date: Mon, 23 Mar 2020 16:37:40 +0100 Subject: [PATCH] Use fallback values in DropShadowBorder Use icon size when creating image table value. Only run documentation action when properties have changed. --- .github/workflows/documentation.yml | 7 +++++-- .../components/border/DropShadowBorder.java | 17 +++++++++-------- .../darklaf/properties/ui/menuItem.properties | 4 ++++ .../test/java/documentation/CreateUITable.java | 16 +++++++++++----- 4 files changed, 29 insertions(+), 15 deletions(-) diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 7ec9aaff..1125d716 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -1,8 +1,11 @@ name: Documentation on: push: - branches: - - '*' + paths: + - '**.properties' + pull_request: + paths: + - '**.properties' jobs: gradle: diff --git a/core/src/main/java/com/github/weisj/darklaf/components/border/DropShadowBorder.java b/core/src/main/java/com/github/weisj/darklaf/components/border/DropShadowBorder.java index 08c59f3d..d5aa864c 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/border/DropShadowBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/border/DropShadowBorder.java @@ -78,14 +78,14 @@ public class DropShadowBorder implements Border, Serializable { public DropShadowBorder(final Color shadowColor, final int shadowSize, final float shadowOpacity, final int cornerSize, final boolean showTopShadow, final boolean showLeftShadow, final boolean showBottomShadow, final boolean showRightShadow) { - this.shadowColor = shadowColor; - this.shadowSize = shadowSize; - this.shadowOpacity = shadowOpacity; - this.cornerSize = cornerSize; - this.showTopShadow = showTopShadow; - this.showLeftShadow = showLeftShadow; - this.showBottomShadow = showBottomShadow; - this.showRightShadow = showRightShadow; + setShadowColor(shadowColor); + setShadowSize(shadowSize); + setShadowOpacity(shadowOpacity); + setCornerSize(cornerSize); + setShowTopShadow(showTopShadow); + setShowLeftShadow(showLeftShadow); + setShowBottomShadow(showBottomShadow); + setShowRightShadow(showRightShadow); } @@ -411,6 +411,7 @@ public class DropShadowBorder implements Border, Serializable { public DropShadowBorder setShadowColor(final Color shadowColor) { this.shadowColor = shadowColor; + if (shadowColor == null) this.shadowColor = Color.BLACK; return this; } diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/menuItem.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/menuItem.properties index 9323cd19..1ba1addc 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/menuItem.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/menuItem.properties @@ -53,7 +53,11 @@ MenuItem.arrowIcon = navigation/arrowRight.svg[t MenuItem.arrowHover.icon = navigation/arrowRightHover.svg[themed] MenuItem.checkIcon = empty(7,7) Menu.checkIcon = empty(7,7) + CheckBoxMenuItem.checkIcon = empty(19,19) CheckBoxMenuItem.arrowIcon = empty(16,16) +CheckBoxMenuItem.dashIcon = empty(0,0) + RadioButtonMenuItem.checkIcon = empty(19,19) RadioButtonMenuItem.arrowIcon = empty(16,16) +RadioButtonMenuItem.dashIcon = empty(0,0) diff --git a/core/src/test/java/documentation/CreateUITable.java b/core/src/test/java/documentation/CreateUITable.java index 85632c1c..5b1ada8b 100644 --- a/core/src/test/java/documentation/CreateUITable.java +++ b/core/src/test/java/documentation/CreateUITable.java @@ -239,11 +239,12 @@ public class CreateUITable { private String parseImage(final String key, final Object value, final int ident) { String stringRepresentation = parseValue(value).replaceAll(" ", ""); String path; + Dimension size = new Dimension(SAMPLE_WIDTH, SAMPLE_HEIGHT); try { if (!(value instanceof Icon)) { - path = createImage(value, stringRepresentation); + path = createImage(value, stringRepresentation, size); } else { - path = createImage(value, key); + path = createImage(value, key, size); } } catch (IOException ignored) { return StringUtil.repeat(IDENT, ident) + "\n"; @@ -252,7 +253,7 @@ public class CreateUITable { + String.format("\"%s\"\n", path, key); } - private String createImage(final Object value, final String name) throws IOException { + private String createImage(final Object value, final String name, final Dimension size) throws IOException { new File(workingFolder + "img/").mkdirs(); String fileName = "img/" + name + ".png"; File imageFile = new File(workingFolder + fileName); @@ -260,11 +261,16 @@ public class CreateUITable { JComponent comp = (JComponent) new SampleRenderer().getTableCellRendererComponent(null, value, false, false, 0, 0); BufferedImage image = ImageUtil.createCompatibleTranslucentImage(SAMPLE_WIDTH, SAMPLE_HEIGHT); Graphics g = image.getGraphics(); + if (value instanceof Icon) { + size.width = Math.max(size.width, ((Icon) value).getIconWidth()); + size.height = Math.max(size.height, ((Icon) value).getIconHeight()); + } + if (!(value instanceof Icon) && !(value instanceof DropShadowBorder)) { g.setColor(new JPanel().getBackground()); - g.fillRect(0, 0, SAMPLE_WIDTH, SAMPLE_HEIGHT); + g.fillRect(0, 0, size.width, size.height); } - comp.setBounds(0, 0, SAMPLE_WIDTH, SAMPLE_HEIGHT); + comp.setBounds(0, 0, size.width, size.height); comp.setOpaque(false); comp.paint(g); g.dispose();