@@ -125,6 +140,10 @@ public int getIconHeight() {
public void paintIcon(Component component, Graphics g, int i, int j) {
}
+ @Override
+ public void render(@NotNull PaintingApi api) {
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) return true;
@@ -158,3 +177,25 @@ public static final class EmptyIconUIResource extends EmptyIcon implements UIRes
}
}
}
+
+class EmptyIconIdentifier implements IconIdentifier {
+ int width;
+ int height;
+
+ EmptyIconIdentifier(int width, int height) {
+ this.width = width;
+ this.height = height;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o == null || getClass() != o.getClass()) return false;
+ EmptyIconIdentifier that = (EmptyIconIdentifier)o;
+ return width == that.width && height == that.height;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(width, height);
+ }
+}
\ No newline at end of file
diff --git a/plugins/devkit/intellij.devkit.compose/src/demo/ComponentShowcaseTab.kt b/plugins/devkit/intellij.devkit.compose/src/demo/ComponentShowcaseTab.kt
index acfbe489da0d4..f4ac5f537b665 100644
--- a/plugins/devkit/intellij.devkit.compose/src/demo/ComponentShowcaseTab.kt
+++ b/plugins/devkit/intellij.devkit.compose/src/demo/ComponentShowcaseTab.kt
@@ -13,10 +13,14 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
+import com.intellij.icons.AllIcons
import com.intellij.ide.BrowserUtil
import com.intellij.openapi.project.Project
+import com.intellij.ui.IconDeferrer
import com.intellij.ui.JBColor
import com.intellij.util.ui.JBUI
+import kotlinx.coroutines.delay
+import org.jetbrains.icons.api.Icon
import org.jetbrains.jewel.bridge.toComposeColor
import org.jetbrains.jewel.foundation.LocalComponent
import org.jetbrains.jewel.foundation.actionSystem.provideData
@@ -284,7 +288,7 @@ private fun IconsShowcase() {
}
IconButton(onClick = {}, Modifier.size(24.dp)) {
- Icon(key = AllIconsKeys.Actions.Close, contentDescription = "Close")
+ Icon(AllIconsKeys.Actions.Close, "Close")
}
IconActionButton(
@@ -295,9 +299,25 @@ private fun IconsShowcase() {
hints = arrayOf(Size(24)),
tooltip = { Text("Hello there") },
)
+
+ Box {
+ Icon(AllIcons.General.OpenDisk as Icon, "Build Load Changes")
+ }
+
+ Box {
+ Icon(deferedIcon as Icon, "Deferred Icon Sample")
+ }
}
}
+private val deferedIcon = IconDeferrer.getInstance().deferAsync(
+ AllIcons.General.Print,
+ "KABOOM-DEF_ICON_TST"
+) {
+ delay(10000)
+ AllIcons.General.GreenCheckmark
+}
+
@Composable
private fun RowScope.ColumnTwo(project: Project) {
Column(Modifier.trackActivation().weight(1f), verticalArrangement = Arrangement.spacedBy(16.dp)) {
diff --git a/plugins/devkit/intellij.devkit.compose/src/showcase/ComposePerformanceDemoAction.kt b/plugins/devkit/intellij.devkit.compose/src/showcase/ComposePerformanceDemoAction.kt
index 48145337aea3a..28372645314ac 100644
--- a/plugins/devkit/intellij.devkit.compose/src/showcase/ComposePerformanceDemoAction.kt
+++ b/plugins/devkit/intellij.devkit.compose/src/showcase/ComposePerformanceDemoAction.kt
@@ -3,13 +3,17 @@ package com.intellij.devkit.compose.showcase
import androidx.compose.animation.core.*
import androidx.compose.foundation.Canvas
+import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.size
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
+import androidx.compose.ui.draw.clipToBounds
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.Color
@@ -21,18 +25,24 @@ import androidx.compose.ui.text.rememberTextMeasurer
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
+import com.intellij.icons.AllIcons
import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.project.DumbAwareAction
import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.DialogWrapper
import org.jetbrains.jewel.bridge.compose
+import org.jetbrains.jewel.ui.component.Checkbox
+import org.jetbrains.jewel.ui.component.Icon
import org.jetbrains.jewel.ui.component.Slider
import org.jetbrains.jewel.ui.component.Text
+import org.jetbrains.jewel.ui.icon.IconKey
+import org.jetbrains.jewel.ui.icons.AllIconsKeys
import java.awt.BorderLayout
import java.util.*
import javax.swing.*
import kotlin.math.*
+import kotlin.reflect.typeOf
internal class ComposePerformanceDemoAction : DumbAwareAction() {
@@ -49,7 +59,7 @@ private class MyDialog(project: Project?, dialogTitle: String) :
DialogWrapper(project, null, true, IdeModalityType.MODELESS, true) {
val centerPanelWrapper = JPanel(BorderLayout())
- enum class TestCase { TextAnimation, Canvas }
+ enum class TestCase { TextAnimation, Canvas, Icons }
enum class Mode { Swing, AWT }
var mode = Mode.Swing
@@ -74,17 +84,22 @@ private class MyDialog(project: Project?, dialogTitle: String) :
ButtonGroup().let { group ->
val textAnimationButton = JRadioButton("Text animation")
val canvasButton = JRadioButton("Canvas")
+ val iconsButton = JRadioButton("Icons")
group.add(textAnimationButton)
group.add(canvasButton)
+ group.add(iconsButton)
textAnimationButton.isSelected = testCase == TestCase.TextAnimation
canvasButton.isSelected = testCase == TestCase.Canvas
+ iconsButton.isSelected = testCase == TestCase.Icons
textAnimationButton.addActionListener { testCase = TestCase.TextAnimation; initCentralPanel() }
canvasButton.addActionListener { testCase = TestCase.Canvas; initCentralPanel() }
+ iconsButton.addActionListener { testCase = TestCase.Icons; initCentralPanel() }
controlPanel.add(canvasButton)
controlPanel.add(textAnimationButton)
+ controlPanel.add(iconsButton)
}
controlPanel.add(JSeparator(JSeparator.VERTICAL))
@@ -119,6 +134,7 @@ private class MyDialog(project: Project?, dialogTitle: String) :
val comp = when (testCase) {
TestCase.TextAnimation -> createTextAnimationComponent()
TestCase.Canvas -> createClockComponent()
+ TestCase.Icons -> createIconsComponent()
}
centerPanelWrapper.add(comp)
@@ -129,6 +145,111 @@ private class MyDialog(project: Project?, dialogTitle: String) :
}
}
+private fun createIconsComponent(): JComponent {
+ return compose {
+ var minFps by remember { mutableStateOf(Int.MAX_VALUE) }
+ var maxFps by remember { mutableStateOf(Int.MIN_VALUE) }
+ val frameTimes = remember { LinkedList