-
Notifications
You must be signed in to change notification settings - Fork 333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MVC Pattern and Data Binding #25
Comments
This looks really interesting to me, I think I'd like something like this myself. Thanks for the suggestion. I think the Coherent approach can serve as a nice inspiration. Are there any particular features here you think are the most important? Also, if you have any suggestions for what the interface could look like, that would be great. |
If you want to use the Coherent approach then I would do something like this:
It's very important to implement a ViewModel class that has a PropertyChange notifier so whenever a property change, we can manually tell the UI to update a single property or the whole model. Example:
the binding might be a two-way type, that means that the UI can change the value through a setter. Example:
I would do a few changes in the DataGrid control as well
Would be also nice having a style binding like this:
In this case we are binding a boolean to a visibility converter. LibRocket in this particular case automatically converts the boolean to a string, but this is not always the case. Sometimes for particular values we might need some kind of Converters. Here we have two choices:
Another example for a possible converter:
Personally I prefer using converters as we don't always want to use scripting languages in libRocket, but both are valid ways to implement the thing. Last thing we would need to implement are the event triggers:
Generally the binding will be
EDIT: Ideally we should keep the code separated from the view. That's the logic behind it. EDIT2: Converters aren't a priority though as we could just avoid them by binding get() and set() methods for the properties rather than binding the properties directly:
|
Thanks for the writeup, looks like a good start to me! Yes, I also think whichever solution we go for, all the capabilities should be available from the C++-API. You seem to have thought quite well through this, do you wish to give this a go? Otherwise, I can take a stab at this, but it might be awhile before I have time to really look at this. |
We've had support for data bindings in the master branch for a while now. Closing this now, however, users are still encouraged to provide feedback and bug reports in new issues. |
Is there any way to see this feature implemented just like AngularJS or CoherentGT?
Some examples:
https://www.w3schools.com/angular/angular_databinding.asp
https://coherent-labs.com/Documentation/cpp-gt/df/dfb/_h_t_m_l_data_binding.html
Also would be cool to create DataTemplates through bindings and converters.
The text was updated successfully, but these errors were encountered: