Skip to content

Commit 6ff2213

Browse files
Add native support for radial gradients in CSS compiler (#4332)
Fixed #3502 Enabled `RoundRectBorder` to utilize native Codename One gradient support when the CSS background is a valid CN1 gradient (e.g. `radial-gradient`). Fixed parsing logic for `radial-gradient` position coordinates to correctly map to CN1 relative X/Y values (removing inverted coordinate calculation). Ensured safety when casting style properties in `canBeAchievedWithRoundRectBorder`. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
1 parent 0286dde commit 6ff2213

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

CodenameOneDesigner/src/com/codename1/designer/css/CSSTheme.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -489,8 +489,8 @@ private void parseRadialGradient(ScaledUnit background) {
489489
}
490490

491491
type = Style.BACKGROUND_GRADIENT_RADIAL;
492-
gradientX = 1-(float)relX;
493-
gradientY = 1-(float)relY;
492+
gradientX = (float)relX;
493+
gradientY = (float)relY;
494494
this.bgTransparency = (byte)alpha;
495495
this.startColor = color1;
496496
this.endColor = color2;
@@ -2920,7 +2920,17 @@ public boolean canBeAchievedWithCSSBorder(Map<String,LexicalUnit> styles) {
29202920
}
29212921

29222922
public boolean canBeAchievedWithRoundRectBorder(Map<String,LexicalUnit> styles) {
2923-
if (hasUnequalBorders() || this.hasGradient() || !isBorderLineOrNone() || !isNone(backgroundImageUrl) || hasBoxShadow() || hasBorderImage()) {
2923+
boolean supportedGradient = false;
2924+
if (this.hasGradient()) {
2925+
LexicalUnit backgroundLU = styles.get("background");
2926+
if (backgroundLU instanceof ScaledUnit) {
2927+
ScaledUnit background = (ScaledUnit)backgroundLU;
2928+
if (background != null && background.isCN1Gradient()) {
2929+
supportedGradient = true;
2930+
}
2931+
}
2932+
}
2933+
if (hasUnequalBorders() || (this.hasGradient() && !supportedGradient) || !isBorderLineOrNone() || !isNone(backgroundImageUrl) || hasBoxShadow() || hasBorderImage()) {
29242934
return false;
29252935
}
29262936

0 commit comments

Comments
 (0)