diff options
| author | 2023-02-24 20:52:10 +0100 | |
|---|---|---|
| committer | 2023-02-24 20:52:10 +0100 | |
| commit | 368cadd25a8b57ee5c41e45d1abe8d1dfb194c69 (patch) | |
| tree | 191cb7cc7807a5fe513b3d485b2fda21d3bf0bde /examples/checkbox/src | |
| parent | 573d27eb52bbfacf1b06983b4282f00eb5265bdc (diff) | |
| parent | 8059c40142d601588e01c152ce1bb72a1295dde8 (diff) | |
| download | iced-368cadd25a8b57ee5c41e45d1abe8d1dfb194c69.tar.gz iced-368cadd25a8b57ee5c41e45d1abe8d1dfb194c69.tar.bz2 iced-368cadd25a8b57ee5c41e45d1abe8d1dfb194c69.zip | |
Merge pull request #1697 from iced-rs/text-glyphon
Text shaping, font fallback, and `iced_wgpu` overhaul
Diffstat (limited to '')
| -rw-r--r-- | examples/checkbox/src/main.rs | 28 | 
1 files changed, 19 insertions, 9 deletions
| diff --git a/examples/checkbox/src/main.rs b/examples/checkbox/src/main.rs index 09950bb8..77111490 100644 --- a/examples/checkbox/src/main.rs +++ b/examples/checkbox/src/main.rs @@ -1,10 +1,9 @@ +use iced::executor; +use iced::font::{self, Font};  use iced::widget::{checkbox, column, container}; -use iced::{Element, Font, Length, Sandbox, Settings}; +use iced::{Application, Command, Element, Length, Settings, Theme}; -const ICON_FONT: Font = Font::External { -    name: "Icons", -    bytes: include_bytes!("../fonts/icons.ttf"), -}; +const ICON_FONT: Font = Font::Name("icons");  pub fn main() -> iced::Result {      Example::run(Settings::default()) @@ -20,24 +19,35 @@ struct Example {  enum Message {      DefaultChecked(bool),      CustomChecked(bool), +    FontLoaded(Result<(), font::Error>),  } -impl Sandbox for Example { +impl Application for Example {      type Message = Message; +    type Flags = (); +    type Executor = executor::Default; +    type Theme = Theme; -    fn new() -> Self { -        Default::default() +    fn new(_flags: Self::Flags) -> (Self, Command<Message>) { +        ( +            Self::default(), +            font::load(include_bytes!("../fonts/icons.ttf").as_ref()) +                .map(Message::FontLoaded), +        )      }      fn title(&self) -> String {          String::from("Checkbox - Iced")      } -    fn update(&mut self, message: Message) { +    fn update(&mut self, message: Message) -> Command<Message> {          match message {              Message::DefaultChecked(value) => self.default_checkbox = value,              Message::CustomChecked(value) => self.custom_checkbox = value, +            Message::FontLoaded(_) => (),          } + +        Command::none()      }      fn view(&self) -> Element<Message> { | 
