Skip to content

Commit

Permalink
Merge branch 'LawnchairLauncher:14-dev' into trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
Goooler authored Aug 23, 2024
2 parents 7870205 + 11ebddb commit 48b3cb2
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 0 deletions.
1 change: 1 addition & 0 deletions lawnchair/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@
<string name="icon_shape_egg">Egg</string>
<string name="icon_shape_cupertino">iOS</string>
<string name="icon_shape_octagon">Octagon</string>
<string name="icon_shape_hexagon">Hexagon</string>
<string name="icon_shape_sammy">One UI</string>
<string name="icon_shape_rounded_square">Rounded square</string>
<string name="icon_shape_sharp_square">Sharp square</string>
Expand Down
37 changes: 37 additions & 0 deletions lawnchair/src/app/lawnchair/icons/shape/IconCornerShape.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import android.graphics.Path
import android.graphics.PointF
import com.android.app.animation.Interpolators.LINEAR
import com.android.launcher3.Utilities
import kotlin.math.sqrt

sealed class IconCornerShape {

Expand Down Expand Up @@ -97,6 +98,41 @@ sealed class IconCornerShape {
override fun toString(): String = "cut"
}

object CutHex : BaseBezierPath() {

override fun addCorner(
path: Path,
position: Position,
size: PointF,
progress: Float,
offsetX: Float,
offsetY: Float,
) {
if (progress == 0f) {
val paddingX = size.x - (size.x * sqrt(3.0) / 2).toFloat()
var newOffsetX = offsetX

when (position) {
Position.BottomLeft -> newOffsetX += paddingX
Position.BottomRight -> path.rMoveTo(-paddingX, 0f)
Position.TopLeft -> path.setLastPoint(paddingX + offsetX, size.y + offsetY)
Position.TopRight -> newOffsetX -= paddingX
}

path.lineTo(
position.endX * size.x + newOffsetX,
position.endY * size.y + offsetY,
)
} else {
super.addCorner(path, position, size, progress, offsetX, offsetY)
}
}

override fun toString(): String {
return "cuthex"
}
}

object LightSquircle : BaseBezierPath() {

override val controlDistance: Float = .1f
Expand Down Expand Up @@ -276,6 +312,7 @@ sealed class IconCornerShape {
fun fromString(value: String): IconCornerShape {
return when (value) {
"cut" -> Cut
"cuthex" -> CutHex
"lightsquircle" -> LightSquircle
"cubic", "squircle" -> Squircle
"strongsquircle" -> StrongSquircle
Expand Down
17 changes: 17 additions & 0 deletions lawnchair/src/app/lawnchair/icons/shape/IconShape.kt
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,22 @@ open class IconShape(
}
}

object Hexagon : IconShape(
IconCornerShape.CutHex,
IconCornerShape.CutHex,
IconCornerShape.CutHex,
IconCornerShape.CutHex,
PointF(1f, .5f),
PointF(1f, .5f),
PointF(1f, .5f),
PointF(1f, .5f),
) {

override fun toString(): String {
return "hexagon"
}
}

object Diamond : IconShape(
IconCornerShape.Cut,
IconCornerShape.Cut,
Expand Down Expand Up @@ -470,6 +486,7 @@ open class IconShape(
"cylinder" -> Cylinder
"cupertino" -> Cupertino
"octagon" -> Octagon
"hexagon" -> Hexagon
"diamond" -> Diamond
"egg" -> Egg
"" -> null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ fun iconShapeEntries(context: Context): List<ListPreferenceEntry<IconShape>> {
ListPreferenceEntry(IconShape.Cylinder) { stringResource(id = R.string.icon_shape_cylinder) },
ListPreferenceEntry(IconShape.Diamond) { stringResource(id = R.string.icon_shape_diamond) },
ListPreferenceEntry(IconShape.Egg) { stringResource(id = R.string.icon_shape_egg) },
ListPreferenceEntry(IconShape.Hexagon) { stringResource(id = R.string.icon_shape_hexagon) },
ListPreferenceEntry(IconShape.Cupertino) { stringResource(id = R.string.icon_shape_cupertino) },
ListPreferenceEntry(IconShape.Octagon) { stringResource(id = R.string.icon_shape_octagon) },
ListPreferenceEntry(IconShape.Sammy) { stringResource(id = R.string.icon_shape_sammy) },
Expand Down

0 comments on commit 48b3cb2

Please sign in to comment.