Skip to content
This repository has been archived by the owner on Jun 5, 2024. It is now read-only.

remove Env type and Data trait #53

Closed
wants to merge 1 commit into from

Conversation

herkhinah
Copy link

@herkhinah herkhinah commented Mar 7, 2024

I've refactored out the Env type and Data trait. The crate compiles and the examples run. Fixes linebender/xilem#373

@herkhinah herkhinah changed the title WIP: remove Env data-type WIP: remove Env type and Data trait Mar 7, 2024
@herkhinah herkhinah force-pushed the shekhinah/remove-env branch from 0a84292 to f40944c Compare March 7, 2024 10:05
@herkhinah herkhinah changed the title WIP: remove Env type and Data trait remove Env type and Data trait Mar 7, 2024
@PoignardAzur
Copy link
Collaborator

Sorry for the late reply, I've been on vacation. I've only had time to skim this, but it looks like a clean refactor. Pretty high-quality contribution!

I've noticed a // TODO remove env in widget/flex.rs that you probably didn't mean to leave.

I'll take another look at this soon, and after that, we'll try to get this PR merged ASAP.

Copy link
Collaborator

@PoignardAzur PoignardAzur left a comment

Choose a reason for hiding this comment

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

Overall this seems like a clean set of changes. Once the items I mentioned are addressed, and the rustfmt and clippy errors are fixed, we can merge this ASAP.

By the way, please make sure to do any followup fixes in a separate commit (eg don't use rebase or git commit --amend) so the fixes don't get lost in this PR's huge changeset.

Comment on lines +693 to 696
// TODO remove env
/*
// paint the baseline if we're debugging layout
if env.get(Env::DEBUG_PAINT) && ctx.widget_state.baseline_offset != 0.0 {
Copy link
Collaborator

@PoignardAzur PoignardAzur Mar 16, 2024

Choose a reason for hiding this comment

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

The refactor needs to address these kinds of cases. I'd suggest adding debug_paint, debug_widget and debug_widget_id bool attributes to GlobalPassCtx and going from there.

Comment on lines +257 to +258
// TODO Env removal
/*
Copy link
Collaborator

Choose a reason for hiding this comment

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

See above.

Comment on lines +1042 to +1043
// TODO env removal
/*
Copy link
Collaborator

Choose a reason for hiding this comment

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

See above.

Comment on lines +1062 to +1063
// TODO: Env removal
/*
Copy link
Collaborator

Choose a reason for hiding this comment

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

See above.

Comment on lines +28 to +34
impl PartialEq for RichText {
fn eq(&self, other: &Self) -> bool {
Arc::ptr_eq(&self.buffer, &other.buffer) && Arc::ptr_eq(&self.attrs, &other.attrs) && Arc::ptr_eq(&self.links, &other.links)
}
}

impl Eq for RichText {}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is an invalid implementation of Eq and a dubious implementation of PartialEq. Two buffers with different pointer values but identical content shouldn't return false in PartialEq.

As a placeholder solution, I'd suggest adding a function called eg maybe_eq to the TextStorage trait with the same semantic as the now-removed Data::same(). We can think of a better design once this is merged.

@PoignardAzur
Copy link
Collaborator

FYI, I might rebase this PR on my side (or straight-up redo it from scratch) next week, since I'm actively working on Masonry now.

PoignardAzur added a commit that referenced this pull request Mar 26, 2024
Fix some clippy lints
Update text snapshots
Update documentation and examples
Update roadmap
Add debug properties to PaintCtx
Add maybe_eq method to TextStorage as a monkey-patch

---

Based on PR #53
by: Shekhinah Memmel <[email protected]>
@PoignardAzur
Copy link
Collaborator

I've done a bunch of changes on top of this PR and merged them. Thanks for the contribution!

@herkhinah
Copy link
Author

herkhinah commented Mar 28, 2024 via email

@PoignardAzur
Copy link
Collaborator

Shit. Good luck then.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove Env and Data
2 participants