iced icon indicating copy to clipboard operation
iced copied to clipboard

Layout is wrong

Open Pieresqi opened this issue 1 year ago • 1 comments

Is your issue REALLY a bug?

  • [X] My issue is indeed a bug!
  • [X] I am not crazy! I will not fill out this form just to ask a question or request a feature. Pinky promise.

Is there an existing issue for this?

  • [X] I have searched the existing issues.

Is this issue related to iced?

  • [X] My hardware is compatible and my graphics drivers are up-to-date.

What happened?

Let's have this SSCCE:

use iced::{widget::*, Color, Element, Length, Sandbox, Settings};

fn main() -> Result<(), iced::Error> {
    <App as Sandbox>::run(Settings::default())
}

struct App;

impl Sandbox for App {
    type Message = ();

    fn new() -> Self {
        Self
    }

    fn title(&self) -> String {
        String::new()
    }

    fn update(&mut self, _: Self::Message) {}

    fn view(&self) -> Element<'_, Self::Message> {
        let options: [Element<'_, (), Theme, Renderer>; 2] = [
            text("first text").height(Length::Fill).into(),
            text("second text").into(),
        ];

        let column: Element<'_, (), Theme, Renderer> =
            column(options).height(Length::Shrink).into();

        column
    }

    fn theme(&self) -> Theme {
        Theme::KanagawaDragon
    }
}

iced = "0.12.1"

I can only see the 2nd text "second text". The 1st is hidden/gone.

What is the expected behavior?

I should be able too see both texts.

Version

crates.io release

Operating System

Windows

Do you have any log output?

No response

Pieresqi avatar Sep 06 '24 23:09 Pieresqi

Maybe try using a row / column instead of [Element<'_, (), Theme, Renderer>; 2]. I've never seen that type of pattern.

You want it to be like:

let my_row = row![text("hii!!"), text("second txt!!")];

I think the problem you have is because the row will decide where the objects inside are placed? And the [Element] will not.

nednoodlehead avatar Sep 10 '24 18:09 nednoodlehead

If you remove the .height(Length::Fill) from the first text widget, both text widgets are shown.

JL710 avatar Mar 29 '25 18:03 JL710