Introduce Program API
This commit is contained in:
parent
0524e9b457
commit
c22269bff3
43 changed files with 1141 additions and 831 deletions
|
|
@ -3,18 +3,17 @@ use iced::mouse;
|
|||
use iced::widget::{
|
||||
canvas, checkbox, column, horizontal_space, row, slider, text,
|
||||
};
|
||||
use iced::{
|
||||
Element, Length, Point, Rectangle, Renderer, Sandbox, Settings, Theme,
|
||||
Vector,
|
||||
};
|
||||
use iced::{Element, Length, Point, Rectangle, Renderer, Theme, Vector};
|
||||
|
||||
pub fn main() -> iced::Result {
|
||||
VectorialText::run(Settings {
|
||||
antialiasing: true,
|
||||
..Settings::default()
|
||||
})
|
||||
iced::sandbox(VectorialText::update, VectorialText::view)
|
||||
.theme(|_| Theme::Dark)
|
||||
.title("Vectorial Text - Iced")
|
||||
.antialiased()
|
||||
.run()
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
struct VectorialText {
|
||||
state: State,
|
||||
}
|
||||
|
|
@ -27,19 +26,7 @@ enum Message {
|
|||
ToggleJapanese(bool),
|
||||
}
|
||||
|
||||
impl Sandbox for VectorialText {
|
||||
type Message = Message;
|
||||
|
||||
fn new() -> Self {
|
||||
Self {
|
||||
state: State::new(),
|
||||
}
|
||||
}
|
||||
|
||||
fn title(&self) -> String {
|
||||
String::from("Vectorial Text - Iced")
|
||||
}
|
||||
|
||||
impl VectorialText {
|
||||
fn update(&mut self, message: Message) {
|
||||
match message {
|
||||
Message::SizeChanged(size) => {
|
||||
|
|
@ -106,10 +93,6 @@ impl Sandbox for VectorialText {
|
|||
.padding(20)
|
||||
.into()
|
||||
}
|
||||
|
||||
fn theme(&self) -> Theme {
|
||||
Theme::Dark
|
||||
}
|
||||
}
|
||||
|
||||
struct State {
|
||||
|
|
@ -170,3 +153,9 @@ impl<Message> canvas::Program<Message> for State {
|
|||
vec![geometry]
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for State {
|
||||
fn default() -> Self {
|
||||
State::new()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue