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

Responsive Broken #1879

Closed
2 tasks done
AustinMReppert opened this issue May 27, 2023 · 3 comments · Fixed by #1890
Closed
2 tasks done

Responsive Broken #1879

AustinMReppert opened this issue May 27, 2023 · 3 comments · Fixed by #1890
Labels
bug Something isn't working layout widget

Comments

@AustinMReppert
Copy link
Contributor

AustinMReppert commented May 27, 2023

Is there an existing issue for this?

  • I have searched the existing issues.

Is this issue related to iced?

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

What happened?

Responsive is broken. The size provided in the closure will update, but the components inside will not update.

https://github.com/iced-rs/iced/blob/fcb1b454368638209862aeb5db41bc5f7d6d51a7/widget/src/lazy/responsive.rs#LL63C35-L63C35
This condition was added to only update the content layout if it is invalidated, however the content layout does not invalidate itself.

What is the expected behavior?

The content layout should be invalidated? Or we need to set the layout to None in update?

if self.size == new_size {
    return;
}
self.layout = None; // ?

Version

master

Operative System

Windows

Do you have any log output?

No response

@AustinMReppert AustinMReppert added the bug Something isn't working label May 27, 2023
@hecrj
Copy link
Member

hecrj commented May 31, 2023

Do you have an SSCCE?

@AustinMReppert
Copy link
Contributor Author

use iced::advanced::Widget;
use iced::widget::{Container, Responsive};
use iced::{Background, Color, Element, Sandbox, Settings};

pub fn main() -> iced::Result {
    HelloWorld::run(Settings::default())
}

#[derive(Debug, Clone, Copy)]
pub enum Message {}

struct HelloWorld {}

impl Sandbox for HelloWorld {
    type Message = Message;

    fn new() -> Self {
        HelloWorld {}
    }

    fn title(&self) -> String {
        "Test".to_string()
    }

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

    fn view(&self) -> Element<Message> {
        Responsive::new(|view| {
            Container::new("text")
                .width(view.width / 2.0)
                .height(view.height / 2.0)
                .style(|theme: &iced::Theme| iced::widget::container::Appearance {
                    text_color: None,
                    background: Some(Background::Color(Color::new(1.0, 0.0, 0.0, 1.0))),
                    border_radius: Default::default(),
                    border_width: 0.0,
                    border_color: Default::default(),
                })
                .into()
        })
        .into()
    }
}

@hecrj
Copy link
Member

hecrj commented Jun 1, 2023

Thanks! Should be fixed by #1890.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working layout widget
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants