Created
August 3, 2022 00:52
-
-
Save mtkennerly/a61f945a652d2d7cd54181fc16f37538 to your computer and use it in GitHub Desktop.
Iced issue with container width+max_width
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[package] | |
name = "repro-width-and-max" | |
version = "0.1.0" | |
edition = "2021" | |
[dependencies] | |
# iced = "0.4.2" | |
iced = { git = "https://github.com/iced-rs/iced.git", rev = "c44267b85f7aaa2997e3caf1323b837d95818c22" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use iced::{alignment::Horizontal, Column, Container, Element, Length, Row, Sandbox, Settings, Text}; | |
pub fn main() -> iced::Result { | |
Demo::run(Settings::default()) | |
} | |
struct Demo {} | |
#[derive(Debug, Clone)] | |
enum Message {} | |
impl Sandbox for Demo { | |
type Message = Message; | |
fn new() -> Self { | |
Demo {} | |
} | |
fn title(&self) -> String { | |
String::from("Repro - Iced") | |
} | |
fn update(&mut self, _message: Message) {} | |
fn view(&mut self) -> Element<Message> { | |
Column::new() | |
.spacing(10) | |
.push( | |
Row::new() | |
.spacing(10) | |
.width(Length::Fill) | |
.push( | |
Container::new( | |
Text::new("start") | |
.width(Length::Fill) | |
.horizontal_alignment(Horizontal::Center) | |
) | |
.width(Length::Fill) | |
.style(iced::theme::Container::Box), | |
) | |
.push( | |
Container::new( | |
Text::new("without max") | |
.width(Length::Fill) | |
.horizontal_alignment(Horizontal::Center), | |
) | |
.width(Length::Fill) | |
.style(iced::theme::Container::Box), | |
) | |
.push( | |
Container::new( | |
Text::new("end") | |
.width(Length::Fill) | |
.horizontal_alignment(Horizontal::Center) | |
) | |
.width(Length::Fill) | |
.style(iced::theme::Container::Box), | |
) | |
) | |
.push( | |
Row::new() | |
.spacing(10) | |
.width(Length::Fill) | |
.push( | |
Container::new( | |
Text::new("start") | |
.width(Length::Fill) | |
.horizontal_alignment(Horizontal::Center) | |
) | |
.width(Length::Fill) | |
.style(iced::theme::Container::Box), | |
) | |
.push( | |
Container::new( | |
Text::new("with max") | |
.width(Length::Fill) | |
.horizontal_alignment(Horizontal::Center), | |
) | |
.width(Length::Fill) | |
.max_width(200) | |
.style(iced::theme::Container::Box), | |
) | |
.push( | |
Container::new( | |
Text::new("end") | |
.width(Length::Fill) | |
.horizontal_alignment(Horizontal::Center) | |
) | |
.width(Length::Fill) | |
.style(iced::theme::Container::Box), | |
) | |
) | |
.into() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment