consistent sizing

This commit is contained in:
downthecrop 2025-10-23 13:33:44 -07:00
parent 16546ef862
commit 14b107861e
11 changed files with 343 additions and 336 deletions

View file

@ -2,6 +2,7 @@ package KondoKit.components
import KondoKit.Helpers
import KondoKit.Helpers.FieldNotifier
import KondoKit.ViewConstants
import KondoKit.plugin.Companion.WIDGET_COLOR
import KondoKit.plugin.Companion.primaryColor
import KondoKit.plugin.Companion.secondaryColor
@ -62,7 +63,7 @@ class SettingsPanel(private val plugin: Plugin) : JPanel() {
val label = JLabel(field.name.capitalize()).apply {
foreground = secondaryColor
font = Font("RuneScape Small", Font.TRUETYPE_FONT, 16)
font = ViewConstants.FONT_RUNESCAPE_SMALL_16
}
gbc.gridx = 0
gbc.gridy = 0
@ -229,7 +230,7 @@ class SettingsPanel(private val plugin: Plugin) : JPanel() {
// Create title label
val titleLabel = JLabel("${field.name} (Key-Value Pairs)").apply {
foreground = secondaryColor
font = Font("RuneScape Small", Font.TRUETYPE_FONT, 16)
font = ViewConstants.FONT_RUNESCAPE_SMALL_16
alignmentX = Component.LEFT_ALIGNMENT
// Add mouse listener to the label only if a description is available
@ -451,14 +452,14 @@ class SettingsPanel(private val plugin: Plugin) : JPanel() {
var customToolTipWindow: JWindow? = null
fun showCustomToolTip(text: String, component: JComponent) {
val _font = Font("RuneScape Small", Font.PLAIN, 16)
val tooltipFont = ViewConstants.FONT_RUNESCAPE_SMALL_PLAIN_16
val maxWidth = 150
val lineHeight = 16
// Create a dummy JLabel to get FontMetrics for the font used in the tooltip
val dummyLabel = JLabel()
dummyLabel.font = _font
val fontMetrics = dummyLabel.getFontMetrics(_font)
dummyLabel.font = tooltipFont
val fontMetrics = dummyLabel.getFontMetrics(tooltipFont)
val lineHeight = fontMetrics.height
// Calculate the approximate width of the text
val textWidth = fontMetrics.stringWidth(text)
@ -478,7 +479,7 @@ class SettingsPanel(private val plugin: Plugin) : JPanel() {
isOpaque = true
background = KondoKit.plugin.Companion.TOOLTIP_BACKGROUND
foreground = Color.WHITE
font = _font
font = tooltipFont
maximumSize = Dimension(maxWidth, Int.MAX_VALUE)
preferredSize = Dimension(maxWidth, requiredHeight)
}
@ -500,4 +501,4 @@ class SettingsPanel(private val plugin: Plugin) : JPanel() {
customToolTipWindow!!.isVisible = true
}
}
}
}