Skip to content

Commit

Permalink
fix: force layout of width Fill when requested for the text
Browse files Browse the repository at this point in the history
  • Loading branch information
wash2 committed Dec 5, 2023
1 parent 2f67ad8 commit 4dc1fce
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/widget/cosmic_toggler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use iced_core::{
alignment, event, layout, mouse, renderer, text,
widget::{self, tree, Tree},
Clipboard, Element, Event, Layout, Length, Pixels, Rectangle, Shell, Widget,
Clipboard, Element, Event, Layout, Length, Pixels, Rectangle, Shell, Size, Widget,
};

use crate::{
Expand Down Expand Up @@ -174,7 +174,7 @@ where
.state
.downcast_mut::<iced_widget::text::State<Renderer::Paragraph>>();

iced_core::widget::text::layout(
let node = iced_core::widget::text::layout(
state,
renderer,
limits,
Expand All @@ -187,7 +187,17 @@ where
self.text_alignment,
alignment::Vertical::Top,
self.text_shaping,
)
);
match self.width {
Length::Fill => {
let size = node.size();
layout::Node::with_children(
Size::new(limits.width(Length::Fill).max().width, size.height),
vec![node],
)
}
_ => node,
}
} else {
layout::Node::new(iced_core::Size::ZERO)
}
Expand Down

0 comments on commit 4dc1fce

Please sign in to comment.