Merge pull request #1964 from bungoboingo/feat/multi-window-support
[Feature] 🪟 Multi Window 🪟 .. redux!
This commit is contained in:
commit
fc285d3e46
59 changed files with 3020 additions and 761 deletions
|
|
@ -26,7 +26,7 @@ impl<Theme> crate::graphics::Compositor for Compositor<Theme> {
|
|||
fn new<W: HasRawWindowHandle + HasRawDisplayHandle>(
|
||||
settings: Self::Settings,
|
||||
compatible_window: Option<&W>,
|
||||
) -> Result<(Self, Self::Renderer), Error> {
|
||||
) -> Result<Self, Error> {
|
||||
let candidates =
|
||||
Candidate::list_from_env().unwrap_or(Candidate::default_list());
|
||||
|
||||
|
|
@ -34,9 +34,7 @@ impl<Theme> crate::graphics::Compositor for Compositor<Theme> {
|
|||
|
||||
for candidate in candidates {
|
||||
match candidate.build(settings, compatible_window) {
|
||||
Ok((compositor, renderer)) => {
|
||||
return Ok((compositor, renderer))
|
||||
}
|
||||
Ok(compositor) => return Ok(compositor),
|
||||
Err(new_error) => {
|
||||
error = new_error;
|
||||
}
|
||||
|
|
@ -46,6 +44,18 @@ impl<Theme> crate::graphics::Compositor for Compositor<Theme> {
|
|||
Err(error)
|
||||
}
|
||||
|
||||
fn create_renderer(&self) -> Self::Renderer {
|
||||
match self {
|
||||
Compositor::TinySkia(compositor) => {
|
||||
Renderer::TinySkia(compositor.create_renderer())
|
||||
}
|
||||
#[cfg(feature = "wgpu")]
|
||||
Compositor::Wgpu(compositor) => {
|
||||
Renderer::Wgpu(compositor.create_renderer())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn create_surface<W: HasRawWindowHandle + HasRawDisplayHandle>(
|
||||
&mut self,
|
||||
window: &W,
|
||||
|
|
@ -220,24 +230,21 @@ impl Candidate {
|
|||
self,
|
||||
settings: Settings,
|
||||
_compatible_window: Option<&W>,
|
||||
) -> Result<(Compositor<Theme>, Renderer<Theme>), Error> {
|
||||
) -> Result<Compositor<Theme>, Error> {
|
||||
match self {
|
||||
Self::TinySkia => {
|
||||
let (compositor, backend) =
|
||||
iced_tiny_skia::window::compositor::new();
|
||||
let compositor = iced_tiny_skia::window::compositor::new(
|
||||
iced_tiny_skia::Settings {
|
||||
default_font: settings.default_font,
|
||||
default_text_size: settings.default_text_size,
|
||||
},
|
||||
);
|
||||
|
||||
Ok((
|
||||
Compositor::TinySkia(compositor),
|
||||
Renderer::TinySkia(iced_tiny_skia::Renderer::new(
|
||||
backend,
|
||||
settings.default_font,
|
||||
settings.default_text_size,
|
||||
)),
|
||||
))
|
||||
Ok(Compositor::TinySkia(compositor))
|
||||
}
|
||||
#[cfg(feature = "wgpu")]
|
||||
Self::Wgpu => {
|
||||
let (compositor, backend) = iced_wgpu::window::compositor::new(
|
||||
let compositor = iced_wgpu::window::compositor::new(
|
||||
iced_wgpu::Settings {
|
||||
default_font: settings.default_font,
|
||||
default_text_size: settings.default_text_size,
|
||||
|
|
@ -247,14 +254,7 @@ impl Candidate {
|
|||
_compatible_window,
|
||||
)?;
|
||||
|
||||
Ok((
|
||||
Compositor::Wgpu(compositor),
|
||||
Renderer::Wgpu(iced_wgpu::Renderer::new(
|
||||
backend,
|
||||
settings.default_font,
|
||||
settings.default_text_size,
|
||||
)),
|
||||
))
|
||||
Ok(Compositor::Wgpu(compositor))
|
||||
}
|
||||
#[cfg(not(feature = "wgpu"))]
|
||||
Self::Wgpu => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue