-
Notifications
You must be signed in to change notification settings - Fork 25
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
🎋 Fix #11: Id clash when using multiple Tree
s
#12
Conversation
e91f5a3
to
f5662bf
Compare
Ran into this issue today - I've pulled that PR in my fork - works. Thanks :) |
I'll rebase this once #13 lands, unless someone needs this sooner, if so let me know! |
f5662bf
to
ed81533
Compare
This PR marks `serde` as an option dependency and only derives the various `Serialize` and `Deserialize` traits when this feature is enabled. Regardless of not forcing the user to have the `serde` dependency, having the `serde` feature of `egui` (optionally) enabled is a requirement for #12.
ed81533
to
67b4cff
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
We should to add some docs to Tree
though to explain the purpose of this Id
. There is also a few doc-examples that need updating (hence the failing CI)
I'm finishing this up in #32 |
self.id = ui.id(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a mistake
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked at this wrongly you're right!
Sorry, this slipped my mind! I thought I enabled you to push to this branch, but fixing it in #32 is fine! |
* Closes #11 * (this is a fork of #12) --- Each `Tree` now has a globally unique id, meaning the same `Tree` can be rendered in different `Ui`:s and still work, and you can have multiple trees. However, it is up to the user to pick a globally unique id. --------- Co-authored-by: tosti007 <git@brianjanssen.nl>
Based on #13 (will update and rebase once that's in), to have the
egui/serde
dependency enabled.This PR is an implementation to solve issue #11.
This is achieved by storing an
egui::Id
for each tree. In order to get theTiledId::egui_id
theTree
's id is passed. The value of theTree
'sid
is determined by a user passed value, thus this is a breaking change.I opted to allow
serde
to serialize and deserialize the passed value, as adding aid_source
kind of function, which needs to be called after deserialization felt bad. I also opted to have the user pass anInto<egui::Id>
rather than obtaining it from theegui::Ui
passed in theTree::ui
function, as that will cause theTileId
s to break when the user draws the sameTree
within a differentUi
context.