Skip to content

Commit

Permalink
Use LayeredIcon for mixin classes (#2340)
Browse files Browse the repository at this point in the history
* Use layered icons for mixin classes

* Resize icons

* Remove outlines

* Use `IconLayerProvider`

* Clean up svg
  • Loading branch information
kikugie authored Aug 1, 2024
1 parent e54877a commit 93be505
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/main/kotlin/asset/MixinAssets.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ object MixinAssets : Assets() {

val MIXIN_CLASS_ICON = loadIcon("/assets/icons/mixin/mixin_class_gutter.png")
val MIXIN_CLASS_ICON_DARK = loadIcon("/assets/icons/mixin/mixin_class_gutter_dark.png")

val MIXIN_MARK = loadIcon("/assets/icons/mixin/mixin_mark.svg")
}
16 changes: 10 additions & 6 deletions src/main/kotlin/platform/mixin/framework/MixinIconProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,19 @@
package com.demonwav.mcdev.platform.mixin.framework

import com.demonwav.mcdev.MinecraftSettings
import com.demonwav.mcdev.asset.PlatformAssets
import com.demonwav.mcdev.asset.MixinAssets
import com.demonwav.mcdev.platform.mixin.util.isMixin
import com.intellij.ide.IconProvider
import com.intellij.ide.IconLayerProvider
import com.intellij.openapi.util.Iconable
import com.intellij.psi.PsiClass
import com.intellij.psi.PsiElement
import javax.swing.Icon

class MixinIconProvider : IconProvider() {
override fun getIcon(element: PsiElement, flags: Int) =
PlatformAssets.MIXIN_ICON.takeIf {
class MixinIconProvider : IconLayerProvider {
override fun getLayerIcon(element: Iconable, isLocked: Boolean): Icon? =
MixinAssets.MIXIN_MARK.takeIf {
MinecraftSettings.instance.mixinClassIcon && element is PsiClass && element.isMixin
}

override fun getLayerDescription(): String =
"Mixin class"
}
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@

<library.presentationProvider implementation="com.demonwav.mcdev.platform.mixin.framework.MixinPresentationProvider" />

<iconProvider implementation="com.demonwav.mcdev.platform.mixin.framework.MixinIconProvider" />
<iconLayerProvider implementation="com.demonwav.mcdev.platform.mixin.framework.MixinIconProvider" />

<!--region MixinExtras Expression Language-->
<fileType name="MixinExtras Expression File"
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/assets/icons/mixin/mixin_mark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 93be505

Please sign in to comment.