Implement iced_glutin 🎉
This commit is contained in:
parent
a1a5fcfd46
commit
e0e4ee73fe
31 changed files with 718 additions and 498 deletions
|
|
@ -8,4 +8,4 @@ publish = false
|
|||
[dependencies]
|
||||
iced = { path = "../.." }
|
||||
iced_native = { path = "../../native" }
|
||||
iced_wgpu = { path = "../../wgpu" }
|
||||
iced_graphics = { path = "../../graphics" }
|
||||
|
|
|
|||
|
|
@ -9,11 +9,11 @@ mod circle {
|
|||
// Of course, you can choose to make the implementation renderer-agnostic,
|
||||
// if you wish to, by creating your own `Renderer` trait, which could be
|
||||
// implemented by `iced_wgpu` and other renderers.
|
||||
use iced_graphics::{Backend, Defaults, Primitive, Renderer};
|
||||
use iced_native::{
|
||||
layout, mouse, Background, Color, Element, Hasher, Layout, Length,
|
||||
Point, Size, Widget,
|
||||
};
|
||||
use iced_wgpu::{Defaults, Primitive, Renderer};
|
||||
|
||||
pub struct Circle {
|
||||
radius: u16,
|
||||
|
|
@ -25,7 +25,10 @@ mod circle {
|
|||
}
|
||||
}
|
||||
|
||||
impl<Message> Widget<Message, Renderer> for Circle {
|
||||
impl<Message, B> Widget<Message, Renderer<B>> for Circle
|
||||
where
|
||||
B: Backend,
|
||||
{
|
||||
fn width(&self) -> Length {
|
||||
Length::Shrink
|
||||
}
|
||||
|
|
@ -36,7 +39,7 @@ mod circle {
|
|||
|
||||
fn layout(
|
||||
&self,
|
||||
_renderer: &Renderer,
|
||||
_renderer: &Renderer<B>,
|
||||
_limits: &layout::Limits,
|
||||
) -> layout::Node {
|
||||
layout::Node::new(Size::new(
|
||||
|
|
@ -53,7 +56,7 @@ mod circle {
|
|||
|
||||
fn draw(
|
||||
&self,
|
||||
_renderer: &mut Renderer,
|
||||
_renderer: &mut Renderer<B>,
|
||||
_defaults: &Defaults,
|
||||
layout: Layout<'_>,
|
||||
_cursor_position: Point,
|
||||
|
|
@ -71,8 +74,11 @@ mod circle {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, Message> Into<Element<'a, Message, Renderer>> for Circle {
|
||||
fn into(self) -> Element<'a, Message, Renderer> {
|
||||
impl<'a, Message, B> Into<Element<'a, Message, Renderer<B>>> for Circle
|
||||
where
|
||||
B: Backend,
|
||||
{
|
||||
fn into(self) -> Element<'a, Message, Renderer<B>> {
|
||||
Element::new(self)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,4 +8,4 @@ publish = false
|
|||
[dependencies]
|
||||
iced = { path = "../.." }
|
||||
iced_native = { path = "../../native" }
|
||||
iced_wgpu = { path = "../../wgpu" }
|
||||
iced_graphics = { path = "../../graphics" }
|
||||
|
|
|
|||
|
|
@ -10,14 +10,14 @@ mod rainbow {
|
|||
// Of course, you can choose to make the implementation renderer-agnostic,
|
||||
// if you wish to, by creating your own `Renderer` trait, which could be
|
||||
// implemented by `iced_wgpu` and other renderers.
|
||||
use iced_graphics::{
|
||||
triangle::{Mesh2D, Vertex2D},
|
||||
Backend, Defaults, Primitive, Renderer,
|
||||
};
|
||||
use iced_native::{
|
||||
layout, mouse, Element, Hasher, Layout, Length, Point, Size, Vector,
|
||||
Widget,
|
||||
};
|
||||
use iced_wgpu::{
|
||||
triangle::{Mesh2D, Vertex2D},
|
||||
Defaults, Primitive, Renderer,
|
||||
};
|
||||
|
||||
pub struct Rainbow;
|
||||
|
||||
|
|
@ -27,7 +27,10 @@ mod rainbow {
|
|||
}
|
||||
}
|
||||
|
||||
impl<Message> Widget<Message, Renderer> for Rainbow {
|
||||
impl<Message, B> Widget<Message, Renderer<B>> for Rainbow
|
||||
where
|
||||
B: Backend,
|
||||
{
|
||||
fn width(&self) -> Length {
|
||||
Length::Fill
|
||||
}
|
||||
|
|
@ -38,7 +41,7 @@ mod rainbow {
|
|||
|
||||
fn layout(
|
||||
&self,
|
||||
_renderer: &Renderer,
|
||||
_renderer: &Renderer<B>,
|
||||
limits: &layout::Limits,
|
||||
) -> layout::Node {
|
||||
let size = limits.width(Length::Fill).resolve(Size::ZERO);
|
||||
|
|
@ -50,7 +53,7 @@ mod rainbow {
|
|||
|
||||
fn draw(
|
||||
&self,
|
||||
_renderer: &mut Renderer,
|
||||
_renderer: &mut Renderer<B>,
|
||||
_defaults: &Defaults,
|
||||
layout: Layout<'_>,
|
||||
cursor_position: Point,
|
||||
|
|
@ -146,8 +149,11 @@ mod rainbow {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, Message> Into<Element<'a, Message, Renderer>> for Rainbow {
|
||||
fn into(self) -> Element<'a, Message, Renderer> {
|
||||
impl<'a, Message, B> Into<Element<'a, Message, Renderer<B>>> for Rainbow
|
||||
where
|
||||
B: Backend,
|
||||
{
|
||||
fn into(self) -> Element<'a, Message, Renderer<B>> {
|
||||
Element::new(self)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ edition = "2018"
|
|||
publish = false
|
||||
|
||||
[dependencies]
|
||||
iced = { path = "../..", features = ["async-std"] }
|
||||
iced = { path = "../..", features = ["async-std", "debug"] }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,5 @@ edition = "2018"
|
|||
publish = false
|
||||
|
||||
[dependencies]
|
||||
iced_winit = { path = "../../winit", features = ["debug"] }
|
||||
iced_glow = { path = "../../glow" }
|
||||
iced = { path = "../..", features = ["image", "debug"] }
|
||||
env_logger = "0.7"
|
||||
|
|
|
|||
|
|
@ -1,20 +1,14 @@
|
|||
use iced_glow::{
|
||||
button, scrollable, slider, text_input, window, Button, Checkbox, Color,
|
||||
Column, Command, Container, Element, HorizontalAlignment, Image, Length,
|
||||
Radio, Row, Scrollable, Slider, Space, Text, TextInput,
|
||||
use iced::{
|
||||
button, executor, scrollable, slider, text_input, Application, Button,
|
||||
Checkbox, Color, Column, Command, Container, Element, HorizontalAlignment,
|
||||
Image, Length, Radio, Row, Scrollable, Settings, Slider, Space, Text,
|
||||
TextInput,
|
||||
};
|
||||
use iced_winit::{executor, Application, Settings};
|
||||
|
||||
pub fn main() {
|
||||
env_logger::init();
|
||||
|
||||
Tour::run(
|
||||
Settings::default(),
|
||||
iced_glow::Settings {
|
||||
default_font: None,
|
||||
antialiasing: None,
|
||||
},
|
||||
)
|
||||
Tour::run(Settings::default())
|
||||
}
|
||||
|
||||
pub struct Tour {
|
||||
|
|
@ -26,7 +20,6 @@ pub struct Tour {
|
|||
}
|
||||
|
||||
impl Application for Tour {
|
||||
type Compositor = window::Compositor;
|
||||
type Executor = executor::Null;
|
||||
type Message = Message;
|
||||
type Flags = ();
|
||||
|
|
@ -693,18 +686,17 @@ impl<'a> Step {
|
|||
|
||||
fn ferris<'a>(width: u16) -> Container<'a, StepMessage> {
|
||||
Container::new(
|
||||
Text::new("Not supported yet!")
|
||||
// This should go away once we unify resource loading on native
|
||||
// platforms
|
||||
//if cfg!(target_arch = "wasm32") {
|
||||
// Image::new("images/ferris.png")
|
||||
//} else {
|
||||
// Image::new(format!(
|
||||
// "{}/images/ferris.png",
|
||||
// env!("CARGO_MANIFEST_DIR")
|
||||
// ))
|
||||
//}
|
||||
//.width(Length::Units(width)),
|
||||
if cfg!(target_arch = "wasm32") {
|
||||
Image::new("images/ferris.png")
|
||||
} else {
|
||||
Image::new(format!(
|
||||
"{}/images/ferris.png",
|
||||
env!("CARGO_MANIFEST_DIR")
|
||||
))
|
||||
}
|
||||
.width(Length::Units(width)),
|
||||
)
|
||||
.width(Length::Fill)
|
||||
.center_x()
|
||||
|
|
@ -765,7 +757,7 @@ pub enum Layout {
|
|||
}
|
||||
|
||||
mod style {
|
||||
use iced_glow::{button, Background, Color, Vector};
|
||||
use iced::{button, Background, Color, Vector};
|
||||
|
||||
pub enum Button {
|
||||
Primary,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue