Merge remote-tracking branch 'origin/master' into feat/multi-window-support
# Conflicts: # Cargo.toml # core/src/window/icon.rs # core/src/window/id.rs # core/src/window/position.rs # core/src/window/settings.rs # examples/integration/src/main.rs # examples/integration_opengl/src/main.rs # glutin/src/application.rs # native/src/subscription.rs # native/src/window.rs # runtime/src/window/action.rs # src/lib.rs # src/window.rs # winit/Cargo.toml # winit/src/application.rs # winit/src/icon.rs # winit/src/settings.rs # winit/src/window.rs
This commit is contained in:
commit
633f405f3f
394 changed files with 17278 additions and 13290 deletions
16
src/advanced.rs
Normal file
16
src/advanced.rs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
//! Leverage advanced concepts like custom widgets.
|
||||
pub use crate::core::image;
|
||||
pub use crate::core::layout::{self, Layout};
|
||||
pub use crate::core::mouse;
|
||||
pub use crate::core::overlay::{self, Overlay};
|
||||
pub use crate::core::renderer::{self, Renderer};
|
||||
pub use crate::core::svg;
|
||||
pub use crate::core::text::{self, Text};
|
||||
pub use crate::core::widget::{self, Widget};
|
||||
pub use crate::core::{Clipboard, Hasher, Shell};
|
||||
pub use crate::renderer::graphics;
|
||||
|
||||
pub mod subscription {
|
||||
//! Write your own subscriptions.
|
||||
pub use crate::runtime::futures::subscription::{EventStream, Recipe};
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
//! Build interactive cross-platform applications.
|
||||
use crate::{Command, Element, Executor, Settings, Subscription};
|
||||
|
||||
pub use iced_native::application::{Appearance, StyleSheet};
|
||||
pub use crate::style::application::{Appearance, StyleSheet};
|
||||
|
||||
/// An interactive cross-platform application.
|
||||
///
|
||||
|
|
@ -39,15 +39,15 @@ pub use iced_native::application::{Appearance, StyleSheet};
|
|||
/// to listen to time.
|
||||
/// - [`todos`], a todos tracker inspired by [TodoMVC].
|
||||
///
|
||||
/// [The repository has a bunch of examples]: https://github.com/iced-rs/iced/tree/0.8/examples
|
||||
/// [`clock`]: https://github.com/iced-rs/iced/tree/0.8/examples/clock
|
||||
/// [`download_progress`]: https://github.com/iced-rs/iced/tree/0.8/examples/download_progress
|
||||
/// [`events`]: https://github.com/iced-rs/iced/tree/0.8/examples/events
|
||||
/// [`game_of_life`]: https://github.com/iced-rs/iced/tree/0.8/examples/game_of_life
|
||||
/// [`pokedex`]: https://github.com/iced-rs/iced/tree/0.8/examples/pokedex
|
||||
/// [`solar_system`]: https://github.com/iced-rs/iced/tree/0.8/examples/solar_system
|
||||
/// [`stopwatch`]: https://github.com/iced-rs/iced/tree/0.8/examples/stopwatch
|
||||
/// [`todos`]: https://github.com/iced-rs/iced/tree/0.8/examples/todos
|
||||
/// [The repository has a bunch of examples]: https://github.com/iced-rs/iced/tree/0.9/examples
|
||||
/// [`clock`]: https://github.com/iced-rs/iced/tree/0.9/examples/clock
|
||||
/// [`download_progress`]: https://github.com/iced-rs/iced/tree/0.9/examples/download_progress
|
||||
/// [`events`]: https://github.com/iced-rs/iced/tree/0.9/examples/events
|
||||
/// [`game_of_life`]: https://github.com/iced-rs/iced/tree/0.9/examples/game_of_life
|
||||
/// [`pokedex`]: https://github.com/iced-rs/iced/tree/0.9/examples/pokedex
|
||||
/// [`solar_system`]: https://github.com/iced-rs/iced/tree/0.9/examples/solar_system
|
||||
/// [`stopwatch`]: https://github.com/iced-rs/iced/tree/0.9/examples/stopwatch
|
||||
/// [`todos`]: https://github.com/iced-rs/iced/tree/0.9/examples/todos
|
||||
/// [`Sandbox`]: crate::Sandbox
|
||||
/// [`Canvas`]: crate::widget::Canvas
|
||||
/// [PokéAPI]: https://pokeapi.co/
|
||||
|
|
@ -197,26 +197,25 @@ pub trait Application: Sized {
|
|||
let renderer_settings = crate::renderer::Settings {
|
||||
default_font: settings.default_font,
|
||||
default_text_size: settings.default_text_size,
|
||||
text_multithreading: settings.text_multithreading,
|
||||
antialiasing: if settings.antialiasing {
|
||||
Some(crate::renderer::settings::Antialiasing::MSAAx4)
|
||||
Some(crate::graphics::Antialiasing::MSAAx4)
|
||||
} else {
|
||||
None
|
||||
},
|
||||
..crate::renderer::Settings::from_env()
|
||||
..crate::renderer::Settings::default()
|
||||
};
|
||||
|
||||
Ok(crate::runtime::application::run::<
|
||||
Ok(crate::shell::application::run::<
|
||||
Instance<Self>,
|
||||
Self::Executor,
|
||||
crate::renderer::window::Compositor<Self::Theme>,
|
||||
crate::renderer::Compositor<Self::Theme>,
|
||||
>(settings.into(), renderer_settings)?)
|
||||
}
|
||||
}
|
||||
|
||||
struct Instance<A: Application>(A);
|
||||
|
||||
impl<A> iced_winit::Program for Instance<A>
|
||||
impl<A> crate::runtime::Program for Instance<A>
|
||||
where
|
||||
A: Application,
|
||||
{
|
||||
|
|
@ -232,7 +231,7 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl<A> crate::runtime::Application for Instance<A>
|
||||
impl<A> crate::shell::Application for Instance<A>
|
||||
where
|
||||
A: Application,
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
//! Access the clipboard.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub use crate::runtime::clipboard::{read, write};
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
/// A generic widget.
|
||||
///
|
||||
/// This is an alias of an `iced_native` element with a default `Renderer`.
|
||||
pub type Element<'a, Message, Renderer = crate::Renderer> =
|
||||
crate::runtime::Element<'a, Message, Renderer>;
|
||||
16
src/error.rs
16
src/error.rs
|
|
@ -1,4 +1,6 @@
|
|||
use iced_futures::futures;
|
||||
use crate::futures;
|
||||
use crate::graphics;
|
||||
use crate::shell;
|
||||
|
||||
/// An error that occurred while running an application.
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
|
|
@ -13,19 +15,19 @@ pub enum Error {
|
|||
|
||||
/// The application graphics context could not be created.
|
||||
#[error("the application graphics context could not be created")]
|
||||
GraphicsCreationFailed(iced_graphics::Error),
|
||||
GraphicsCreationFailed(graphics::Error),
|
||||
}
|
||||
|
||||
impl From<iced_winit::Error> for Error {
|
||||
fn from(error: iced_winit::Error) -> Error {
|
||||
impl From<shell::Error> for Error {
|
||||
fn from(error: shell::Error) -> Error {
|
||||
match error {
|
||||
iced_winit::Error::ExecutorCreationFailed(error) => {
|
||||
shell::Error::ExecutorCreationFailed(error) => {
|
||||
Error::ExecutorCreationFailed(error)
|
||||
}
|
||||
iced_winit::Error::WindowCreationFailed(error) => {
|
||||
shell::Error::WindowCreationFailed(error) => {
|
||||
Error::WindowCreationFailed(Box::new(error))
|
||||
}
|
||||
iced_winit::Error::GraphicsCreationFailed(error) => {
|
||||
shell::Error::GraphicsCreationFailed(error) => {
|
||||
Error::GraphicsCreationFailed(error)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +0,0 @@
|
|||
//! Choose your preferred executor to power your application.
|
||||
pub use crate::runtime::Executor;
|
||||
|
||||
/// A default cross-platform executor.
|
||||
///
|
||||
/// - On native platforms, it will use:
|
||||
/// - `iced_futures::backend::native::tokio` when the `tokio` feature is enabled.
|
||||
/// - `iced_futures::backend::native::async-std` when the `async-std` feature is
|
||||
/// enabled.
|
||||
/// - `iced_futures::backend::native::smol` when the `smol` feature is enabled.
|
||||
/// - `iced_futures::backend::native::thread_pool` otherwise.
|
||||
///
|
||||
/// - On Wasm, it will use `iced_futures::backend::wasm::wasm_bindgen`.
|
||||
pub type Default = iced_futures::backend::default::Executor;
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
//! Listen and react to keyboard events.
|
||||
pub use crate::runtime::keyboard::{Event, KeyCode, Modifiers};
|
||||
159
src/lib.rs
159
src/lib.rs
|
|
@ -24,13 +24,13 @@
|
|||
//! [scrollables]: https://gfycat.com/perkybaggybaboon-rust-gui
|
||||
//! [Debug overlay with performance metrics]: https://gfycat.com/incredibledarlingbee
|
||||
//! [Modular ecosystem]: https://github.com/iced-rs/iced/blob/master/ECOSYSTEM.md
|
||||
//! [renderer-agnostic native runtime]: https://github.com/iced-rs/iced/tree/0.8/native
|
||||
//! [renderer-agnostic native runtime]: https://github.com/iced-rs/iced/tree/0.9/native
|
||||
//! [`wgpu`]: https://github.com/gfx-rs/wgpu-rs
|
||||
//! [built-in renderer]: https://github.com/iced-rs/iced/tree/0.8/wgpu
|
||||
//! [windowing shell]: https://github.com/iced-rs/iced/tree/0.8/winit
|
||||
//! [built-in renderer]: https://github.com/iced-rs/iced/tree/0.9/wgpu
|
||||
//! [windowing shell]: https://github.com/iced-rs/iced/tree/0.9/winit
|
||||
//! [`dodrio`]: https://github.com/fitzgen/dodrio
|
||||
//! [web runtime]: https://github.com/iced-rs/iced_web
|
||||
//! [examples]: https://github.com/iced-rs/iced/tree/0.8/examples
|
||||
//! [examples]: https://github.com/iced-rs/iced/tree/0.9/examples
|
||||
//! [repository]: https://github.com/iced-rs/iced
|
||||
//!
|
||||
//! # Overview
|
||||
|
|
@ -163,62 +163,147 @@
|
|||
)]
|
||||
#![forbid(rust_2018_idioms, unsafe_code)]
|
||||
#![allow(clippy::inherent_to_string, clippy::type_complexity)]
|
||||
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
|
||||
use iced_widget::graphics;
|
||||
use iced_widget::renderer;
|
||||
use iced_widget::style;
|
||||
use iced_winit as shell;
|
||||
use iced_winit::core;
|
||||
use iced_winit::runtime;
|
||||
|
||||
pub use iced_futures::futures;
|
||||
|
||||
mod element;
|
||||
mod error;
|
||||
mod result;
|
||||
mod sandbox;
|
||||
|
||||
pub mod application;
|
||||
pub mod clipboard;
|
||||
pub mod executor;
|
||||
pub mod keyboard;
|
||||
pub mod mouse;
|
||||
pub mod overlay;
|
||||
pub mod settings;
|
||||
pub mod time;
|
||||
pub mod touch;
|
||||
pub mod widget;
|
||||
pub mod window;
|
||||
|
||||
#[cfg(all(not(feature = "glow"), feature = "multi-window"))]
|
||||
#[cfg(feature = "advanced")]
|
||||
pub mod advanced;
|
||||
|
||||
#[cfg(feature = "multi-window")]
|
||||
pub mod multi_window;
|
||||
|
||||
#[cfg(all(not(feature = "glow"), feature = "wgpu"))]
|
||||
use iced_winit as runtime;
|
||||
pub use style::theme;
|
||||
|
||||
#[cfg(feature = "glow")]
|
||||
use iced_glutin as runtime;
|
||||
pub use crate::core::alignment;
|
||||
pub use crate::core::event;
|
||||
pub use crate::core::gradient;
|
||||
pub use crate::core::{
|
||||
color, Alignment, Background, Color, ContentFit, Degrees, Gradient, Length,
|
||||
Padding, Pixels, Point, Radians, Rectangle, Size, Vector,
|
||||
};
|
||||
pub use crate::runtime::Command;
|
||||
|
||||
#[cfg(all(not(feature = "glow"), feature = "wgpu"))]
|
||||
use iced_wgpu as renderer;
|
||||
pub mod clipboard {
|
||||
//! Access the clipboard.
|
||||
pub use crate::runtime::clipboard::{read, write};
|
||||
}
|
||||
|
||||
#[cfg(feature = "glow")]
|
||||
use iced_glow as renderer;
|
||||
pub mod executor {
|
||||
//! Choose your preferred executor to power your application.
|
||||
pub use iced_futures::Executor;
|
||||
|
||||
pub use iced_native::theme;
|
||||
pub use runtime::event;
|
||||
pub use runtime::subscription;
|
||||
/// A default cross-platform executor.
|
||||
///
|
||||
/// - On native platforms, it will use:
|
||||
/// - `iced_futures::backend::native::tokio` when the `tokio` feature is enabled.
|
||||
/// - `iced_futures::backend::native::async-std` when the `async-std` feature is
|
||||
/// enabled.
|
||||
/// - `iced_futures::backend::native::smol` when the `smol` feature is enabled.
|
||||
/// - `iced_futures::backend::native::thread_pool` otherwise.
|
||||
///
|
||||
/// - On Wasm, it will use `iced_futures::backend::wasm::wasm_bindgen`.
|
||||
pub type Default = iced_futures::backend::default::Executor;
|
||||
}
|
||||
|
||||
pub mod font {
|
||||
//! Load and use fonts.
|
||||
pub use crate::core::font::*;
|
||||
pub use crate::runtime::font::*;
|
||||
}
|
||||
|
||||
pub mod keyboard {
|
||||
//! Listen and react to keyboard events.
|
||||
pub use crate::core::keyboard::{Event, KeyCode, Modifiers};
|
||||
}
|
||||
|
||||
pub mod mouse {
|
||||
//! Listen and react to mouse events.
|
||||
pub use crate::core::mouse::{
|
||||
Button, Cursor, Event, Interaction, ScrollDelta,
|
||||
};
|
||||
}
|
||||
|
||||
pub mod subscription {
|
||||
//! Listen to external events in your application.
|
||||
pub use iced_futures::subscription::{
|
||||
channel, events, events_with, run, run_with_id, unfold, Subscription,
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(feature = "system")]
|
||||
pub mod system {
|
||||
//! Retrieve system information.
|
||||
pub use crate::runtime::system::Information;
|
||||
pub use crate::shell::system::*;
|
||||
}
|
||||
|
||||
pub mod overlay {
|
||||
//! Display interactive elements on top of other widgets.
|
||||
|
||||
/// A generic [`Overlay`].
|
||||
///
|
||||
/// This is an alias of an `iced_native` element with a default `Renderer`.
|
||||
///
|
||||
/// [`Overlay`]: iced_native::Overlay
|
||||
pub type Element<'a, Message, Renderer = crate::Renderer> =
|
||||
crate::core::overlay::Element<'a, Message, Renderer>;
|
||||
|
||||
pub use iced_widget::overlay::*;
|
||||
}
|
||||
|
||||
pub mod touch {
|
||||
//! Listen and react to touch events.
|
||||
pub use crate::core::touch::{Event, Finger};
|
||||
}
|
||||
|
||||
pub mod widget {
|
||||
//! Use the built-in widgets or create your own.
|
||||
pub use iced_widget::*;
|
||||
|
||||
// We hide the re-exported modules by `iced_widget`
|
||||
mod core {}
|
||||
mod graphics {}
|
||||
mod native {}
|
||||
mod renderer {}
|
||||
mod style {}
|
||||
mod runtime {}
|
||||
}
|
||||
|
||||
pub use application::Application;
|
||||
pub use element::Element;
|
||||
pub use error::Error;
|
||||
pub use event::Event;
|
||||
pub use executor::Executor;
|
||||
pub use renderer::Renderer;
|
||||
pub use result::Result;
|
||||
pub use font::Font;
|
||||
pub use sandbox::Sandbox;
|
||||
pub use settings::Settings;
|
||||
pub use subscription::Subscription;
|
||||
pub use theme::Theme;
|
||||
|
||||
pub use runtime::alignment;
|
||||
pub use runtime::futures;
|
||||
pub use runtime::{
|
||||
color, Alignment, Background, Color, Command, ContentFit, Font, Length,
|
||||
Padding, Point, Rectangle, Size, Vector,
|
||||
};
|
||||
/// The default renderer.
|
||||
pub type Renderer<Theme = style::Theme> = renderer::Renderer<Theme>;
|
||||
|
||||
#[cfg(feature = "system")]
|
||||
pub use runtime::system;
|
||||
/// A generic widget.
|
||||
///
|
||||
/// This is an alias of an `iced_native` element with a default `Renderer`.
|
||||
pub type Element<'a, Message, Renderer = crate::Renderer> =
|
||||
crate::core::Element<'a, Message, Renderer>;
|
||||
|
||||
/// The result of running an [`Application`].
|
||||
///
|
||||
/// [`Application`]: crate::Application
|
||||
pub type Result = std::result::Result<(), Error>;
|
||||
|
|
|
|||
|
|
@ -1,2 +0,0 @@
|
|||
//! Listen and react to mouse events.
|
||||
pub use crate::runtime::mouse::{Button, Event, Interaction, ScrollDelta};
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
//! Display interactive elements on top of other widgets.
|
||||
|
||||
/// A generic [`Overlay`].
|
||||
///
|
||||
/// This is an alias of an `iced_native` element with a default `Renderer`.
|
||||
///
|
||||
/// [`Overlay`]: iced_native::Overlay
|
||||
pub type Element<'a, Message, Renderer = crate::Renderer> =
|
||||
iced_native::overlay::Element<'a, Message, Renderer>;
|
||||
|
||||
pub mod menu {
|
||||
//! Build and show dropdown menus.
|
||||
pub use iced_native::overlay::menu::{Appearance, State, StyleSheet};
|
||||
|
||||
/// A widget that produces a message when clicked.
|
||||
pub type Menu<'a, Message, Renderer = crate::Renderer> =
|
||||
iced_native::overlay::Menu<'a, Message, Renderer>;
|
||||
}
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
use crate::Error;
|
||||
|
||||
/// The result of running an [`Application`].
|
||||
///
|
||||
/// [`Application`]: crate::Application
|
||||
pub type Result = std::result::Result<(), Error>;
|
||||
|
|
@ -34,19 +34,19 @@ use crate::{Application, Command, Element, Error, Settings, Subscription};
|
|||
/// - [`tour`], a simple UI tour that can run both on native platforms and the
|
||||
/// web!
|
||||
///
|
||||
/// [The repository has a bunch of examples]: https://github.com/iced-rs/iced/tree/0.8/examples
|
||||
/// [`bezier_tool`]: https://github.com/iced-rs/iced/tree/0.8/examples/bezier_tool
|
||||
/// [`counter`]: https://github.com/iced-rs/iced/tree/0.8/examples/counter
|
||||
/// [`custom_widget`]: https://github.com/iced-rs/iced/tree/0.8/examples/custom_widget
|
||||
/// [`geometry`]: https://github.com/iced-rs/iced/tree/0.8/examples/geometry
|
||||
/// [`pane_grid`]: https://github.com/iced-rs/iced/tree/0.8/examples/pane_grid
|
||||
/// [`progress_bar`]: https://github.com/iced-rs/iced/tree/0.8/examples/progress_bar
|
||||
/// [`styling`]: https://github.com/iced-rs/iced/tree/0.8/examples/styling
|
||||
/// [`svg`]: https://github.com/iced-rs/iced/tree/0.8/examples/svg
|
||||
/// [`tour`]: https://github.com/iced-rs/iced/tree/0.8/examples/tour
|
||||
/// [The repository has a bunch of examples]: https://github.com/iced-rs/iced/tree/0.9/examples
|
||||
/// [`bezier_tool`]: https://github.com/iced-rs/iced/tree/0.9/examples/bezier_tool
|
||||
/// [`counter`]: https://github.com/iced-rs/iced/tree/0.9/examples/counter
|
||||
/// [`custom_widget`]: https://github.com/iced-rs/iced/tree/0.9/examples/custom_widget
|
||||
/// [`geometry`]: https://github.com/iced-rs/iced/tree/0.9/examples/geometry
|
||||
/// [`pane_grid`]: https://github.com/iced-rs/iced/tree/0.9/examples/pane_grid
|
||||
/// [`progress_bar`]: https://github.com/iced-rs/iced/tree/0.9/examples/progress_bar
|
||||
/// [`styling`]: https://github.com/iced-rs/iced/tree/0.9/examples/styling
|
||||
/// [`svg`]: https://github.com/iced-rs/iced/tree/0.9/examples/svg
|
||||
/// [`tour`]: https://github.com/iced-rs/iced/tree/0.9/examples/tour
|
||||
/// [`Canvas widget`]: crate::widget::Canvas
|
||||
/// [the overview]: index.html#overview
|
||||
/// [`iced_wgpu`]: https://github.com/iced-rs/iced/tree/0.8/wgpu
|
||||
/// [`iced_wgpu`]: https://github.com/iced-rs/iced/tree/0.9/wgpu
|
||||
/// [`Svg` widget]: crate::widget::Svg
|
||||
/// [Ghostscript Tiger]: https://commons.wikimedia.org/wiki/File:Ghostscript_Tiger.svg
|
||||
///
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
//! Configure your application.
|
||||
use crate::window;
|
||||
use crate::Font;
|
||||
|
||||
/// The settings of an application.
|
||||
#[derive(Debug, Clone)]
|
||||
|
|
@ -20,23 +21,16 @@ pub struct Settings<Flags> {
|
|||
/// [`Application`]: crate::Application
|
||||
pub flags: Flags,
|
||||
|
||||
/// The bytes of the font that will be used by default.
|
||||
/// The default [`Font`] to be used.
|
||||
///
|
||||
/// If `None` is provided, a default system font will be chosen.
|
||||
// TODO: Add `name` for web compatibility
|
||||
pub default_font: Option<&'static [u8]>,
|
||||
/// By default, it uses [`Font::SansSerif`].
|
||||
pub default_font: Font,
|
||||
|
||||
/// The text size that will be used by default.
|
||||
///
|
||||
/// The default value is `20.0`.
|
||||
/// The default value is `16.0`.
|
||||
pub default_text_size: f32,
|
||||
|
||||
/// If enabled, spread text workload in multiple threads when multiple cores
|
||||
/// are available.
|
||||
///
|
||||
/// By default, it is disabled.
|
||||
pub text_multithreading: bool,
|
||||
|
||||
/// If set to true, the renderer will try to perform antialiasing for some
|
||||
/// primitives.
|
||||
///
|
||||
|
|
@ -55,15 +49,6 @@ pub struct Settings<Flags> {
|
|||
///
|
||||
/// [`Application`]: crate::Application
|
||||
pub exit_on_close_request: bool,
|
||||
|
||||
/// Whether the [`Application`] should try to build the context
|
||||
/// using OpenGL ES first then OpenGL.
|
||||
///
|
||||
/// By default, it is disabled.
|
||||
/// **Note:** Only works for the `glow` backend.
|
||||
///
|
||||
/// [`Application`]: crate::Application
|
||||
pub try_opengles_first: bool,
|
||||
}
|
||||
|
||||
impl<Flags> Settings<Flags> {
|
||||
|
|
@ -79,10 +64,8 @@ impl<Flags> Settings<Flags> {
|
|||
window: default_settings.window,
|
||||
default_font: default_settings.default_font,
|
||||
default_text_size: default_settings.default_text_size,
|
||||
text_multithreading: default_settings.text_multithreading,
|
||||
antialiasing: default_settings.antialiasing,
|
||||
exit_on_close_request: default_settings.exit_on_close_request,
|
||||
try_opengles_first: default_settings.try_opengles_first,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -97,11 +80,9 @@ where
|
|||
window: Default::default(),
|
||||
flags: Default::default(),
|
||||
default_font: Default::default(),
|
||||
default_text_size: 20.0,
|
||||
text_multithreading: false,
|
||||
default_text_size: 16.0,
|
||||
antialiasing: false,
|
||||
exit_on_close_request: true,
|
||||
try_opengles_first: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -113,7 +94,6 @@ impl<Flags> From<Settings<Flags>> for iced_winit::Settings<Flags> {
|
|||
window: settings.window.into(),
|
||||
flags: settings.flags,
|
||||
exit_on_close_request: settings.exit_on_close_request,
|
||||
try_opengles_first: settings.try_opengles_first,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
//! Listen and react to touch events.
|
||||
pub use crate::runtime::touch::{Event, Finger};
|
||||
pub use crate::core::touch::{Event, Finger};
|
||||
|
|
|
|||
238
src/widget.rs
238
src/widget.rs
|
|
@ -1,238 +0,0 @@
|
|||
//! Display information and interactive controls in your application.
|
||||
pub use iced_native::widget::helpers::*;
|
||||
|
||||
pub use iced_native::{column, row};
|
||||
|
||||
/// A container that distributes its contents vertically.
|
||||
pub type Column<'a, Message, Renderer = crate::Renderer> =
|
||||
iced_native::widget::Column<'a, Message, Renderer>;
|
||||
|
||||
/// A container that distributes its contents horizontally.
|
||||
pub type Row<'a, Message, Renderer = crate::Renderer> =
|
||||
iced_native::widget::Row<'a, Message, Renderer>;
|
||||
|
||||
pub mod text {
|
||||
//! Write some text for your users to read.
|
||||
pub use iced_native::widget::text::{Appearance, StyleSheet};
|
||||
|
||||
/// A paragraph of text.
|
||||
pub type Text<'a, Renderer = crate::Renderer> =
|
||||
iced_native::widget::Text<'a, Renderer>;
|
||||
}
|
||||
|
||||
pub mod button {
|
||||
//! Allow your users to perform actions by pressing a button.
|
||||
pub use iced_native::widget::button::{Appearance, StyleSheet};
|
||||
|
||||
/// A widget that produces a message when clicked.
|
||||
pub type Button<'a, Message, Renderer = crate::Renderer> =
|
||||
iced_native::widget::Button<'a, Message, Renderer>;
|
||||
}
|
||||
|
||||
pub mod checkbox {
|
||||
//! Show toggle controls using checkboxes.
|
||||
pub use iced_native::widget::checkbox::{Appearance, Icon, StyleSheet};
|
||||
|
||||
/// A box that can be checked.
|
||||
pub type Checkbox<'a, Message, Renderer = crate::Renderer> =
|
||||
iced_native::widget::Checkbox<'a, Message, Renderer>;
|
||||
}
|
||||
|
||||
pub mod container {
|
||||
//! Decorate content and apply alignment.
|
||||
pub use iced_native::widget::container::{Appearance, StyleSheet};
|
||||
|
||||
/// An element decorating some content.
|
||||
pub type Container<'a, Message, Renderer = crate::Renderer> =
|
||||
iced_native::widget::Container<'a, Message, Renderer>;
|
||||
}
|
||||
|
||||
pub mod pane_grid {
|
||||
//! Let your users split regions of your application and organize layout dynamically.
|
||||
//!
|
||||
//! [](https://gfycat.com/mixedflatjellyfish)
|
||||
//!
|
||||
//! # Example
|
||||
//! The [`pane_grid` example] showcases how to use a [`PaneGrid`] with resizing,
|
||||
//! drag and drop, and hotkey support.
|
||||
//!
|
||||
//! [`pane_grid` example]: https://github.com/iced-rs/iced/tree/0.8/examples/pane_grid
|
||||
pub use iced_native::widget::pane_grid::{
|
||||
Axis, Configuration, Direction, DragEvent, Line, Node, Pane,
|
||||
ResizeEvent, Split, State, StyleSheet,
|
||||
};
|
||||
|
||||
/// A collection of panes distributed using either vertical or horizontal splits
|
||||
/// to completely fill the space available.
|
||||
///
|
||||
/// [](https://gfycat.com/mixedflatjellyfish)
|
||||
pub type PaneGrid<'a, Message, Renderer = crate::Renderer> =
|
||||
iced_native::widget::PaneGrid<'a, Message, Renderer>;
|
||||
|
||||
/// The content of a [`Pane`].
|
||||
pub type Content<'a, Message, Renderer = crate::Renderer> =
|
||||
iced_native::widget::pane_grid::Content<'a, Message, Renderer>;
|
||||
|
||||
/// The title bar of a [`Pane`].
|
||||
pub type TitleBar<'a, Message, Renderer = crate::Renderer> =
|
||||
iced_native::widget::pane_grid::TitleBar<'a, Message, Renderer>;
|
||||
}
|
||||
|
||||
pub mod pick_list {
|
||||
//! Display a dropdown list of selectable values.
|
||||
pub use iced_native::widget::pick_list::{
|
||||
Appearance, Handle, Icon, StyleSheet,
|
||||
};
|
||||
|
||||
/// A widget allowing the selection of a single value from a list of options.
|
||||
pub type PickList<'a, T, Message, Renderer = crate::Renderer> =
|
||||
iced_native::widget::PickList<'a, T, Message, Renderer>;
|
||||
}
|
||||
|
||||
pub mod radio {
|
||||
//! Create choices using radio buttons.
|
||||
pub use iced_native::widget::radio::{Appearance, StyleSheet};
|
||||
|
||||
/// A circular button representing a choice.
|
||||
pub type Radio<Message, Renderer = crate::Renderer> =
|
||||
iced_native::widget::Radio<Message, Renderer>;
|
||||
}
|
||||
|
||||
pub mod scrollable {
|
||||
//! Navigate an endless amount of content with a scrollbar.
|
||||
pub use iced_native::widget::scrollable::{
|
||||
snap_to, style::Scrollbar, style::Scroller, Id, Properties,
|
||||
RelativeOffset, StyleSheet,
|
||||
};
|
||||
|
||||
/// A widget that can vertically display an infinite amount of content
|
||||
/// with a scrollbar.
|
||||
pub type Scrollable<'a, Message, Renderer = crate::Renderer> =
|
||||
iced_native::widget::Scrollable<'a, Message, Renderer>;
|
||||
}
|
||||
|
||||
pub mod toggler {
|
||||
//! Show toggle controls using togglers.
|
||||
pub use iced_native::widget::toggler::{Appearance, StyleSheet};
|
||||
|
||||
/// A toggler widget.
|
||||
pub type Toggler<'a, Message, Renderer = crate::Renderer> =
|
||||
iced_native::widget::Toggler<'a, Message, Renderer>;
|
||||
}
|
||||
|
||||
pub mod text_input {
|
||||
//! Display fields that can be filled with text.
|
||||
pub use iced_native::widget::text_input::{
|
||||
focus, move_cursor_to, move_cursor_to_end, move_cursor_to_front,
|
||||
select_all, Appearance, Id, StyleSheet,
|
||||
};
|
||||
|
||||
/// A field that can be filled with text.
|
||||
pub type TextInput<'a, Message, Renderer = crate::Renderer> =
|
||||
iced_native::widget::TextInput<'a, Message, Renderer>;
|
||||
}
|
||||
|
||||
pub mod tooltip {
|
||||
//! Display a widget over another.
|
||||
pub use iced_native::widget::tooltip::Position;
|
||||
|
||||
/// A widget allowing the selection of a single value from a list of options.
|
||||
pub type Tooltip<'a, Message, Renderer = crate::Renderer> =
|
||||
iced_native::widget::Tooltip<'a, Message, Renderer>;
|
||||
}
|
||||
|
||||
pub use iced_native::widget::progress_bar;
|
||||
pub use iced_native::widget::rule;
|
||||
pub use iced_native::widget::slider;
|
||||
pub use iced_native::widget::vertical_slider;
|
||||
pub use iced_native::widget::Space;
|
||||
|
||||
pub use button::Button;
|
||||
pub use checkbox::Checkbox;
|
||||
pub use container::Container;
|
||||
pub use pane_grid::PaneGrid;
|
||||
pub use pick_list::PickList;
|
||||
pub use progress_bar::ProgressBar;
|
||||
pub use radio::Radio;
|
||||
pub use rule::Rule;
|
||||
pub use scrollable::Scrollable;
|
||||
pub use slider::Slider;
|
||||
pub use text::Text;
|
||||
pub use text_input::TextInput;
|
||||
pub use toggler::Toggler;
|
||||
pub use tooltip::Tooltip;
|
||||
pub use vertical_slider::VerticalSlider;
|
||||
|
||||
#[cfg(feature = "canvas")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "canvas")))]
|
||||
pub use iced_graphics::widget::canvas;
|
||||
|
||||
#[cfg(feature = "canvas")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "canvas")))]
|
||||
/// Creates a new [`Canvas`].
|
||||
pub fn canvas<P, Message, Theme>(program: P) -> Canvas<Message, Theme, P>
|
||||
where
|
||||
P: canvas::Program<Message, Theme>,
|
||||
{
|
||||
Canvas::new(program)
|
||||
}
|
||||
|
||||
#[cfg(feature = "image")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "image")))]
|
||||
pub mod image {
|
||||
//! Display images in your user interface.
|
||||
pub use iced_native::image::Handle;
|
||||
|
||||
/// A frame that displays an image.
|
||||
pub type Image = iced_native::widget::Image<Handle>;
|
||||
|
||||
pub use iced_native::widget::image::viewer;
|
||||
pub use viewer::Viewer;
|
||||
}
|
||||
|
||||
#[cfg(feature = "qr_code")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "qr_code")))]
|
||||
pub use iced_graphics::widget::qr_code;
|
||||
|
||||
#[cfg(feature = "svg")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "svg")))]
|
||||
pub mod svg {
|
||||
//! Display vector graphics in your application.
|
||||
pub use iced_native::svg::Handle;
|
||||
pub use iced_native::widget::svg::{Appearance, StyleSheet, Svg};
|
||||
}
|
||||
|
||||
#[cfg(feature = "canvas")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "canvas")))]
|
||||
pub use canvas::Canvas;
|
||||
|
||||
#[cfg(feature = "image")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "image")))]
|
||||
pub use image::Image;
|
||||
|
||||
#[cfg(feature = "qr_code")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "qr_code")))]
|
||||
pub use qr_code::QRCode;
|
||||
|
||||
#[cfg(feature = "svg")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "svg")))]
|
||||
pub use svg::Svg;
|
||||
|
||||
use crate::Command;
|
||||
use iced_native::widget::operation;
|
||||
|
||||
/// Focuses the previous focusable widget.
|
||||
pub fn focus_previous<Message>() -> Command<Message>
|
||||
where
|
||||
Message: 'static,
|
||||
{
|
||||
Command::widget(operation::focusable::focus_previous())
|
||||
}
|
||||
|
||||
/// Focuses the next focusable widget.
|
||||
pub fn focus_next<Message>() -> Command<Message>
|
||||
where
|
||||
Message: 'static,
|
||||
{
|
||||
Command::widget(operation::focusable::focus_next())
|
||||
}
|
||||
|
|
@ -1,6 +1,12 @@
|
|||
//! Configure the window of your application in native platforms.
|
||||
pub use iced_native::window::Icon;
|
||||
pub use iced_native::window::Position;
|
||||
pub use iced_native::window::Settings;
|
||||
mod position;
|
||||
mod settings;
|
||||
|
||||
pub mod icon;
|
||||
|
||||
pub use icon::Icon;
|
||||
pub use position::Position;
|
||||
pub use settings::{PlatformSpecific, Settings};
|
||||
|
||||
pub use crate::core::window::*;
|
||||
pub use crate::runtime::window::*;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue