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

Switch Widget Port #132

Closed
wants to merge 0 commits into from
Closed

Switch Widget Port #132

wants to merge 0 commits into from

Conversation

giannissc
Copy link
Contributor

No description provided.

Copy link
Contributor

@Philipp-M Philipp-M left a comment

Choose a reason for hiding this comment

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

Left a few comments.

I think something like an additional example showing this in action would be awesome (I think we should generally start with adding more examples, to get a feeling of the UX etc. and examples are good for testing as well)

src/view/switch.rs Outdated Show resolved Hide resolved
src/view/switch.rs Outdated Show resolved Hide resolved
src/view/switch.rs Outdated Show resolved Hide resolved
@giannissc
Copy link
Contributor Author

This was a good exercise! I think I understand a bit more the Xilem model. Thank for the comments they were really helpful :)

It's ready for another review! @Philipp-M

Copy link
Contributor

@Philipp-M Philipp-M left a comment

Choose a reason for hiding this comment

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

Just tried the example, looks nice :)

examples/hello.rs Outdated Show resolved Hide resolved
src/view/switch.rs Outdated Show resolved Hide resolved
@giannissc
Copy link
Contributor Author

Just rebased and force pushed with the new changes @Philipp-M

@giannissc giannissc marked this pull request as draft August 29, 2023 09:39
@giannissc giannissc marked this pull request as draft August 29, 2023 09:39
@giannissc giannissc marked this pull request as ready for review August 29, 2023 12:29
Copy link
Contributor

@Philipp-M Philipp-M left a comment

Choose a reason for hiding this comment

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

Sorry for the delay, haven't found the time till now...

Some nit-picks, not really that important.

I think this is good to merge when it's rebased (for the new CI workflows) and the CI is fixed (I think you can just disable clippy for that line), thanks!

I found a bug orthogonal to this PR while testing this, maybe I'll look into this (dragging the knob or pressing a button in the h_stack and then moving up to the top button and releasing the cursor)

pub struct Switch {
id_path: IdPath,
is_on: bool,
is_moved: bool,
Copy link
Contributor

Choose a reason for hiding this comment

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

(Slightly nit picky) I would name this something like is_dragging as I think it's more appropriate...

if self.is_on != (self.knob_position.x > SWITCH_WIDTH / 2.0) {
cx.add_message(Message::new(self.id_path.clone(), ()))
}
} else if cx.is_active() {
Copy link
Contributor

Choose a reason for hiding this comment

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

(Also super nit-picky, because it shouldn't really change the behavior, as a MouseMove event should happen before)

Suggested change
} else if cx.is_active() {
} else if cx.is_active() && cx.is_hot() {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am replying here even though I will be creating a new PR. The is_hot check I think is wrong here and the only reason it doesn't affect the behaviour is because no actual message is being send here. Had there been any message being sent to the view it would not have if the user moved past the boundaries of the widget. Good UX would be to ensure things function correctly even in light of errors from the user

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm I guess it really depends. A button is not clicked when the user releases it outside the button area. On touchscreens I agree with you though, or generally when the switch is dragged, but this should never be the case here, since is_dragging will be set before, so it doesn't really matter...

@Philipp-M
Copy link
Contributor

Is this supposed to be closed?

@giannissc
Copy link
Contributor Author

I know what happened here.. It was before I started using git extensively and I had all these into main instead of it's own branch so when synchronized my main to master I discarded my commits for the switch widget..

@jplatte
Copy link
Member

jplatte commented Nov 22, 2023

They are still recoverable though, GitHub keeps everything that's pushed to a PR: 6275db8 (parent commit are also available, and clickable in the web UI)

@giannissc
Copy link
Contributor Author

That's ok it was easy enough to start fresh. But I will keep this in mind next time this happens. Thanks!

@Philipp-M
Copy link
Contributor

I'm not sure though, whether it's possible to change the source branch (see https://stackoverflow.com/questions/42381557/changing-source-branch-for-pr-on-github)

So either you'll cherry-pick all the relevant commits onto your main branch and reopen this PR (after merging, you can of course sync with upstream main again), or you have to create a new PR with a different source branch.

@jplatte
Copy link
Member

jplatte commented Nov 22, 2023

It's not possible to reopen a PR after the branch that was used to create it is force-pushed while the PR is closed.

@Philipp-M
Copy link
Contributor

Oh really, interesting, thanks for letting me know.

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.

3 participants