How do I just purely draw shapes using Iced

So I build my first "hello world" program in Iced:


use iced::{Text, Sandbox, Element, Settings};
fn main() -> iced::Result
{
    Hello::run(Settings::default())
}

struct Hello;

impl Sandbox for Hello
{
	type Message = ();

	fn new() -> Self
	{
		Self
	}

	fn title(&self) -> String
	{
		String::from("Title")
	}
	fn update(&mut self, _message: Self::Message)
	{

	}
	fn view(&mut self) -> Element<Self::Message>
	{
		Text::new("Hello world").into()
	}
}

So I was wondering over here

I want to now prevent it from being resizable and I want to to get rid of the title bar (including the minmize, maximize and close buttons) and have a simple rectangle shown,.

In the trait Sandbox, should I replace it with Application to do that?

https://docs.rs/iced/0.3.0/iced/trait.Sandbox.html#a-simple-hello-world

The Settings type that you use in your main function contains a window::Settings field that you can use to control the window settings. For example:

    Hello::run(Settings {
        window: iced::window::Settings {
            resizable: false,
            decorations: false,
            ..Default::default(),
        },
        ..Default::default(),
    })
3 Likes