Additional theme support + dynamic scrolling for resized views

This commit is contained in:
downthecrop 2024-10-23 15:59:29 -07:00
parent fce9b4eea7
commit c917981ef8
3 changed files with 6 additions and 3 deletions

View file

@ -17,6 +17,7 @@ class ScrollablePanel(private val content: JPanel) : JPanel() {
private var scrollbarY = 0 private var scrollbarY = 0
private var showScrollbar = false private var showScrollbar = false
private var draggingScrollPill = false private var draggingScrollPill = false
private var lastSize = 0
// Define a buffer for the view height (extra space for smoother scrolling) // Define a buffer for the view height (extra space for smoother scrolling)
private val viewBuffer = -30 private val viewBuffer = -30
@ -68,6 +69,8 @@ class ScrollablePanel(private val content: JPanel) : JPanel() {
Timer().schedule(object : TimerTask() { Timer().schedule(object : TimerTask() {
override fun run() { override fun run() {
updateScrollbar() updateScrollbar()
if(lastSize != content.preferredSize.height.coerceAtLeast(frame.height + viewBuffer))
handleResize()
} }
}, 0, 1000) }, 0, 1000)
@ -84,7 +87,8 @@ class ScrollablePanel(private val content: JPanel) : JPanel() {
bounds = Rectangle(0, 0, 242, frame.height) bounds = Rectangle(0, 0, 242, frame.height)
// Dynamically update content bounds and scrollbar on frame resize with buffer // 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 showScrollbar = content.height > frame.height
currentOffsetY = 0 currentOffsetY = 0

View file

@ -60,7 +60,7 @@ object Themes {
ThemeType.SARADOMIN -> Theme( ThemeType.SARADOMIN -> Theme(
widgetColor = Color(62, 53, 41), widgetColor = Color(62, 53, 41),
titleBarColor = Color(111, 93, 69).darker(), titleBarColor = Color(111, 93, 69).darker(),
viewBackgroundColor = Color(111, 93, 69), viewBackgroundColor = Color(101, 85, 63),
primaryColor = Color(180, 150, 120), primaryColor = Color(180, 150, 120),
secondaryColor = Color(230, 210, 190), secondaryColor = Color(230, 210, 190),
popupBackground = Color(70, 56, 42), popupBackground = Color(70, 56, 42),

View file

@ -46,7 +46,6 @@ import java.awt.event.ActionListener
import java.awt.event.MouseAdapter import java.awt.event.MouseAdapter
import java.awt.event.MouseEvent import java.awt.event.MouseEvent
import javax.swing.* import javax.swing.*
import javax.swing.plaf.nimbus.AbstractRegionPainter
@Target(AnnotationTarget.FIELD) @Target(AnnotationTarget.FIELD)