iced-rs / iced

A cross-platform GUI library for Rust, inspired by Elm

Home Page:https://iced.rs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

My text() os not updated when clicking Theo button in FydeOS 18.0

soucosmo opened this issue · comments

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?

My main.rs

use iced::{
    Element,
    Sandbox,
    Settings,
    widget::{button, column, text, Column},
};

#[derive(Debug, Clone)]
enum Contagem {
    Adc1,
    Adc10,
    Rem1,
    Rem10,
}


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

#[derive(Default)]
struct App {
    contagem: i32,
}

impl Sandbox for App {
    type Message = Contagem;

    fn new() -> Self {
        Self { contagem: 0 }
    }

    fn title(&self) -> String {
        String::from("A cool application")
    }

    fn update(&mut self, message: Self::Message) {
        println!("contagem {}", self.contagem);
        match message {
            Contagem::Adc1 => self.contagem += 1,
            Contagem::Adc10 => self.contagem += 10,
            Contagem::Rem1 => self.contagem -= 1,
            Contagem::Rem10 => self.contagem -= 10,
        }
    
    }

    fn view(&self) -> Element<Self::Message> {
        println!("contagem view {}", self.contagem);

        column![
            text("Hello, world!").size(45),
            button("Adicionar 1").on_press(Contagem::Adc1),
            button("Adicionar 10").on_press(Contagem::Adc10),
            text(&self.contagem).size(25),
            button("Remover 1").on_press(Contagem::Rem1),
            button("Remover 10").on_press(Contagem::Rem10),
        ].into()
    }
}

My Cargo.toml

[package]
name = "teste-iced"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
iced = { version = "0.12.1", features = ["tokio", "webgl"] }
iced_runtime = "0.12.1"

When running the program, everything works fine, except updating text(&self.contagem).size(25), when clicking the button, nothing happens, does anyone know how to solve it?

What is the expected behavior?

When clicking on a button, the counter should show the updated value on the screen, the view() function is called normally, the print happens to prove it, the code works on another computer with Windows, but on my operating system it doesn't work, I'm using it FydeOS 18.0

Version

crates.io release

Operating System

Linux

Do you have any log output?

No response

Screenshot

image

The console indicates that the buttons work, but the interface is not updated according to the self.contagem value

I managed to solve it by setting this environment variable: ICED_BACKEND=tiny-skia
image

One thing I noticed is that ICED_BACKEND=tiny-skia makes the performance poor, I built a list, and when adding new items to the list it is possible to notice the delay in updating.

Researching more on the subject, I found this link pop-os/cosmic-comp#264 which suggests using WGPU_BACKEND=gl, and to my surprise, the performance was perfect, I don't know if that works of something in the development of iced, but here is my story.