msink / kotlin-libui

Kotlin/Native interop to libui: a portable GUI library
MIT License
650 stars 50 forks source link

Data-binding #8

Open andreas-mausch opened 5 years ago

andreas-mausch commented 5 years ago

Do you plan to support some kind of data-binding?

I think of it in a way that you pass a model object (Observable?) to a TextField, and each time the string is changed, the UI is changed as well.

And, additionally, each time the user types into the TextField, the model object get's changed automatically.

msink commented 5 years ago

As general direction - yes, it should support some data-binding, but I think it should be separate library.

No concrete plans for now.

mervyn-mccreight commented 5 years ago

Hello,

we (@andreas-mausch and me) would like to work on it. We already have a prototype version of this running (included in the DSL, not a separate library), but we are not sure how to test it. We found some files in the test directory, but can not make any sense of them. How can we write unit-tests for the stuff we came up with?

Our prototype is implementing the same as you can see in this vueJS example here: https://vuejs.org/v2/guide/#Handling-User-Input (app-6) -- the one with the input and the text.

msink commented 5 years ago

About tests - test directory was here from very early days of development, and still not used. Maybe it should be removed or cleaned - I still don't figure out how to test this correctly.

Anyway it too should wait for migration to 'multiplatform' plugin.

andreas-mausch commented 5 years ago

@msink Can you take a look at the changes in this branch and tell us if you like it? https://github.com/mervyn-mccreight/kotlin-libui/tree/data-binding

Just check the new examples data-binding-1 and 2 to get an impression.

It's not complete yet, and we want to rename "ModelEntry" to "Property" to be more similar to TornadoFX. But if you in general like what we did, I would continue on implementing ObservableLists for ComboBoxes and ListViews.

msink commented 5 years ago

I'm not competent in this area, but to me it looks overcomplicated. Can it be just some data class, something like is done for tables? checkbox(Data::checkbox)

Maybe more clean way could be using coroutines.