Skip to content
Permalink
Browse files

Fixed round rect border handling to only use roundrectborder if eithe…

…r all of the corners have the same radius, or top corners have the same radius (and bottom has no radius), or bottom corners have same radius (and top has no radius) - otherwise it falls back to image border. Ultimately we should move to supporting topRightMode, topLeftMode, bottomRightMode, and bottomLeftMode for independent corner radii, but the resource file currently doesn't support these settings... and didn't want to delve into that right now.
  • Loading branch information...
shannah committed Sep 25, 2018
1 parent b6a85e5 commit 66c87a6f2896bed0b1ed2834860b230e4ec8648f
Showing with 29 additions and 5 deletions.
  1. +29 −5 CodenameOneDesigner/src/com/codename1/designer/css/CSSTheme.java
@@ -2373,7 +2373,6 @@ public boolean canBeAchievedWithRoundRectBorder(Map<String,LexicalUnit> styles)




String prefix = "cn1-border";
String[] corners = new String[]{"top-left", "top-right", "bottom-left", "bottom-right"};
String[] xy = new String[]{"x", "y"};
@@ -2387,9 +2386,25 @@ public boolean canBeAchievedWithRoundRectBorder(Map<String,LexicalUnit> styles)
}

ScaledUnit val = null;
boolean topLeft=false;
boolean topRight = false;
boolean bottomLeft = false;
boolean bottomRight = false;
for (String cornerStyle : radiusAtts) {
ScaledUnit u = (ScaledUnit)styles.get(cornerStyle);
if (u != null && u.getPixelValue() != 0) {
if (cornerStyle.indexOf("top-left") != -1) {
topLeft = true;
}
if (cornerStyle.indexOf("top-right") != -1) {
topRight = true;
}
if (cornerStyle.indexOf("bottom-left") != -1) {
bottomLeft = true;
}
if (cornerStyle.indexOf("bottom-right") != -1) {
bottomRight = true;
}
if (val != null && val.getPixelValue() != u.getPixelValue()) {
// We have more than one non-zero corner radius
//System.out.println("Failed corner test");
@@ -2400,6 +2415,13 @@ public boolean canBeAchievedWithRoundRectBorder(Map<String,LexicalUnit> styles)
}
}


if (topLeft != topRight || bottomLeft != bottomRight) {
// Resource files don't currently support topLeftMode, topRightMode, bottomLeftMode, and bottomRightMode
// so we need to fall back to image borders if the left and right have different radii
return false;
}

// All corners are the same, so we can proceed to the next step.

prefix = "border";
@@ -4437,10 +4459,12 @@ private ScaledUnit getBorderRadius(Map<String,LexicalUnit> styles) {
ScaledUnit bottomRightRadius = getBorderRadius(styles, "bottom-right");
//System.out.println("TopLeftRadius is : "+topLeftRadius+" isZero? "+isZero(topLeftRadius));
//System.out.println("BottomRight Radius is : "+bottomRightRadius+" isZero? "+isZero(bottomRightRadius));
out.bottomLeftMode(!isZero(bottomLeftRadius));
out.bottomRightMode(!isZero(bottomRightRadius));
out.topLeftMode(!isZero(topLeftRadius));
out.topRightMode(!isZero(topRightRadius));
if (!isZero(bottomLeftRadius) && !isZero(bottomRightRadius) && isZero(topLeftRadius) && isZero(topRightRadius)) {
out.bottomOnlyMode(true);
} else if (isZero(bottomLeftRadius) && isZero(bottomRightRadius) && !isZero(topLeftRadius) && !isZero(topRightRadius)) {
out.topOnlyMode(true);
}



if (borderWidth != null) {

0 comments on commit 66c87a6

Please sign in to comment.
You can’t perform that action at this time.