Add ignoreWhenSizingToContents

This commit is contained in:
DBotThePony 2025-02-17 19:38:12 +07:00
parent aa2e053c26
commit 6105328e85
Signed by: DBot
GPG Key ID: DCC23B5715498507
3 changed files with 19 additions and 2 deletions

View File

@ -1384,6 +1384,9 @@ open class EditablePanel<out S : Screen>(
parent?.updateBounds()
}
open val ignoreWhenSizingToContents: Boolean
get() = false
/**
* Attempts to tightly fit dimensions to all children
*/
@ -1405,8 +1408,10 @@ open class EditablePanel<out S : Screen>(
for (child in visibleChildrenInternal) {
when (child.dock) {
Dock.NONE -> {
width = maxOf(width, child.x + child.width)
height = maxOf(height, child.y + child.height)
if (!child.ignoreWhenSizingToContents) {
width = maxOf(width, child.x + child.width)
height = maxOf(height, child.y + child.height)
}
}
Dock.FILL -> {

View File

@ -34,6 +34,9 @@ open class FramePanel<out S : Screen>(
var isActive = tabs.isEmpty()
protected set
override val ignoreWhenSizingToContents: Boolean
get() = true
init {
tabs.add(this)
}
@ -197,6 +200,9 @@ open class FramePanel<out S : Screen>(
close()
}
override val ignoreWhenSizingToContents: Boolean
get() = true
override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
if (isPressed) {
CLOSE_BUTTON_PRESSED.render(graphics, 0f, 0f, width, height)
@ -223,6 +229,9 @@ open class FramePanel<out S : Screen>(
isActive = !isActive
}*/
override val ignoreWhenSizingToContents: Boolean
get() = true
override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
/*if (isPressed) {
HELP_BUTTON_PRESSED.render(graphics, 0f, 0f, width, height)

View File

@ -339,6 +339,9 @@ class DeviceControls<out S : MatteryScreen<*>>(
private var upgradeWindow: FramePanel<S>? = null
override val ignoreWhenSizingToContents: Boolean
get() = true
private val buttons = ArrayList<EditablePanel<S>>()
private fun alignButtons() {