aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/com/raeids/stratus/gui/components/TextBlock.kt
blob: 63b3d0131274e58f1a73a67e0a1cdb4898c34090 (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
33
34
35
36
37
38
39
40
41
package com.raeids.stratus.gui.components

import gg.essential.elementa.components.UIBlock
import gg.essential.elementa.components.UIText
import gg.essential.elementa.constraints.ChildBasedSizeConstraint
import gg.essential.elementa.dsl.*
import gg.essential.elementa.effects.OutlineEffect
import gg.essential.elementa.state.BasicState
import gg.essential.vigilance.gui.VigilancePalette
import gg.essential.vigilance.gui.settings.SettingComponent

/**
 * Heavily modified from Vigilance under LGPLv3 (modified to be just a text block)
 * https://github.com/Sk1erLLC/Vigilance/blob/master/LICENSE
 */
class TextBlock(
    text: String
) : SettingComponent() {
    private val textHolder = UIBlock() constrain {
        width = ChildBasedSizeConstraint() + 6.pixels()
        height = ChildBasedSizeConstraint() + 6.pixels()
        color = VigilancePalette.getDarkHighlight().toConstraint()
    } childOf this effect OutlineEffect(
        VigilancePalette.getDivider(),
        1f
    ).bindColor(BasicState(VigilancePalette.getDivider()))

    private val text: UIText = UIText(text) constrain {
        x = 3.pixels()
        y = 3.pixels()
    }

    init {
        this.text childOf textHolder

        constrain {
            width = ChildBasedSizeConstraint()
            height = ChildBasedSizeConstraint()
        }
    }
}