Skip to content

egui: Add Deref<Target = Context> for Ui#4072

Closed
obellish wants to merge 8 commits intoemilk:mainfrom
obellish:master
Closed

egui: Add Deref<Target = Context> for Ui#4072
obellish wants to merge 8 commits intoemilk:mainfrom
obellish:master

Conversation

@obellish
Copy link
Copy Markdown
Contributor

@emilk
Copy link
Copy Markdown
Owner

emilk commented Mar 8, 2024

Does this mean we can remove .input() .memory etc from Ui?

@obellish
Copy link
Copy Markdown
Contributor Author

obellish commented Mar 8, 2024

I believe so, as any methods on ctx will be on Ui as well, so duplicate methods can go away

Co-authored-by: Emil Ernerfeldt <[email protected]>
@obellish
Copy link
Copy Markdown
Contributor Author

obellish commented Mar 8, 2024

I didn't include DerefMut but I could as it would allow for us to pass a &mut Ui where a &mut Context is expected.

@emilk
Copy link
Copy Markdown
Owner

emilk commented Mar 12, 2024

We shouldn't implement DerefMut, because a &mut Context in almost never needed. But we should remove the now redundant Ui::input etc

@obellish
Copy link
Copy Markdown
Contributor Author

Removed all the direct helper methods from Ui.

@emilk emilk changed the title add Deref<Target = Context> for Ui Add Deref<Target = Context> for Ui Mar 20, 2024
Copy link
Copy Markdown
Owner

@emilk emilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great - thank you!

@emilk
Copy link
Copy Markdown
Owner

emilk commented Mar 21, 2024

There are some cargo check failures

@obellish obellish changed the title Add Deref<Target = Context> for Ui egui: Add Deref<Target = Context> for Ui Mar 21, 2024
@obellish
Copy link
Copy Markdown
Contributor Author

Removed the unused deps!

@emilk
Copy link
Copy Markdown
Owner

emilk commented Mar 21, 2024

a docstring needs updating too

@obellish
Copy link
Copy Markdown
Contributor Author

Which one?

@emilk
Copy link
Copy Markdown
Owner

emilk commented Mar 22, 2024

Check the CI output:

Screenshot 2024-03-22 at 12 27 45

@emilk
Copy link
Copy Markdown
Owner

emilk commented Mar 25, 2024

I tried fixing this myself, but since you opened the PR from your own master it failed.

@TimTheBig
Copy link
Copy Markdown

Is there any plan to merge this? It would be nice

@emilk emilk closed this in 5ea94dd Dec 14, 2025
Masterchef365 pushed a commit to Masterchef365/egui that referenced this pull request Apr 3, 2026
* Closes emilk#4033
* Closes emilk#4072

This means you don't have to type `ui.ctx().foo` but just `ui.foo`

---------

Co-authored-by: obellish <[email protected]>
Co-authored-by: obellish <[email protected]>
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.

Implement Deref<Target = Context> for Ui

3 participants