package net.shadowfacts.asmr import net.shadowfacts.cacao.CacaoScreen import net.shadowfacts.cacao.Window import net.shadowfacts.cacao.view.* import net.shadowfacts.cacao.view.button.Button import net.shadowfacts.cacao.viewcontroller.ViewController /** * @author shadowfacts */ class TestCacaoScreen: CacaoScreen() { init { val viewController = object: ViewController() { override fun loadView() { this.view = View() } override fun viewDidLoad() { val container = view.addSubview(View()) createConstraints { container.centerXAnchor equalTo view.centerXAnchor container.centerYAnchor equalTo view.centerYAnchor } embedChild(object: ViewController() { override fun loadView() { val button = Button(Label("test button")) button.handler = { println("button clicked") } this.view = button } }, container = container) } } addWindow(Window(viewController)) } // init { // addWindow(Window().apply { // val stack = addView(StackView(Axis.VERTICAL, StackView.Distribution.CENTER, spacing = 4.0).apply { // backgroundColor = Color.WHITE // }) // val red = stack.addArrangedSubview(TextureView(Texture(Identifier("textures/block/birch_log_top.png"), 0, 0, 16, 16)).apply { // intrinsicContentSize = Size(50.0, 50.0) // }) // val green = stack.addArrangedSubview(NinePatchView(NinePatchTexture.PANEL_BG).apply { // intrinsicContentSize = Size(75.0, 100.0) // }) // val blue = stack.addArrangedSubview(View().apply { // intrinsicContentSize = Size(50.0, 50.0) // backgroundColor = Color(0x0000ff) // }) // val purple = blue.addSubview(DropdownButton( // initialValue = RedstoneMode.HIGH, // allValues = RedstoneMode.values().asIterable(), // createView = { Label(it.name) }, // updateView = { newValue, label -> label.text = newValue.name } // ).apply { // handler = { // println("dropdown value: ${it.value}") // val dialog = DialogView( // "New redstone mode", // it.value.name, // arrayOf(DialogView.DefaultButtonType.OK), // Texture(Identifier("textures/block/birch_log_top.png"), 0, 0, 16, 16), // buttonCallback = { _, window -> // window.removeFromScreen() // } // ) // val dialogWindow = Window() // dialogWindow.addView(dialog) // this@TestCacaoScreen.addWindow(dialogWindow) // } // }) // // val label = addView(Label("test ".repeat(100), maxLines = 5)) // // solver.dsl { // stack.topAnchor equalTo 0 // stack.centerXAnchor equalTo this@apply.centerXAnchor // stack.widthAnchor equalTo 100 // purple.centerXAnchor equalTo blue.centerXAnchor // purple.centerYAnchor equalTo blue.centerYAnchor //// purple.widthAnchor equalTo 50 // // label.topAnchor equalTo 0 // label.leftAnchor equalTo 0 // label.widthAnchor equalTo 100 // } // // //// val red = addView(View().apply { //// backgroundColor = Color(0xff0000) //// }) //// val green = addView(View().apply { //// backgroundColor = Color(0x00ff00) //// }) //// val blue = addView(View().apply { //// backgroundColor = Color(0x0000ff) //// }) //// val purple = green.addSubview(View().apply { //// backgroundColor = Color(0x800080) //// }) //// purple.intrinsicContentSize = Size(width = 150.0, height = 150.0) //// val label = purple.addSubview(Label("Hello, world!").apply { //// textColor = Color.WHITE //// }) //// //// solver.dsl { //// red.leftAnchor equalTo 0 //// red.widthAnchor equalTo 200 //// red.topAnchor equalTo 0 //// red.heightAnchor equalTo 100 //// //// green.leftAnchor equalTo (red.leftAnchor + red.widthAnchor + 20) //// green.widthAnchor equalTo red.widthAnchor //// green.topAnchor equalTo 0 //// green.heightAnchor equalTo (red.heightAnchor + 100) //// //// blue.leftAnchor equalTo green.leftAnchor //// blue.widthAnchor equalTo green.widthAnchor //// blue.topAnchor equalTo (green.topAnchor + green.heightAnchor) //// blue.heightAnchor equalTo 50 //// ////// purple.widthAnchor equalTo 100 ////// purple.heightAnchor equalTo 100 //// purple.centerXAnchor equalTo green.centerXAnchor //// purple.centerYAnchor equalTo green.centerYAnchor //// //// label.centerXAnchor equalTo purple.centerXAnchor //// label.centerYAnchor equalTo purple.centerYAnchor //// } //// //// layout() // }) // } }