From c917981ef82b911aab65b554c5f67ca276de99e5 Mon Sep 17 00:00:00 2001 From: downthecrop Date: Wed, 23 Oct 2024 15:59:29 -0700 Subject: [PATCH] Additional theme support + dynamic scrolling for resized views --- .../src/main/kotlin/KondoKit/ScrollablePanel.kt | 6 +++++- plugin-playground/src/main/kotlin/KondoKit/Themes.kt | 2 +- plugin-playground/src/main/kotlin/KondoKit/plugin.kt | 1 - 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/plugin-playground/src/main/kotlin/KondoKit/ScrollablePanel.kt b/plugin-playground/src/main/kotlin/KondoKit/ScrollablePanel.kt index 46f2b5a..cf6444c 100644 --- a/plugin-playground/src/main/kotlin/KondoKit/ScrollablePanel.kt +++ b/plugin-playground/src/main/kotlin/KondoKit/ScrollablePanel.kt @@ -17,6 +17,7 @@ class ScrollablePanel(private val content: JPanel) : JPanel() { private var scrollbarY = 0 private var showScrollbar = false private var draggingScrollPill = false + private var lastSize = 0 // Define a buffer for the view height (extra space for smoother scrolling) private val viewBuffer = -30 @@ -68,6 +69,8 @@ class ScrollablePanel(private val content: JPanel) : JPanel() { Timer().schedule(object : TimerTask() { override fun run() { updateScrollbar() + if(lastSize != content.preferredSize.height.coerceAtLeast(frame.height + viewBuffer)) + handleResize() } }, 0, 1000) @@ -84,7 +87,8 @@ class ScrollablePanel(private val content: JPanel) : JPanel() { bounds = Rectangle(0, 0, 242, frame.height) // Dynamically update content bounds and scrollbar on frame resize with buffer - content.bounds = Rectangle(0, 0, 242, content.preferredSize.height.coerceAtLeast(frame.height + viewBuffer)) + lastSize = content.preferredSize.height.coerceAtLeast(frame.height + viewBuffer) + content.bounds = Rectangle(0, 0, 242, lastSize) showScrollbar = content.height > frame.height currentOffsetY = 0 diff --git a/plugin-playground/src/main/kotlin/KondoKit/Themes.kt b/plugin-playground/src/main/kotlin/KondoKit/Themes.kt index fc64103..1b7988d 100644 --- a/plugin-playground/src/main/kotlin/KondoKit/Themes.kt +++ b/plugin-playground/src/main/kotlin/KondoKit/Themes.kt @@ -60,7 +60,7 @@ object Themes { ThemeType.SARADOMIN -> Theme( widgetColor = Color(62, 53, 41), titleBarColor = Color(111, 93, 69).darker(), - viewBackgroundColor = Color(111, 93, 69), + viewBackgroundColor = Color(101, 85, 63), primaryColor = Color(180, 150, 120), secondaryColor = Color(230, 210, 190), popupBackground = Color(70, 56, 42), diff --git a/plugin-playground/src/main/kotlin/KondoKit/plugin.kt b/plugin-playground/src/main/kotlin/KondoKit/plugin.kt index bc0f6b3..1fde673 100644 --- a/plugin-playground/src/main/kotlin/KondoKit/plugin.kt +++ b/plugin-playground/src/main/kotlin/KondoKit/plugin.kt @@ -46,7 +46,6 @@ import java.awt.event.ActionListener import java.awt.event.MouseAdapter import java.awt.event.MouseEvent import javax.swing.* -import javax.swing.plaf.nimbus.AbstractRegionPainter @Target(AnnotationTarget.FIELD)