Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(legacy): Selective corner rounding for Arraylist element's side rectangle option. #5662

Merged
merged 1 commit into from
Feb 20, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ class Arraylist(
private val rectColorMode by choices(
"Rect-ColorMode", arrayOf("Custom", "Fade", "Random", "Rainbow", "Gradient"), "Custom"
) { rectMode != "None" }
private val rectColors = ColorSettingsInteger(this, "RectColor", applyMax = true) { isCustomRectSupported }.with(blueRibbon)
private val rectColors =
ColorSettingsInteger(this, "RectColor", applyMax = true) { isCustomRectSupported }.with(blueRibbon)
private val rectFadeColors = ColorSettingsInteger(this, "Rect-Fade", applyMax = true) { rectColorMode == "Fade" }

private val rectFadeDistance by int("Rect-Fade-Distance", 50, 0..100) { rectColorMode == "Fade" }
Expand All @@ -86,7 +87,8 @@ class Arraylist(
private val backgroundMode by choices(
"Background-Mode", arrayOf("Custom", "Fade", "Random", "Rainbow", "Gradient"), "Custom"
)
private val bgColors = ColorSettingsInteger(this, "BackgroundColor") { backgroundMode == "Custom" }.with(Color.BLACK.withAlpha(150))
private val bgColors =
ColorSettingsInteger(this, "BackgroundColor") { backgroundMode == "Custom" }.with(Color.BLACK.withAlpha(150))
private val bgFadeColors = ColorSettingsInteger(this, "Background-Fade") { backgroundMode == "Fade" }

private val bgFadeDistance by int("Background-Fade-Distance", 50, 0..100) { backgroundMode == "Fade" }
Expand All @@ -109,23 +111,12 @@ class Arraylist(
private val yDistance by float("ShadowYDistance", 0F, -2F..2F) { iconShadows }
private val shadowColor by color("ShadowColor", Color.BLACK.withAlpha(128), rainbow = true) { iconShadows }

// The images seem to be overlapped when either Rainbow or Gradient mode is active.
private val iconColorMode by choices(
"IconColorMode", arrayOf("Custom", "Fade"/*, "Rainbow", "Gradient"*/), "Custom"
"IconColorMode", arrayOf("Custom", "Fade"), "Custom"
) { displayIcons }
private val iconColor by color("IconColor", Color.WHITE) { iconColorMode == "Custom" && displayIcons }
private val iconFadeColor by color("IconFadeColor", Color.WHITE) { iconColorMode == "Fade" && displayIcons }
private val iconFadeDistance by int("IconFadeDistance", 50, 0..100) { iconColorMode == "Fade" && displayIcons }
/*private val maxIconGradientColors by int(
"MaxIconGradientColors", 4, 1..MAX_GRADIENT_COLORS
) { iconColorMode == "Gradient" && displayIcons }
private val iconGradientSpeed by float(
"IconGradientSpeed",
1f,
0f..10f
) { iconColorMode == "Gradient" && displayIcons }
private val iconGradColors =
ColorSettingsFloat.create(this, "Icon-Gradient") { iconColorMode == "Gradient" && displayIcons }*/

private fun isColorModeUsed(value: String) = value in listOf(textColorMode, rectMode, backgroundMode, iconColorMode)

Expand Down Expand Up @@ -318,7 +309,11 @@ class Arraylist(
else -> backgroundCustomColor
},
roundedBackgroundRadius,
RenderUtils.RoundedCorners.LEFT_ONLY
if (rectMode == "Left") {
RenderUtils.RoundedCorners.NONE
} else {
RenderUtils.RoundedCorners.LEFT_ONLY
}
)
}
}
Expand Down Expand Up @@ -374,7 +369,13 @@ class Arraylist(

when (rectMode) {
"Left" -> drawRoundedRect(
xPos - 5, yPos, xPos - 2, yPos + textSpacer, rectColor, roundedRectRadius,
xPos - 5,
yPos,
xPos - 2,
yPos + textSpacer,
rectColor,
roundedRectRadius,
RenderUtils.RoundedCorners.LEFT_ONLY
)

"Right" -> drawRoundedRect(
Expand All @@ -384,6 +385,13 @@ class Arraylist(
yPos + textSpacer,
rectColor,
roundedRectRadius,
if (modules.lastIndex == 0) {
RenderUtils.RoundedCorners.RIGHT_ONLY
} else when (module) {
modules.first() -> RenderUtils.RoundedCorners.TOP_RIGHT_ONLY
modules.last() -> RenderUtils.RoundedCorners.BOTTOM_RIGHT_ONLY
else -> RenderUtils.RoundedCorners.NONE
}
)

"Outline" -> {
Expand Down Expand Up @@ -428,7 +436,7 @@ class Arraylist(
).use {
RainbowShader.begin(backgroundMode == "Rainbow", rainbowX, rainbowY, rainbowOffset).use {
drawRoundedRect(
0F,
if (rectMode == "Left") 1f else 0f,
yPos,
xPos + width + if (rectMode == "Right") 4 else 1,
yPos + textSpacer,
Expand All @@ -440,7 +448,11 @@ class Arraylist(
else -> backgroundCustomColor
},
roundedBackgroundRadius,
RenderUtils.RoundedCorners.RIGHT_ONLY
if (rectMode == "Right") {
RenderUtils.RoundedCorners.NONE
} else {
RenderUtils.RoundedCorners.RIGHT_ONLY
}
)
}
}
Expand Down Expand Up @@ -493,12 +505,18 @@ class Arraylist(
when (rectMode) {
"Left" -> drawRoundedRect(
0F,
yPos - 1,
yPos,
3F,
yPos + textSpacer,
rectColor,
roundedRectRadius,
RenderUtils.RoundedCorners.RIGHT_ONLY
if (modules.lastIndex == 0) {
RenderUtils.RoundedCorners.LEFT_ONLY
} else when (module) {
modules.first() -> RenderUtils.RoundedCorners.TOP_LEFT_ONLY
modules.last() -> RenderUtils.RoundedCorners.BOTTOM_LEFT_ONLY
else -> RenderUtils.RoundedCorners.NONE
}
)

"Right" -> drawRoundedRect(
Expand Down