56 lines
1.7 KiB
Kotlin
56 lines
1.7 KiB
Kotlin
package net.shadowfacts.phycon.screen
|
|
|
|
import net.minecraft.util.Identifier
|
|
import net.shadowfacts.cacao.CacaoScreen
|
|
import net.shadowfacts.cacao.window.Window
|
|
import net.shadowfacts.cacao.geometry.Axis
|
|
import net.shadowfacts.cacao.geometry.Size
|
|
import net.shadowfacts.cacao.util.Color
|
|
import net.shadowfacts.cacao.util.texture.NinePatchTexture
|
|
import net.shadowfacts.cacao.util.texture.Texture
|
|
import net.shadowfacts.cacao.view.NinePatchView
|
|
import net.shadowfacts.cacao.view.StackView
|
|
import net.shadowfacts.cacao.view.TextureView
|
|
import net.shadowfacts.cacao.view.View
|
|
import net.shadowfacts.cacao.viewcontroller.ViewController
|
|
import net.shadowfacts.kiwidsl.dsl
|
|
|
|
/**
|
|
* @author shadowfacts
|
|
*/
|
|
class TestCacaoScreen: CacaoScreen() {
|
|
|
|
init {
|
|
val viewController = object: ViewController() {
|
|
override fun loadView() {
|
|
view = View()
|
|
}
|
|
|
|
override fun viewDidLoad() {
|
|
super.viewDidLoad()
|
|
|
|
val stack = view.addSubview(StackView(Axis.VERTICAL, StackView.Distribution.CENTER, spacing = 4.0)).apply {
|
|
backgroundColor = Color.WHITE
|
|
}
|
|
val birch = stack.addArrangedSubview(TextureView(Texture(Identifier("textures/block/birch_log_top.png"), 0, 0, 16, 16))).apply {
|
|
intrinsicContentSize = Size(50.0, 50.0)
|
|
}
|
|
val ninePatch = stack.addArrangedSubview(NinePatchView(NinePatchTexture.PANEL_BG)).apply {
|
|
intrinsicContentSize = Size(75.0, 100.0)
|
|
}
|
|
val red = stack.addArrangedSubview(View()).apply {
|
|
intrinsicContentSize = Size(50.0, 50.0)
|
|
backgroundColor = Color.RED
|
|
}
|
|
|
|
view.solver.dsl {
|
|
stack.topAnchor equalTo 0
|
|
stack.centerXAnchor equalTo window!!.centerXAnchor
|
|
stack.widthAnchor equalTo 100
|
|
}
|
|
}
|
|
}
|
|
addWindow(Window(viewController))
|
|
}
|
|
|
|
} |