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

checkbox: add from_label constructor #2111

Merged
merged 2 commits into from
Jan 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ You can find its changes [documented below](#070---2021-01-01).
- Scope: expose scoped state using state() and state_mut() ([#2082] by [@rjwittams]
- Tabs: allow getting and setting the tab index of a Tabs widget ([#2082] by [@rjwittams]
- `RangeSlider` and `Annotated` ([#1979] by [@xarvic])
- Add `Checkbox::from_label` constructor ([#2111] by [@maurerdietmar])
Copy link
Collaborator

Choose a reason for hiding this comment

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

[#2111] should be a link to your PR. There is a list of links at the end of this file.


### Changed

Expand Down Expand Up @@ -532,6 +533,7 @@ Last release without a changelog :(
[@klemensn]: https://github.com/klemensn
[@agentsim]: https://github.com/agentsim
[@jplatte]: https://github.com/jplatte
[@maurerdietmar]: https://github.com/maurerdietmar

[#599]: https://github.com/linebender/druid/pull/599
[#611]: https://github.com/linebender/druid/pull/611
Expand Down Expand Up @@ -814,6 +816,7 @@ Last release without a changelog :(
[#2036]: https://github.com/linebender/druid/pull/2036
[#2064]: https://github.com/linebender/druid/pull/2064
[#1979]: https://github.com/linebender/druid/pull/1979
[#2111]: https://github.com/linebender/druid/pull/2111

[Unreleased]: https://github.com/linebender/druid/compare/v0.7.0...master
[0.7.0]: https://github.com/linebender/druid/compare/v0.6.0...v0.7.0
Expand Down
9 changes: 6 additions & 3 deletions druid/src/widget/checkbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ pub struct Checkbox {
impl Checkbox {
/// Create a new `Checkbox` with a text label.
pub fn new(text: impl Into<LabelText<bool>>) -> Checkbox {
Checkbox {
child_label: Label::new(text),
}
Self::from_label(Label::new(text))
}

/// Create a new `Checkbox` with the provided [`Label`].
pub fn from_label(label: Label<bool>) -> Checkbox {
Checkbox { child_label: label }
}

/// Update the text label.
Expand Down