Better spacing changes

This commit is contained in:
downthecrop 2025-10-23 14:43:43 -07:00
parent 14b107861e
commit 8679bca47a
5 changed files with 56 additions and 21 deletions

View file

@ -24,7 +24,7 @@ object ViewConstants {
val DEFAULT_WIDGET_SIZE = Dimension(234, 50)
val PLUGIN_LIST_ITEM_SIZE = Dimension(DEFAULT_WIDGET_SIZE.width, 60)
val TOGGLE_PLACEHOLDER_SIZE = Dimension(60, 24)
val TOTAL_XP_WIDGET_SIZE = Dimension(220, 30)
val TOTAL_XP_WIDGET_SIZE = Dimension(DEFAULT_WIDGET_SIZE.width, 42)
val IMAGE_SIZE = Dimension(25, 23)
val SEARCH_FIELD_SIZE = Dimension(DEFAULT_WIDGET_SIZE.width, 30)
val DEFAULT_PANEL_SIZE = Dimension(DEFAULT_WIDGET_SIZE.width, 500)

View file

@ -10,7 +10,11 @@ import javax.swing.JPanel
class WidgetPanel(
private val widgetWidth: Int = ViewConstants.DEFAULT_WIDGET_SIZE.width,
private val widgetHeight: Int = ViewConstants.DEFAULT_WIDGET_SIZE.height,
private val addDefaultPadding: Boolean = true
private val addDefaultPadding: Boolean = true,
private val paddingTop: Int? = null,
private val paddingLeft: Int? = null,
private val paddingBottom: Int? = null,
private val paddingRight: Int? = null
) : JPanel() {
init {
@ -25,11 +29,12 @@ class WidgetPanel(
maximumSize = size
minimumSize = size
if (addDefaultPadding) {
border = BorderFactory.createEmptyBorder(5, 5, 5, 5)
} else {
border = BorderFactory.createEmptyBorder(0, 0, 0, 0)
}
val top = paddingTop ?: if (addDefaultPadding) 5 else 0
val left = paddingLeft ?: if (addDefaultPadding) 5 else 0
val bottom = paddingBottom ?: if (addDefaultPadding) 5 else 0
val right = paddingRight ?: if (addDefaultPadding) 5 else 0
border = BorderFactory.createEmptyBorder(top, left, bottom, right)
}
fun setFixedSize(width: Int, height: Int) {

View file

@ -37,8 +37,8 @@ annotation class Exposed(val description: String = "")
class plugin : Plugin() {
companion object {
val WIDGET_SIZE = Dimension(220, 50)
val TOTAL_XP_WIDGET_SIZE = Dimension(220, 30)
val WIDGET_SIZE = ViewConstants.DEFAULT_WIDGET_SIZE
val TOTAL_XP_WIDGET_SIZE = ViewConstants.TOTAL_XP_WIDGET_SIZE
val IMAGE_SIZE = Dimension(25, 23)
// Default Theme Colors

View file

@ -9,6 +9,7 @@ import KondoKit.ViewConstants
import KondoKit.views.XPTrackerView.wrappedWidget
import KondoKit.components.PopupMenuComponent
import KondoKit.components.ProgressBar
import KondoKit.components.WidgetPanel
import KondoKit.plugin.Companion.POPUP_BACKGROUND
import KondoKit.plugin.Companion.POPUP_FOREGROUND
import KondoKit.plugin.Companion.TITLE_BAR_COLOR
@ -136,7 +137,7 @@ object LootTrackerView : View, OnPostClientTickCallback, OnKillingBlowNPCCallbac
add(Box.createVerticalStrut(5))
totalTrackerWidget = createTotalLootWidget()
val wrapped = wrappedWidget(totalTrackerWidget!!.container)
val wrapped = wrappedWidget(totalTrackerWidget!!.container, padding = 0)
val popupMenu = resetLootTrackerMenu()
// Create a custom MouseListener
@ -197,7 +198,7 @@ object LootTrackerView : View, OnPostClientTickCallback, OnKillingBlowNPCCallbac
)
}
private fun createWidgetPanel(bufferedImageSprite: BufferedImage, l1 : JLabel, l2 : JLabel): Panel {
private fun createWidgetPanel(bufferedImageSprite: BufferedImage, l1 : JLabel, l2 : JLabel): WidgetPanel {
val imageCanvas = ImageCanvas(bufferedImageSprite).apply {
preferredSize = Dimension(bufferedImageSprite.width, bufferedImageSprite.height)
minimumSize = preferredSize
@ -206,21 +207,33 @@ object LootTrackerView : View, OnPostClientTickCallback, OnKillingBlowNPCCallbac
background = WIDGET_COLOR
}
val imageContainer = Panel(BorderLayout()).apply {
val imageContainer = JPanel(BorderLayout()).apply {
background = WIDGET_COLOR
add(imageCanvas, BorderLayout.NORTH)
border = BorderFactory.createEmptyBorder(-2, 0, 0, 0)
}
return Panel(BorderLayout(5, 0)).apply {
background = WIDGET_COLOR
preferredSize = TOTAL_XP_WIDGET_SIZE
return WidgetPanel(
widgetWidth = ViewConstants.DEFAULT_WIDGET_SIZE.width,
widgetHeight = ViewConstants.TOTAL_XP_WIDGET_SIZE.height,
addDefaultPadding = false,
paddingTop = 10,
paddingBottom = 10,
paddingRight = 10,
paddingLeft = 10
).apply {
layout = BorderLayout(5, 0)
setFixedSize(
ViewConstants.DEFAULT_WIDGET_SIZE.width,
ViewConstants.TOTAL_XP_WIDGET_SIZE.height
)
add(imageContainer, BorderLayout.WEST)
add(createTextPanel(l1,l2), BorderLayout.CENTER)
}
}
private fun createTextPanel(l1 : JLabel, l2: JLabel): Panel {
return Panel(GridLayout(2, 1, 5, 0)).apply {
private fun createTextPanel(l1 : JLabel, l2: JLabel): JPanel {
return JPanel(GridLayout(2, 1, 5, 0)).apply {
background = WIDGET_COLOR
add(l1)
add(l2)
@ -591,7 +604,7 @@ object LootTrackerView : View, OnPostClientTickCallback, OnKillingBlowNPCCallbac
lootItemPanels.clear()
totalTrackerWidget = createTotalLootWidget()
val wrapped = wrappedWidget(totalTrackerWidget!!.container)
val wrapped = wrappedWidget(totalTrackerWidget!!.container, padding = 0)
val _popupMenu = resetLootTrackerMenu()
// Create a custom MouseListener

View file

@ -140,7 +140,7 @@ object XPTrackerView : View, OnUpdateCallback, OnXPUpdateCallback {
private fun createTotalWidgetContainer(popupMenu: JPopupMenu): Container {
totalXPWidget = createTotalXPWidget()
return wrappedWidget(totalXPWidget!!.container).also { attachPopup(it, popupMenu) }
return wrappedWidget(totalXPWidget!!.container, padding = 0).also { attachPopup(it, popupMenu) }
}
override val panel: JPanel
@ -294,7 +294,15 @@ object XPTrackerView : View, OnUpdateCallback, OnXPUpdateCallback {
}
fun createTotalXPWidget(): XPWidget {
val widgetPanel = WidgetPanel(TOTAL_XP_WIDGET_SIZE.width, TOTAL_XP_WIDGET_SIZE.height, addDefaultPadding = false)
val widgetPanel = WidgetPanel(
widgetWidth = ViewConstants.DEFAULT_WIDGET_SIZE.width,
widgetHeight = ViewConstants.TOTAL_XP_WIDGET_SIZE.height,
addDefaultPadding = false,
paddingTop = 10,
paddingBottom = 10,
paddingRight = 10,
paddingLeft = 10
)
val iconContainer = createIconContainer(getBufferedImageFromSprite(API.GetSprite(LVL_ICON)))
@ -308,6 +316,11 @@ object XPTrackerView : View, OnUpdateCallback, OnXPUpdateCallback {
textPanel.add(xpGainedLabel)
textPanel.add(xpPerHourLabel)
widgetPanel.setFixedSize(
ViewConstants.DEFAULT_WIDGET_SIZE.width,
ViewConstants.TOTAL_XP_WIDGET_SIZE.height
)
widgetPanel.add(iconContainer, BorderLayout.WEST)
widgetPanel.add(textPanel, BorderLayout.CENTER)
@ -403,7 +416,11 @@ object XPTrackerView : View, OnUpdateCallback, OnXPUpdateCallback {
fun createXPWidget(skillId: Int, previousXp: Int): XPWidget {
val widgetPanel = WidgetPanel(WIDGET_SIZE.width, WIDGET_SIZE.height, addDefaultPadding = false)
val widgetPanel = WidgetPanel(
widgetWidth = ViewConstants.DEFAULT_WIDGET_SIZE.width,
widgetHeight = ViewConstants.DEFAULT_WIDGET_SIZE.height,
addDefaultPadding = false
)
val iconContainer = createIconContainer(getSkillIcon(skillId))