Skip to content

Atoms<'a> retreiver#8128

Open
Nashvill375 wants to merge 19 commits into
emilk:mainfrom
Nashvill375:feature
Open

Atoms<'a> retreiver#8128
Nashvill375 wants to merge 19 commits into
emilk:mainfrom
Nashvill375:feature

Conversation

@Nashvill375
Copy link
Copy Markdown

A get atoms trait for Button, checkbox etc. I made it because I had time to kill after I tried sorting buttons in a Vec by the image in their atoms, but couldn't get to it because it was private.

@github-actions
Copy link
Copy Markdown

Preview is being built...

Preview will be available at https://egui-pr-preview.github.io/pr/8128-feature

View snapshot changes at kitdiff

@Nashvill375
Copy link
Copy Markdown
Author

I accidentally did something that closed this pull request. Sorry if somebody got duped email.

Comment thread crates/egui/src/atomics/get_atoms.rs Outdated
@@ -0,0 +1,28 @@
pub trait GetAtoms<'a> {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hmm, why a trait and not just adding the fn to each struct?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Honestly? IDK

Comment thread crates/egui/src/atomics/get_atoms.rs Outdated
}

impl<'a> GetAtoms<'a> for Button<'a> {
pub fn text(self) -> Atoms<'a> {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why does it take self? Isn't that annoying? Maybe &self returning &Atoms would be nicer

Copy link
Copy Markdown
Author

@Nashvill375 Nashvill375 Apr 23, 2026

Choose a reason for hiding this comment

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

Honestly I don’t understand references enough to see why it matters, which is not to say it doesn’t because I really don’t know, but I’ll fix it either way. Thanks!

Comment thread crates/egui/src/atomics/get_atoms.rs Outdated
@@ -0,0 +1,28 @@
pub trait GetAtoms<'a> {
pub fn text(self) -> Atoms<'a>;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think it should be called fn atoms() instead

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

👍

@Nashvill375
Copy link
Copy Markdown
Author

Made the last few commits on my phone because I don’t have access to WiFi. I’ll check for issues and add documentation when I can use WiFi.

@Nashvill375
Copy link
Copy Markdown
Author

Should I be adding #[inline] to the atoms functions?

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