From 0cdfaa1e423ee491cd3303d03eddda18a98bf89f Mon Sep 17 00:00:00 2001 From: Sebastiano Poggi Date: Fri, 15 Sep 2023 16:33:02 +0200 Subject: [PATCH] Fix icon loading in IDE (#112) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix icon loading in IDE * Fix icon loading in standalone modules * Fix static analysis * SwingBridgeService will now wait 20 milliseconds before reading the theme and then will retry due to Swing possible race conditions. * Fixed SLC focus system, added right color for unfocused selected items in the LazyTree. * Partially fix icon mapping Something still isn't working well — icon states may need to be applied _after_ mapping, need to check as it breaks in those cases. Checkboxes and radio buttons also use the old UI icons, not sure why they don't get mapped. * Add fallback path for icon loading * Update project settings * Also load iconColorsOnSelection from theme * Fix crash in standalone sample * Clean up painter provider usage * Re-do icon tinting logic, better match Swing * Fix tree crashing in sample (see #114) Also reformat/cleanup after rebase on main --------- Co-authored-by: Lamberto Basti --- .idea/detekt.xml | 2 + .idea/externalDependencies.xml | 1 + buildSrc/src/main/kotlin/jewel.gradle.kts | 1 + .../theme/IntUiThemeDescriptorReader.kt | 21 +- .../theme/IntelliJThemeGeneratorPlugin.kt | 55 ++--- .../jetbrains/jewel/ClassLoaderProvider.kt | 6 + .../org/jetbrains/jewel/IntelliJSvgLoader.kt | 119 ----------- .../jewel/IntelliJThemeColorPalette.kt | 6 +- .../jetbrains/jewel/IntelliJThemeIconData.kt | 30 ++- .../jetbrains/jewel/JewelResourceLoader.kt | 76 ++++++- .../org/jetbrains/jewel/JewelSvgLoader.kt | 54 +++++ .../kotlin/org/jetbrains/jewel/LazyTree.kt | 4 +- .../org/jetbrains/jewel/PaletteMapper.kt | 50 +++-- .../jetbrains/jewel/SimpleResourceLoader.kt | 20 ++ .../kotlin/org/jetbrains/jewel/SvgLoader.kt | 2 +- .../kotlin/org/jetbrains/jewel/SvgPatcher.kt | 2 +- .../kotlin/org/jetbrains/jewel/TextArea.kt | 2 +- .../jewel/foundation/lazy/Keybindings.kt | 2 - .../foundation/lazy/SelectableLazyColumn.kt | 58 ++--- .../lazy/SelectableLazyListScope.kt | 54 +++-- .../jewel/foundation/tree/BasicLazyTree.kt | 2 +- .../jewel/styling/LazyTreeStyling.kt | 15 +- .../jewel/styling/PainterProvider.kt | 23 ++ .../jewel/styling/ResourcePainterProvider.kt | 3 +- .../jewel/themes/PaletteMapperFactory.kt | 142 +++++-------- .../themes/StandalonePaletteMapperFactory.kt | 82 +++++++ .../jetbrains/jewel/bridge/BridgeIconData.kt | 17 +- .../jewel/bridge/BridgeIconMapper.kt | 60 ++++++ .../bridge/BridgePaletteMapperFactory.kt | 27 +++ .../jewel/bridge/BridgeResourceLoader.kt | 25 +++ ...er.kt => BridgeResourcePainterProvider.kt} | 29 ++- .../jewel/bridge/BridgeThemeColorPalette.kt | 72 +++++-- .../org/jetbrains/jewel/bridge/BridgeUtils.kt | 18 +- .../jetbrains/jewel/bridge/ComposePanel.kt | 1 - .../org/jetbrains/jewel/bridge/IconMapper.kt | 3 +- .../org/jetbrains/jewel/bridge/IntUiBridge.kt | 64 +++--- .../jewel/bridge/IntelliJIconMapper.kt | 44 ---- .../jewel/bridge/SwingBridgeService.kt | 24 ++- .../jewel/bridge/SwingBridgeTheme.kt | 15 +- .../jewel/bridge/UiThemeExtensions.kt | 42 ++++ .../samples/ideplugin/JewelDemoToolWindow.kt | 200 ++++++++++++++---- .../jewel/samples/standalone/Main.kt | 4 +- .../standalone/components/ChipsAndTree.kt | 159 +++++++------- .../intui/core/IntUiThemeColorPalette.kt | 2 +- .../themes/intui/core/IntelliJSvgPatcher.kt | 21 +- .../standalone/IntUiDefaultResourceLoader.kt | 20 -- .../themes/intui/standalone/IntUiTheme.kt | 15 +- .../styling/IntUiLazyTreeStyling.kt | 33 +-- 48 files changed, 1123 insertions(+), 604 deletions(-) create mode 100644 core/src/main/kotlin/org/jetbrains/jewel/ClassLoaderProvider.kt delete mode 100644 core/src/main/kotlin/org/jetbrains/jewel/IntelliJSvgLoader.kt create mode 100644 core/src/main/kotlin/org/jetbrains/jewel/JewelSvgLoader.kt create mode 100644 core/src/main/kotlin/org/jetbrains/jewel/SimpleResourceLoader.kt create mode 100644 core/src/main/kotlin/org/jetbrains/jewel/themes/StandalonePaletteMapperFactory.kt create mode 100644 ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/BridgeIconMapper.kt create mode 100644 ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/BridgePaletteMapperFactory.kt create mode 100644 ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/BridgeResourceLoader.kt rename ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/{IntelliJResourcePainterProvider.kt => BridgeResourcePainterProvider.kt} (57%) delete mode 100644 ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/IntelliJIconMapper.kt create mode 100644 ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/UiThemeExtensions.kt delete mode 100644 themes/int-ui/int-ui-standalone/src/main/kotlin/org/jetbrains/jewel/themes/intui/standalone/IntUiDefaultResourceLoader.kt diff --git a/.idea/detekt.xml b/.idea/detekt.xml index a921d6684..efda1cfc1 100644 --- a/.idea/detekt.xml +++ b/.idea/detekt.xml @@ -11,5 +11,7 @@ +