cleanup
This commit is contained in:
parent
8fb1e21873
commit
757d0753ad
14 changed files with 146 additions and 2521 deletions
|
|
@ -28,7 +28,7 @@ wgpu-bare = ["iced_renderer/wgpu-bare", "iced_widget/wgpu"]
|
|||
# Enables the `tiny-skia` software renderer
|
||||
|
||||
|
||||
default = ["tiny-skia", "x11", "wayland", "tokio"]
|
||||
default = ["tiny-skia", "tokio"]
|
||||
# Enable the `tiny-skia` software renderer backend
|
||||
tiny-skia = ["iced_renderer/tiny-skia"]
|
||||
# Enables the `image` widget
|
||||
|
|
@ -116,7 +116,11 @@ a11y = [
|
|||
"iced_winit?/a11y",
|
||||
]
|
||||
# Enables the winit shell. Conflicts with `wayland` and `glutin`.
|
||||
winit = ["iced_winit", "iced_accessibility?/accesskit_winit"]
|
||||
winit = [
|
||||
"iced_winit",
|
||||
"iced_accessibility?/accesskit_winit",
|
||||
"iced_program/winit",
|
||||
]
|
||||
# Enables the sctk shell.
|
||||
wayland = ["iced_widget/wayland", "iced_core/wayland", "iced_winit/wayland"]
|
||||
[dependencies]
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ pub use nested::Nested;
|
|||
use crate::layout;
|
||||
use crate::mouse;
|
||||
use crate::renderer;
|
||||
use crate::widget::Operation;
|
||||
use crate::widget::Tree;
|
||||
use crate::{Clipboard, Event, Layout, Rectangle, Shell, Size, Vector};
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ rust-version.workspace = true
|
|||
workspace = true
|
||||
|
||||
[features]
|
||||
winit = []
|
||||
debug = []
|
||||
time-travel = []
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
//! The definition of an iced program.
|
||||
pub use iced_graphics as graphics;
|
||||
pub use iced_runtime as runtime;
|
||||
pub use iced_runtime::Task;
|
||||
pub use iced_runtime::core;
|
||||
pub use iced_runtime::futures;
|
||||
|
||||
|
|
@ -17,14 +18,6 @@ use crate::core::window;
|
|||
use crate::core::{Element, Font, Settings};
|
||||
use crate::futures::{Executor, Subscription};
|
||||
use crate::graphics::compositor;
|
||||
use crate::runtime::task::Task;
|
||||
#[cfg(any(feature = "winit", feature = "wayland"))]
|
||||
use crate::shell;
|
||||
#[cfg(any(feature = "winit", feature = "wayland"))]
|
||||
pub use crate::shell::program::{Appearance, DefaultStyle};
|
||||
|
||||
#[cfg(not(any(feature = "winit", feature = "wayland")))]
|
||||
pub use crate::runtime::{Appearance, DefaultStyle};
|
||||
|
||||
/// The internal definition of a [`Program`].
|
||||
///
|
||||
|
|
@ -124,138 +117,138 @@ pub trait Program: Sized {
|
|||
&[]
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "winit", feature = "wayland"))]
|
||||
/// Runs the [`Program`].
|
||||
///
|
||||
/// The state of the [`Program`] must implement [`Default`].
|
||||
/// If your state does not implement [`Default`], use [`run_with`]
|
||||
/// instead.
|
||||
///
|
||||
/// [`run_with`]: Self::run_with
|
||||
fn run(
|
||||
self,
|
||||
settings: Settings,
|
||||
window_settings: Option<window::Settings>,
|
||||
) -> Result
|
||||
where
|
||||
Self: 'static,
|
||||
Self::State: Default,
|
||||
{
|
||||
self.run_with(settings, window_settings, || {
|
||||
(Self::State::default(), Task::none())
|
||||
})
|
||||
}
|
||||
// #[cfg(feature = "winit")]
|
||||
// /// Runs the [`Program`].
|
||||
// ///
|
||||
// /// The state of the [`Program`] must implement [`Default`].
|
||||
// /// If your state does not implement [`Default`], use [`run_with`]
|
||||
// /// instead.
|
||||
// ///
|
||||
// /// [`run_with`]: Self::run_with
|
||||
// fn run(
|
||||
// self,
|
||||
// settings: crate::Settings,
|
||||
// window_settings: Option<window::Settings>,
|
||||
// ) -> crate::Result
|
||||
// where
|
||||
// Self: 'static,
|
||||
// Self::State: Default,
|
||||
// {
|
||||
// self.run_with(settings, window_settings, || {
|
||||
// (Self::State::default(), Task::none())
|
||||
// })
|
||||
// }
|
||||
|
||||
#[cfg(any(feature = "winit", feature = "wayland"))]
|
||||
/// Runs the [`Program`] with the given [`Settings`] and a closure that creates the initial state.
|
||||
fn run_with<I>(
|
||||
self,
|
||||
settings: Settings,
|
||||
window_settings: Option<window::Settings>,
|
||||
initialize: I,
|
||||
) -> Result
|
||||
where
|
||||
Self: 'static,
|
||||
I: FnOnce() -> (Self::State, Task<Self::Message>) + 'static,
|
||||
{
|
||||
use std::marker::PhantomData;
|
||||
// #[cfg(feature = "winit")]
|
||||
// /// Runs the [`Program`] with the given [`Settings`] and a closure that creates the initial state.
|
||||
// fn run_with<I>(
|
||||
// self,
|
||||
// settings: crate::Settings,
|
||||
// window_settings: Option<window::Settings>,
|
||||
// initialize: I,
|
||||
// ) -> crate::Result
|
||||
// where
|
||||
// Self: 'static,
|
||||
// I: FnOnce() -> (Self::State, Task<Self::Message>) + 'static,
|
||||
// {
|
||||
// use std::marker::PhantomData;
|
||||
|
||||
struct Instance<P: Program, I> {
|
||||
program: P,
|
||||
state: P::State,
|
||||
_initialize: PhantomData<I>,
|
||||
}
|
||||
// struct Instance<P: Program, I> {
|
||||
// program: P,
|
||||
// state: P::State,
|
||||
// _initialize: PhantomData<I>,
|
||||
// }
|
||||
|
||||
impl<P: Program, I: FnOnce() -> (P::State, Task<P::Message>)>
|
||||
shell::Program for Instance<P, I>
|
||||
{
|
||||
type Message = P::Message;
|
||||
type Theme = P::Theme;
|
||||
type Renderer = P::Renderer;
|
||||
type Flags = (P, I);
|
||||
type Executor = P::Executor;
|
||||
// impl<P: Program, I: FnOnce() -> (P::State, Task<P::Message>)>
|
||||
// shell::Program for Instance<P, I>
|
||||
// {
|
||||
// type Message = P::Message;
|
||||
// type Theme = P::Theme;
|
||||
// type Renderer = P::Renderer;
|
||||
// type Flags = (P, I);
|
||||
// type Executor = P::Executor;
|
||||
|
||||
fn new(
|
||||
(program, initialize): Self::Flags,
|
||||
) -> (Self, Task<Self::Message>) {
|
||||
let (state, task) = initialize();
|
||||
// fn new(
|
||||
// (program, initialize): Self::Flags,
|
||||
// ) -> (Self, Task<Self::Message>) {
|
||||
// let (state, task) = initialize();
|
||||
|
||||
(
|
||||
Self {
|
||||
program,
|
||||
state,
|
||||
_initialize: PhantomData,
|
||||
},
|
||||
task,
|
||||
)
|
||||
}
|
||||
// (
|
||||
// Self {
|
||||
// program,
|
||||
// state,
|
||||
// _initialize: PhantomData,
|
||||
// },
|
||||
// task,
|
||||
// )
|
||||
// }
|
||||
|
||||
fn title(&self, window: window::Id) -> String {
|
||||
self.program.title(&self.state, window)
|
||||
}
|
||||
// fn title(&self, window: window::Id) -> String {
|
||||
// self.program.title(&self.state, window)
|
||||
// }
|
||||
|
||||
fn update(
|
||||
&mut self,
|
||||
message: Self::Message,
|
||||
) -> Task<Self::Message> {
|
||||
self.program.update(&mut self.state, message)
|
||||
}
|
||||
// fn update(
|
||||
// &mut self,
|
||||
// message: Self::Message,
|
||||
// ) -> Task<Self::Message> {
|
||||
// self.program.update(&mut self.state, message)
|
||||
// }
|
||||
|
||||
fn view(
|
||||
&self,
|
||||
window: window::Id,
|
||||
) -> crate::Element<'_, Self::Message, Self::Theme, Self::Renderer>
|
||||
{
|
||||
self.program.view(&self.state, window)
|
||||
}
|
||||
// fn view(
|
||||
// &self,
|
||||
// window: window::Id,
|
||||
// ) -> crate::Element<'_, Self::Message, Self::Theme, Self::Renderer>
|
||||
// {
|
||||
// self.program.view(&self.state, window)
|
||||
// }
|
||||
|
||||
fn subscription(&self) -> Subscription<Self::Message> {
|
||||
self.program.subscription(&self.state)
|
||||
}
|
||||
// fn subscription(&self) -> Subscription<Self::Message> {
|
||||
// self.program.subscription(&self.state)
|
||||
// }
|
||||
|
||||
fn theme(&self, window: window::Id) -> Self::Theme {
|
||||
self.program.theme(&self.state, window)
|
||||
}
|
||||
// fn theme(&self, window: window::Id) -> Self::Theme {
|
||||
// self.program.theme(&self.state, window)
|
||||
// }
|
||||
|
||||
fn style(&self, theme: &Self::Theme) -> Appearance {
|
||||
self.program.style(&self.state, theme)
|
||||
}
|
||||
// fn style(&self, theme: &Self::Theme) -> Appearance {
|
||||
// self.program.style(&self.state, theme)
|
||||
// }
|
||||
|
||||
fn scale_factor(&self, window: window::Id) -> f64 {
|
||||
self.program.scale_factor(&self.state, window)
|
||||
}
|
||||
}
|
||||
// fn scale_factor(&self, window: window::Id) -> f64 {
|
||||
// self.program.scale_factor(&self.state, window)
|
||||
// }
|
||||
// }
|
||||
|
||||
#[allow(clippy::needless_update)]
|
||||
let renderer_settings = crate::graphics::Settings {
|
||||
default_font: settings.default_font,
|
||||
default_text_size: settings.default_text_size,
|
||||
antialiasing: if settings.antialiasing {
|
||||
Some(crate::graphics::Antialiasing::MSAAx4)
|
||||
} else {
|
||||
None
|
||||
},
|
||||
..crate::graphics::Settings::default()
|
||||
};
|
||||
// #[allow(clippy::needless_update)]
|
||||
// let renderer_settings = crate::graphics::Settings {
|
||||
// default_font: settings.default_font,
|
||||
// default_text_size: settings.default_text_size,
|
||||
// antialiasing: if settings.antialiasing {
|
||||
// Some(crate::graphics::Antialiasing::MSAAx4)
|
||||
// } else {
|
||||
// None
|
||||
// },
|
||||
// ..crate::graphics::Settings::default()
|
||||
// };
|
||||
|
||||
Ok(shell::program::run::<
|
||||
Instance<Self, I>,
|
||||
<Self::Renderer as compositor::Default>::Compositor,
|
||||
>(
|
||||
Settings {
|
||||
id: settings.id,
|
||||
fonts: settings.fonts,
|
||||
default_font: settings.default_font,
|
||||
default_text_size: settings.default_text_size,
|
||||
antialiasing: settings.antialiasing,
|
||||
exit_on_close_request: settings.exit_on_close_request,
|
||||
}
|
||||
.into(),
|
||||
renderer_settings,
|
||||
window_settings,
|
||||
(self, initialize),
|
||||
)?)
|
||||
}
|
||||
// Ok(shell::program::run::<
|
||||
// Instance<Self, I>,
|
||||
// <Self::Renderer as compositor::Default>::Compositor,
|
||||
// >(
|
||||
// crate::Settings {
|
||||
// id: settings.id,
|
||||
// fonts: settings.fonts,
|
||||
// default_font: settings.default_font,
|
||||
// default_text_size: settings.default_text_size,
|
||||
// antialiasing: settings.antialiasing,
|
||||
// exit_on_close_request: settings.exit_on_close_request,
|
||||
// }
|
||||
// .into(),
|
||||
// renderer_settings,
|
||||
// window_settings,
|
||||
// (self, initialize),
|
||||
// )?)
|
||||
// }
|
||||
}
|
||||
|
||||
/// Decorates a [`Program`] with the given title function.
|
||||
|
|
|
|||
|
|
@ -2,10 +2,8 @@
|
|||
|
||||
use std::any::Any;
|
||||
|
||||
use bytes::buf::Take;
|
||||
use dnd::{DndDestinationRectangle, DndSurface};
|
||||
use iced_core::{clipboard::DndSource, Vector};
|
||||
use iced_futures::MaybeSend;
|
||||
use iced_core::clipboard::DndSource;
|
||||
use window_clipboard::mime::{AllowedMimeTypes, AsMimeTypes};
|
||||
|
||||
use crate::{oneshot, task, Action, Task};
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ pub use user_interface::UserInterface;
|
|||
pub use window::Window;
|
||||
|
||||
use crate::futures::futures::channel::oneshot;
|
||||
use dnd::DndAction;
|
||||
|
||||
use std::borrow::Cow;
|
||||
use std::fmt;
|
||||
|
|
@ -70,6 +69,7 @@ pub enum Action<T> {
|
|||
/// This will normally close any application windows and
|
||||
/// terminate the runtime loop.
|
||||
Exit,
|
||||
|
||||
/// Run a Dnd action.
|
||||
Dnd(crate::dnd::DndAction),
|
||||
|
||||
|
|
@ -126,7 +126,7 @@ where
|
|||
Action::PlatformSpecific(action) => {
|
||||
write!(f, "Action::PlatformSpecific({:?})", action)
|
||||
}
|
||||
Action::Dnd(action) => write!(f, "Action::Dnd({:?})", action),
|
||||
Action::Dnd(_) => write!(f, "Action::Dnd"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
//! Platform specific actions defined for wayland
|
||||
|
||||
use std::{fmt, marker::PhantomData};
|
||||
|
||||
use iced_futures::MaybeSend;
|
||||
use std::fmt;
|
||||
|
||||
#[cfg(feature = "wayland")]
|
||||
/// Platform specific actions defined for wayland
|
||||
|
|
@ -20,6 +18,7 @@ impl fmt::Debug for Action {
|
|||
match self {
|
||||
#[cfg(feature = "wayland")]
|
||||
Action::Wayland(action) => action.fmt(_f),
|
||||
#[cfg(not(feature = "wayland"))]
|
||||
_ => Ok(()),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
use iced_core::widget::operation::Outcome;
|
||||
|
||||
use crate::core::event::{self, Event};
|
||||
use crate::core::mouse;
|
||||
use crate::core::renderer;
|
||||
|
|
@ -211,7 +209,6 @@ where
|
|||
operation::Outcome::Chain(next) => {
|
||||
current_operation = Some(next);
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
//! Implement your own event loop to drive a user interface.
|
||||
|
||||
use iced_core::clipboard::DndDestinationRectangles;
|
||||
use iced_core::widget::Operation;
|
||||
use iced_core::widget::tree::NAMED;
|
||||
|
||||
use crate::core::event::{self, Event};
|
||||
|
|
|
|||
|
|
@ -30,8 +30,6 @@
|
|||
//! ]
|
||||
//! }
|
||||
//! ```
|
||||
use crate::message;
|
||||
use crate::program::{self, Appearance, DefaultStyle, Program};
|
||||
|
||||
use crate::theme;
|
||||
|
||||
|
|
@ -40,7 +38,9 @@ use crate::shell;
|
|||
use crate::window;
|
||||
use crate::{
|
||||
Element, Executor, Font, Never, Preset, Result, Settings, Size,
|
||||
Subscription, Theme, task::Task,
|
||||
Subscription, Theme, message,
|
||||
program::{self, Program},
|
||||
task::Task,
|
||||
};
|
||||
|
||||
use iced_debug as debug;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ use crate::{
|
|||
|
||||
use iced_debug as debug;
|
||||
|
||||
#[cfg(not(any(feature = "winit", feature = "wayland")))]
|
||||
#[cfg(not(feature = "winit"))]
|
||||
use crate::runtime::{Appearance, DefaultStyle};
|
||||
|
||||
use std::borrow::Cow;
|
||||
|
|
|
|||
|
|
@ -34,10 +34,6 @@ impl From<shell::Error> for Error {
|
|||
shell::Error::WindowCreationFailed(error) => {
|
||||
Error::WindowCreationFailed(Box::new(error))
|
||||
}
|
||||
#[cfg(feature = "wayland")]
|
||||
shell::Error::WindowCreationFailed(error) => {
|
||||
Error::WindowCreationFailed(Box::new(error))
|
||||
}
|
||||
shell::Error::GraphicsCreationFailed(error) => {
|
||||
Error::GraphicsCreationFailed(error)
|
||||
}
|
||||
|
|
|
|||
35
src/lib.rs
35
src/lib.rs
|
|
@ -504,17 +504,17 @@ compile_error!(
|
|||
Available options: thread-pool, tokio, or smol."
|
||||
);
|
||||
|
||||
#[cfg(all(
|
||||
target_family = "unix",
|
||||
not(target_os = "macos"),
|
||||
not(feature = "wayland"),
|
||||
not(feature = "x11"),
|
||||
))]
|
||||
compile_error!(
|
||||
"No Unix display server backend has been enabled. You must enable a \
|
||||
display server feature.\n\
|
||||
Available options: x11, wayland."
|
||||
);
|
||||
// #[cfg(all(
|
||||
// target_family = "unix",
|
||||
// not(target_os = "macos"),
|
||||
// not(feature = "wayland"),
|
||||
// not(feature = "x11"),
|
||||
// ))]
|
||||
// compile_error!(
|
||||
// "No Unix display server backend has been enabled. You must enable a \
|
||||
// display server feature.\n\
|
||||
// Available options: x11, wayland."
|
||||
// );
|
||||
|
||||
#[cfg(feature = "highlighter")]
|
||||
pub use iced_highlighter as highlighter;
|
||||
|
|
@ -544,19 +544,6 @@ pub use application::Application;
|
|||
#[cfg(feature = "winit")]
|
||||
pub use program::Program;
|
||||
|
||||
// wayland application
|
||||
// #[cfg(feature = "wayland")]
|
||||
// pub mod wayland;
|
||||
// #[cfg(feature = "wayland")]
|
||||
// pub use wayland::application;
|
||||
// #[cfg(feature = "wayland")]
|
||||
// pub use wayland::application::Application;
|
||||
// #[cfg(feature = "wayland")]
|
||||
// pub use wayland::program;
|
||||
// #[doc(inline)]
|
||||
// #[cfg(feature = "wayland")]
|
||||
// pub use wayland::program::Program;
|
||||
|
||||
#[cfg(feature = "advanced")]
|
||||
pub mod advanced;
|
||||
|
||||
|
|
|
|||
2348
winit/src/program.rs
2348
winit/src/program.rs
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue