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

View File

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