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 reflected Map controls #155

Merged
merged 6 commits into from
Nov 5, 2023

Conversation

B-Reif
Copy link
Contributor

@B-Reif B-Reif commented Oct 11, 2023

This PR adds support for editing reflected Map values. Specifically:

  • mutable fields support for editing Map values in-place
  • adds 'remove element' buttons for each key-value pair
  • adds a 'draft element' field to edit and add new key-value pairs
image image

It should be noted the 'add element' draft implementation is pretty inefficient. It uses egui's IdTypeMap which internally clones the element, and also clones the element itself to move the value out of state for use. If we have a better way to store this (on the InspectorUi struct? in the Bevy world?) that would be an improvement.

@jakobhellermann jakobhellermann merged commit 7b2269e into jakobhellermann:main Nov 5, 2023
1 check passed
@jakobhellermann
Copy link
Owner

Very nice, thanks you!

It should be noted the 'add element' draft implementation is pretty inefficient. It uses egui's IdTypeMap which internally clones the element, and also clones the element itself to move the value out of state for use. If we have a better way to store this (on the InspectorUi struct? in the Bevy world?) that would be an improvement.

I think for an a feature like this it doesn't matter too much if this does some unnecessary clones. When it becomes obviously slow we can reconsider.

@B-Reif B-Reif deleted the hash-map-controls branch November 18, 2023 02:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants