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

Spinner widget #1003

Merged
merged 5 commits into from
Jun 1, 2020
Merged

Spinner widget #1003

merged 5 commits into from
Jun 1, 2020

Conversation

futurepaul
Copy link
Collaborator

This is pretty basic except for the spinning math, which I wish I'd commented while I was writing it!

My layout strategy for this is to only match its container size if that container has a constrained height and width. Otherwise it uses the default widget height key to size itself. Does that sound reasonable?

ezgif-6-18988e9ac782

Copy link
Member

@xStrom xStrom left a comment

Choose a reason for hiding this comment

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

Looks promising!

CHANGELOG.md Outdated Show resolved Hide resolved
/// The argument can be either a `Color` or a [`Key<Color>`].
///
/// [`Key<Color>`]: ../struct.Key.html
pub fn set_color(&mut self, color: impl Into<KeyOrValue<Color>>) {
Copy link
Member

Choose a reason for hiding this comment

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

These two color methods should mention in their docs that the alpha channel is ignored.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah that was an oversight. Fixed it to use the color's alpha.

druid/src/widget/spinner.rs Outdated Show resolved Hide resolved

impl Default for Spinner {
fn default() -> Self {
Spinner::new()
Copy link
Member

Choose a reason for hiding this comment

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

Can't we use theme::LABEL_COLOR.into(), in the Default implementation?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure what you're proposing here.

Copy link
Member

@xStrom xStrom Jun 1, 2020

Choose a reason for hiding this comment

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

So the reason you got that clippy warning was because the new function doesn't take any arguments and could be equal to default. So what I'm thinking is that we could do the following:

impl Spinner {
    /// Create a spinner widget
    pub fn new() -> Spinner {
        Spinner::default()
    }
}

impl Default for Spinner {
    fn default() -> Self {
        Spinner {
            t: 0.0,
            color: theme::LABEL_COLOR.into(),
        }
    }
}

It ends up being the same result for now, but if the new method gets arguments added to it then it'll be an easier change. This doesn't matter too much, but I'm just thinking I might somewhat prefer to have the default function be explicit.

Your call.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah, that makes sense! Thanks for explaining.

@xStrom xStrom added S-waiting-on-author waits for changes from the submitter widget concerns a particular widget labels Jun 1, 2020
@futurepaul futurepaul added S-needs-review waits for review and removed S-waiting-on-author waits for changes from the submitter labels Jun 1, 2020
Copy link
Member

@xStrom xStrom left a comment

Choose a reason for hiding this comment

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

I think it's in a good enough state to be merged.

Copy link
Collaborator

@luleyleo luleyleo left a comment

Choose a reason for hiding this comment

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

Looks good.

@luleyleo luleyleo removed the S-needs-review waits for review label Jun 1, 2020
@futurepaul futurepaul merged commit a63eba8 into linebender:master Jun 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
widget concerns a particular widget
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants