Merge branch 'master' into feat/multi-window-support
This commit is contained in:
commit
e09b4e24dd
331 changed files with 12085 additions and 3976 deletions
|
|
@ -39,15 +39,15 @@ pub use crate::style::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.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
|
||||
/// [The repository has a bunch of examples]: https://github.com/iced-rs/iced/tree/0.10/examples
|
||||
/// [`clock`]: https://github.com/iced-rs/iced/tree/0.10/examples/clock
|
||||
/// [`download_progress`]: https://github.com/iced-rs/iced/tree/0.10/examples/download_progress
|
||||
/// [`events`]: https://github.com/iced-rs/iced/tree/0.10/examples/events
|
||||
/// [`game_of_life`]: https://github.com/iced-rs/iced/tree/0.10/examples/game_of_life
|
||||
/// [`pokedex`]: https://github.com/iced-rs/iced/tree/0.10/examples/pokedex
|
||||
/// [`solar_system`]: https://github.com/iced-rs/iced/tree/0.10/examples/solar_system
|
||||
/// [`stopwatch`]: https://github.com/iced-rs/iced/tree/0.10/examples/stopwatch
|
||||
/// [`todos`]: https://github.com/iced-rs/iced/tree/0.10/examples/todos
|
||||
/// [`Sandbox`]: crate::Sandbox
|
||||
/// [`Canvas`]: crate::widget::Canvas
|
||||
/// [PokéAPI]: https://pokeapi.co/
|
||||
|
|
|
|||
56
src/lib.rs
56
src/lib.rs
|
|
@ -20,17 +20,17 @@
|
|||
//! Check out the [repository] and the [examples] for more details!
|
||||
//!
|
||||
//! [Cross-platform support]: https://github.com/iced-rs/iced/blob/master/docs/images/todos_desktop.jpg?raw=true
|
||||
//! [text inputs]: https://gfycat.com/alertcalmcrow-rust-gui
|
||||
//! [scrollables]: https://gfycat.com/perkybaggybaboon-rust-gui
|
||||
//! [Debug overlay with performance metrics]: https://gfycat.com/incredibledarlingbee
|
||||
//! [text inputs]: https://iced.rs/examples/text_input.mp4
|
||||
//! [scrollables]: https://iced.rs/examples/scrollable.mp4
|
||||
//! [Debug overlay with performance metrics]: https://iced.rs/examples/debug.mp4
|
||||
//! [Modular ecosystem]: https://github.com/iced-rs/iced/blob/master/ECOSYSTEM.md
|
||||
//! [renderer-agnostic native runtime]: https://github.com/iced-rs/iced/tree/0.9/native
|
||||
//! [renderer-agnostic native runtime]: https://github.com/iced-rs/iced/tree/0.10/runtime
|
||||
//! [`wgpu`]: https://github.com/gfx-rs/wgpu-rs
|
||||
//! [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
|
||||
//! [built-in renderer]: https://github.com/iced-rs/iced/tree/0.10/wgpu
|
||||
//! [windowing shell]: https://github.com/iced-rs/iced/tree/0.10/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.9/examples
|
||||
//! [examples]: https://github.com/iced-rs/iced/tree/0.10/examples
|
||||
//! [repository]: https://github.com/iced-rs/iced
|
||||
//!
|
||||
//! # Overview
|
||||
|
|
@ -86,7 +86,7 @@
|
|||
//! use iced::widget::{button, column, text, Column};
|
||||
//!
|
||||
//! impl Counter {
|
||||
//! pub fn view(&mut self) -> Column<Message> {
|
||||
//! pub fn view(&self) -> Column<Message> {
|
||||
//! // We use a column: a simple vertical layout
|
||||
//! column![
|
||||
//! // The increment button. We tell it to produce an
|
||||
|
|
@ -151,18 +151,13 @@
|
|||
#![doc(
|
||||
html_logo_url = "https://raw.githubusercontent.com/iced-rs/iced/9ab6923e943f784985e9ef9ca28b10278297225d/docs/logo.svg"
|
||||
)]
|
||||
#![forbid(rust_2018_idioms, unsafe_code)]
|
||||
#![deny(
|
||||
missing_debug_implementations,
|
||||
missing_docs,
|
||||
unused_results,
|
||||
clippy::extra_unused_lifetimes,
|
||||
clippy::from_over_into,
|
||||
clippy::needless_borrow,
|
||||
clippy::new_without_default,
|
||||
clippy::useless_conversion
|
||||
rustdoc::broken_intra_doc_links
|
||||
)]
|
||||
#![forbid(rust_2018_idioms, unsafe_code)]
|
||||
#![allow(clippy::inherent_to_string, clippy::type_complexity)]
|
||||
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
|
||||
use iced_widget::graphics;
|
||||
use iced_widget::renderer;
|
||||
|
|
@ -173,6 +168,9 @@ use iced_winit::runtime;
|
|||
|
||||
pub use iced_futures::futures;
|
||||
|
||||
#[cfg(feature = "highlighter")]
|
||||
pub use iced_highlighter as highlighter;
|
||||
|
||||
mod error;
|
||||
mod sandbox;
|
||||
|
||||
|
|
@ -190,13 +188,11 @@ pub mod multi_window;
|
|||
pub use style::theme;
|
||||
|
||||
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,
|
||||
color, Alignment, Background, BorderRadius, Color, ContentFit, Degrees,
|
||||
Gradient, Length, Padding, Pixels, Point, Radians, Rectangle, Size, Vector,
|
||||
};
|
||||
pub use crate::runtime::Command;
|
||||
|
||||
pub mod clipboard {
|
||||
//! Access the clipboard.
|
||||
|
|
@ -226,9 +222,16 @@ pub mod font {
|
|||
pub use crate::runtime::font::*;
|
||||
}
|
||||
|
||||
pub mod event {
|
||||
//! Handle events of a user interface.
|
||||
pub use crate::core::event::{Event, MacOS, PlatformSpecific, Status};
|
||||
pub use iced_futures::event::{listen, listen_raw, listen_with};
|
||||
}
|
||||
|
||||
pub mod keyboard {
|
||||
//! Listen and react to keyboard events.
|
||||
pub use crate::core::keyboard::{Event, KeyCode, Modifiers};
|
||||
pub use iced_futures::keyboard::{on_key_press, on_key_release};
|
||||
}
|
||||
|
||||
pub mod mouse {
|
||||
|
|
@ -238,10 +241,15 @@ pub mod mouse {
|
|||
};
|
||||
}
|
||||
|
||||
pub mod command {
|
||||
//! Run asynchronous actions.
|
||||
pub use crate::runtime::command::{channel, Command};
|
||||
}
|
||||
|
||||
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,
|
||||
channel, run, run_with_id, unfold, Subscription,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -255,11 +263,11 @@ pub mod system {
|
|||
pub mod overlay {
|
||||
//! Display interactive elements on top of other widgets.
|
||||
|
||||
/// A generic [`Overlay`].
|
||||
/// A generic overlay.
|
||||
///
|
||||
/// This is an alias of an `iced_native` element with a default `Renderer`.
|
||||
/// This is an alias of an [`overlay::Element`] with a default `Renderer`.
|
||||
///
|
||||
/// [`Overlay`]: iced_native::Overlay
|
||||
/// [`overlay::Element`]: crate::core::overlay::Element
|
||||
pub type Element<'a, Message, Renderer = crate::Renderer> =
|
||||
crate::core::overlay::Element<'a, Message, Renderer>;
|
||||
|
||||
|
|
@ -271,6 +279,7 @@ pub mod touch {
|
|||
pub use crate::core::touch::{Event, Finger};
|
||||
}
|
||||
|
||||
#[allow(hidden_glob_reexports)]
|
||||
pub mod widget {
|
||||
//! Use the built-in widgets or create your own.
|
||||
pub use iced_widget::*;
|
||||
|
|
@ -285,6 +294,7 @@ pub mod widget {
|
|||
}
|
||||
|
||||
pub use application::Application;
|
||||
pub use command::Command;
|
||||
pub use error::Error;
|
||||
pub use event::Event;
|
||||
pub use executor::Executor;
|
||||
|
|
|
|||
|
|
@ -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.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
|
||||
/// [The repository has a bunch of examples]: https://github.com/iced-rs/iced/tree/0.10/examples
|
||||
/// [`bezier_tool`]: https://github.com/iced-rs/iced/tree/0.10/examples/bezier_tool
|
||||
/// [`counter`]: https://github.com/iced-rs/iced/tree/0.10/examples/counter
|
||||
/// [`custom_widget`]: https://github.com/iced-rs/iced/tree/0.10/examples/custom_widget
|
||||
/// [`geometry`]: https://github.com/iced-rs/iced/tree/0.10/examples/geometry
|
||||
/// [`pane_grid`]: https://github.com/iced-rs/iced/tree/0.10/examples/pane_grid
|
||||
/// [`progress_bar`]: https://github.com/iced-rs/iced/tree/0.10/examples/progress_bar
|
||||
/// [`styling`]: https://github.com/iced-rs/iced/tree/0.10/examples/styling
|
||||
/// [`svg`]: https://github.com/iced-rs/iced/tree/0.10/examples/svg
|
||||
/// [`tour`]: https://github.com/iced-rs/iced/tree/0.10/examples/tour
|
||||
/// [`Canvas widget`]: crate::widget::Canvas
|
||||
/// [the overview]: index.html#overview
|
||||
/// [`iced_wgpu`]: https://github.com/iced-rs/iced/tree/0.9/wgpu
|
||||
/// [`iced_wgpu`]: https://github.com/iced-rs/iced/tree/0.10/wgpu
|
||||
/// [`Svg` widget]: crate::widget::Svg
|
||||
/// [Ghostscript Tiger]: https://commons.wikimedia.org/wiki/File:Ghostscript_Tiger.svg
|
||||
///
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
//! Configure your application.
|
||||
use crate::window;
|
||||
use crate::Font;
|
||||
use crate::{Font, Pixels};
|
||||
|
||||
use std::borrow::Cow;
|
||||
|
||||
/// The settings of an application.
|
||||
#[derive(Debug, Clone)]
|
||||
|
|
@ -21,15 +23,18 @@ pub struct Settings<Flags> {
|
|||
/// [`Application`]: crate::Application
|
||||
pub flags: Flags,
|
||||
|
||||
/// The fonts to load on boot.
|
||||
pub fonts: Vec<Cow<'static, [u8]>>,
|
||||
|
||||
/// The default [`Font`] to be used.
|
||||
///
|
||||
/// By default, it uses [`Font::SansSerif`].
|
||||
/// By default, it uses [`Family::SansSerif`](crate::font::Family::SansSerif).
|
||||
pub default_font: Font,
|
||||
|
||||
/// The text size that will be used by default.
|
||||
///
|
||||
/// The default value is `16.0`.
|
||||
pub default_text_size: f32,
|
||||
pub default_text_size: Pixels,
|
||||
|
||||
/// If set to true, the renderer will try to perform antialiasing for some
|
||||
/// primitives.
|
||||
|
|
@ -54,6 +59,7 @@ impl<Flags> Settings<Flags> {
|
|||
flags,
|
||||
id: default_settings.id,
|
||||
window: default_settings.window,
|
||||
fonts: default_settings.fonts,
|
||||
default_font: default_settings.default_font,
|
||||
default_text_size: default_settings.default_text_size,
|
||||
antialiasing: default_settings.antialiasing,
|
||||
|
|
@ -68,10 +74,11 @@ where
|
|||
fn default() -> Self {
|
||||
Self {
|
||||
id: None,
|
||||
window: Default::default(),
|
||||
window: window::Settings::default(),
|
||||
flags: Default::default(),
|
||||
default_font: Default::default(),
|
||||
default_text_size: 16.0,
|
||||
fonts: Vec::new(),
|
||||
default_font: Font::default(),
|
||||
default_text_size: Pixels(16.0),
|
||||
antialiasing: false,
|
||||
}
|
||||
}
|
||||
|
|
@ -83,6 +90,7 @@ impl<Flags> From<Settings<Flags>> for iced_winit::Settings<Flags> {
|
|||
id: settings.id,
|
||||
window: settings.window,
|
||||
flags: settings.flags,
|
||||
fonts: settings.fonts,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,10 +10,10 @@ use std::path::Path;
|
|||
|
||||
/// Creates an icon from an image file.
|
||||
///
|
||||
/// This will return an error in case the file is missing at run-time. You may prefer [`Self::from_file_data`] instead.
|
||||
/// This will return an error in case the file is missing at run-time. You may prefer [`from_file_data`] instead.
|
||||
#[cfg(feature = "image")]
|
||||
pub fn from_file<P: AsRef<Path>>(icon_path: P) -> Result<Icon, Error> {
|
||||
let icon = image_rs::io::Reader::open(icon_path)?.decode()?.to_rgba8();
|
||||
let icon = image::io::Reader::open(icon_path)?.decode()?.to_rgba8();
|
||||
|
||||
Ok(icon::from_rgba(icon.to_vec(), icon.width(), icon.height())?)
|
||||
}
|
||||
|
|
@ -25,9 +25,10 @@ pub fn from_file<P: AsRef<Path>>(icon_path: P) -> Result<Icon, Error> {
|
|||
#[cfg(feature = "image")]
|
||||
pub fn from_file_data(
|
||||
data: &[u8],
|
||||
explicit_format: Option<image_rs::ImageFormat>,
|
||||
explicit_format: Option<image::ImageFormat>,
|
||||
) -> Result<Icon, Error> {
|
||||
let mut icon = image_rs::io::Reader::new(std::io::Cursor::new(data));
|
||||
let mut icon = image::io::Reader::new(std::io::Cursor::new(data));
|
||||
|
||||
let icon_with_format = match explicit_format {
|
||||
Some(format) => {
|
||||
icon.set_format(format);
|
||||
|
|
@ -59,5 +60,5 @@ pub enum Error {
|
|||
/// The `image` crate reported an error.
|
||||
#[cfg(feature = "image")]
|
||||
#[error("Unable to create icon from a file: {0}")]
|
||||
ImageError(#[from] image_rs::error::ImageError),
|
||||
ImageError(#[from] image::error::ImageError),
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue