Draw a circle indicator on OSC buttons with toggle mode enabled

This commit is contained in:
lynxnb 2023-04-05 01:37:55 +02:00 committed by Billy Laws
parent 7cf45b11b0
commit 821cdb8d72
1 changed files with 14 additions and 0 deletions

View File

@ -40,6 +40,7 @@ abstract class OnScreenButton(
const val CONFIGURED_ASPECT_RATIO = 2074f / 874f
private var disabledSelectionPaint : Paint? = null
private var toggleModePaint : Paint? = null
}
init {
@ -50,6 +51,13 @@ abstract class OnScreenButton(
strokeWidth = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2f, onScreenControllerView.context.resources.displayMetrics)
}
}
if (toggleModePaint == null) {
toggleModePaint = Paint().apply {
style = Paint.Style.STROKE
strokeWidth = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2f, onScreenControllerView.context.resources.displayMetrics)
}
}
}
final override val config = OnScreenConfigurationImpl(onScreenControllerView.context, buttonId, defaultRelativeX, defaultRelativeY, defaultEnabled)
@ -158,6 +166,12 @@ abstract class OnScreenButton(
}
renderCenteredText(canvas, buttonId.short!!, itemWidth.coerceAtMost(itemHeight) * 0.4f, bounds.centerX().toFloat(), bounds.centerY().toFloat(), alpha)
if (config.toggleMode) {
canvas.drawCircle(bounds.centerX().toFloat(), bounds.centerY().toFloat(), itemWidth.coerceAtMost(itemHeight) * 0.35f, toggleModePaint?.apply {
color = config.textColor
this.alpha = alpha
} ?: return)
}
}