Skip to content

Commit

Permalink
Fix text::State downcast in some widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
hecrj committed Jul 18, 2024
1 parent 1d1a5f1 commit c851e67
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion core/src/widget/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ where

/// The internal state of a [`Text`] widget.
#[derive(Debug, Default)]
pub struct State<P: Paragraph>(paragraph::Plain<P>);
pub struct State<P: Paragraph>(pub paragraph::Plain<P>);

impl<'a, Message, Theme, Renderer> Widget<Message, Theme, Renderer>
for Text<'a, Theme, Renderer>
Expand Down
4 changes: 3 additions & 1 deletion widget/src/checkbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,12 +358,14 @@ where

{
let label_layout = children.next().unwrap();
let state: &widget::text::State<Renderer::Paragraph> =
tree.state.downcast_ref();

crate::text::draw(
renderer,
defaults,
label_layout,
tree.state.downcast_ref(),
state.0.raw(),
crate::text::Style {
color: style.text_color,
},
Expand Down
4 changes: 3 additions & 1 deletion widget/src/radio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,12 +353,14 @@ where

{
let label_layout = children.next().unwrap();
let state: &widget::text::State<Renderer::Paragraph> =
tree.state.downcast_ref();

crate::text::draw(
renderer,
defaults,
label_layout,
tree.state.downcast_ref(),
state.0.raw(),
crate::text::Style {
color: style.text_color,
},
Expand Down
4 changes: 3 additions & 1 deletion widget/src/toggler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,12 +289,14 @@ where

if self.label.is_some() {
let label_layout = children.next().unwrap();
let state: &widget::text::State<Renderer::Paragraph> =
tree.state.downcast_ref();

crate::text::draw(
renderer,
style,
label_layout,
tree.state.downcast_ref(),
state.0.raw(),
crate::text::Style::default(),
viewport,
);
Expand Down

0 comments on commit c851e67

Please sign in to comment.