2021-02-19 04:12:43 +00:00
|
|
|
package net.shadowfacts.phycon.screen
|
|
|
|
|
2021-02-27 04:23:11 +00:00
|
|
|
import net.minecraft.client.MinecraftClient
|
|
|
|
import net.minecraft.text.LiteralText
|
2021-02-19 04:12:43 +00:00
|
|
|
import net.minecraft.util.Identifier
|
|
|
|
import net.shadowfacts.cacao.CacaoScreen
|
2021-02-19 04:27:18 +00:00
|
|
|
import net.shadowfacts.cacao.window.Window
|
2021-02-19 04:12:43 +00:00
|
|
|
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
|
2021-02-27 04:23:11 +00:00
|
|
|
import net.shadowfacts.cacao.view.*
|
|
|
|
import net.shadowfacts.cacao.view.button.Button
|
2021-02-19 04:12:43 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2021-02-27 04:23:11 +00:00
|
|
|
val label = Label(LiteralText("Test"), wrappingMode = Label.WrappingMode.NO_WRAP).apply {
|
|
|
|
// textColor = Color.BLACK
|
|
|
|
}
|
|
|
|
// stack.addArrangedSubview(label)
|
|
|
|
val button = red.addSubview(Button(label))
|
|
|
|
|
2021-02-19 04:12:43 +00:00
|
|
|
view.solver.dsl {
|
|
|
|
stack.topAnchor equalTo 0
|
|
|
|
stack.centerXAnchor equalTo window!!.centerXAnchor
|
|
|
|
stack.widthAnchor equalTo 100
|
2021-02-27 04:23:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
button.centerXAnchor equalTo red.centerXAnchor
|
|
|
|
button.centerYAnchor equalTo red.centerYAnchor
|
|
|
|
// label.heightAnchor equalTo 9
|
|
|
|
button.heightAnchor equalTo 20
|
2021-02-19 04:12:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
addWindow(Window(viewController))
|
|
|
|
}
|
|
|
|
|
2021-02-27 04:23:11 +00:00
|
|
|
}
|