aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/firmament/gui/WFixedPanel.kt
blob: 0fd724bc138cecb3ce7457aa9d06a575770d3099 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*
 * SPDX-FileCopyrightText: 2023 Linnea Gräf <nea@nea.moe>
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 */

package moe.nea.firmament.gui

import io.github.cottonmc.cotton.gui.widget.WPanel
import io.github.cottonmc.cotton.gui.widget.WWidget

class WFixedPanel() : WPanel() {
    var child: WWidget
        set(value) {
            children.clear()
            setSize(0, 0)
            value.parent = this
            children.add(value)
        }
        get() = children.single()

    constructor(child: WWidget) : this() {
        this.child = child
    }

    override fun layout() {
        setSize(0, 0)
        super.layout()
    }

    override fun canResize(): Boolean = false
}