Skip to content
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

Add data bindings #414

Merged
merged 4 commits into from Mar 12, 2023
Merged

Add data bindings #414

merged 4 commits into from Mar 12, 2023

Conversation

AaronErhardt
Copy link
Member

@AaronErhardt AaronErhardt commented Feb 22, 2023

Summary

Fixes #377

This WIP and currently meant as RFC.

This PR adds support for data bindings in the form of special GObjects that just store one value.
The interesting part is, that these objects have - similar to factories - a guard() method that creates an RAII guard.
This guard implements Deref and DerefMut for the actual data type you want to access, which makes it more convenient than using getter and setter methods.

For objects and widgets with a property that describes their state it is made even easier to connect a binding.
For example, ToggleButton has an "active" bool property that indicates whether the button is active or not.
This will most likely be the information you want, so a special trait provides the with_binding() constructor method to directly bind the state to the binding.

Check out the data_binding example to get a better idea of what I'm talking about :)

CC @Ayush1325

Checklist

  • cargo fmt
  • cargo clippy
  • cargo test
  • updated CHANGES.md

@AaronErhardt AaronErhardt marked this pull request as ready for review March 12, 2023 22:10
@AaronErhardt AaronErhardt changed the title core: WIP data bindings Add data bindings Mar 12, 2023
@AaronErhardt AaronErhardt added the waits-on-review-medium A PR that's not trivial to review but also doesn't require in depth knowledge label Mar 12, 2023
@AaronErhardt AaronErhardt merged commit dc2dda8 into next Mar 12, 2023
6 checks passed
@AaronErhardt AaronErhardt deleted the data-bindings branch March 12, 2023 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waits-on-review-medium A PR that's not trivial to review but also doesn't require in depth knowledge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant