Skip to content

Commit

Permalink
Merge pull request #1830 from iced-rs/advanced-text
Browse files Browse the repository at this point in the history
Advanced text
  • Loading branch information
hecrj authored May 11, 2023
2 parents bc62013 + 63d3fc6 commit 669f7cc
Show file tree
Hide file tree
Showing 321 changed files with 8,696 additions and 9,513 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ jobs:
run: cargo build --package tour --target wasm32-unknown-unknown
- name: Check compilation of `todos` example
run: cargo build --package todos --target wasm32-unknown-unknown
- name: Check compilation of `integration_wgpu` example
run: cargo build --package integration_wgpu --target wasm32-unknown-unknown
- name: Check compilation of `integration` example
run: cargo build --package integration --target wasm32-unknown-unknown
49 changes: 17 additions & 32 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,18 @@ categories = ["gui"]

[features]
default = ["wgpu"]
# Enable the `wgpu` GPU-accelerated renderer backend
wgpu = ["iced_renderer/wgpu"]
# Enables the `Image` widget
image = ["iced_wgpu?/image", "iced_glow?/image", "image_rs"]
image = ["iced_widget/image", "image_rs"]
# Enables the `Svg` widget
svg = ["iced_wgpu?/svg", "iced_glow?/svg"]
svg = ["iced_widget/svg"]
# Enables the `Canvas` widget
canvas = ["iced_graphics/canvas"]
canvas = ["iced_widget/canvas"]
# Enables the `QRCode` widget
qr_code = ["iced_graphics/qr_code"]
# Enables the `iced_wgpu` renderer
wgpu = ["iced_wgpu"]
# Enables using system fonts
default_system_font = ["iced_wgpu?/default_system_font", "iced_glow?/default_system_font"]
# Enables the `iced_glow` renderer. Overrides `iced_wgpu`
glow = ["iced_glow", "iced_glutin"]
qr_code = ["iced_widget/qr_code"]
# Enables lazy widgets
lazy = ["iced_widget/lazy"]
# Enables a debug view in native platforms (press F12)
debug = ["iced_winit/debug"]
# Enables `tokio` as the `executor::Default` on native platforms
Expand All @@ -39,13 +37,8 @@ smol = ["iced_futures/smol"]
palette = ["iced_core/palette"]
# Enables querying system information
system = ["iced_winit/system"]
# Enables chrome traces
chrome-trace = [
"iced_winit/chrome-trace",
"iced_glutin?/trace",
"iced_wgpu?/tracing",
"iced_glow?/tracing",
]
# Enables the advanced module
advanced = []

[badges]
maintenance = { status = "actively-developed" }
Expand All @@ -55,37 +48,29 @@ members = [
"core",
"futures",
"graphics",
"glow",
"glutin",
"lazy",
"native",
"runtime",
"renderer",
"style",
"tiny_skia",
"wgpu",
"widget",
"winit",
"examples/*",
]

[dependencies]
iced_core = { version = "0.9", path = "core" }
iced_futures = { version = "0.6", path = "futures" }
iced_native = { version = "0.10", path = "native" }
iced_graphics = { version = "0.8", path = "graphics" }
iced_renderer = { version = "0.1", path = "renderer" }
iced_widget = { version = "0.1", path = "widget" }
iced_winit = { version = "0.9", path = "winit", features = ["application"] }
iced_glutin = { version = "0.8", path = "glutin", optional = true }
iced_glow = { version = "0.8", path = "glow", optional = true }
thiserror = "1.0"
thiserror = "1"

[dependencies.image_rs]
version = "0.24"
package = "image"
optional = true

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
iced_wgpu = { version = "0.10", path = "wgpu", optional = true }

[target.'cfg(target_arch = "wasm32")'.dependencies]
iced_wgpu = { version = "0.10", path = "wgpu", features = ["webgl"], optional = true }

[package.metadata.docs.rs]
rustdoc-args = ["--cfg", "docsrs"]
features = ["image", "svg", "canvas", "qr_code"]
Expand Down
36 changes: 4 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ Inspired by [Elm].
* First-class support for async actions (use futures!)
* [Modular ecosystem] split into reusable parts:
* A [renderer-agnostic native runtime] enabling integration with existing systems
* Two [built-in renderers] leveraging [`wgpu`] and [`glow`]
* Two [built-in renderers] leveraging [`wgpu`] and [`tiny-skia`]
* [`iced_wgpu`] supporting Vulkan, Metal and DX12
* [`iced_glow`] supporting OpenGL 2.1+ and OpenGL ES 2.0+
* [`iced_tiny_skia`] offering a software alternative as a fallback
* A [windowing shell]
* A [web runtime] leveraging the DOM

Expand All @@ -52,9 +52,9 @@ __Iced is currently experimental software.__ [Take a look at the roadmap],
[Modular ecosystem]: ECOSYSTEM.md
[renderer-agnostic native runtime]: native/
[`wgpu`]: https://github.com/gfx-rs/wgpu
[`glow`]: https://github.com/grovesNL/glow
[`tiny-skia`]: https://github.com/RazrFalcon/tiny-skia
[`iced_wgpu`]: wgpu/
[`iced_glow`]: glow/
[`iced_tiny_skia`]: tiny_skia/
[built-in renderers]: ECOSYSTEM.md#Renderers
[windowing shell]: winit/
[`dodrio`]: https://github.com/fitzgen/dodrio
Expand Down Expand Up @@ -196,34 +196,6 @@ end-user-oriented GUI library, while keeping [the ecosystem] modular:
[`ggez`]: https://github.com/ggez/ggez
[the ecosystem]: ECOSYSTEM.md

## Troubleshooting

### `GraphicsAdapterNotFound`

This occurs when the selected [built-in renderer] is not able to create a context.

Often this will occur while using [`iced_wgpu`] as the renderer without
supported hardware (needs Vulkan, Metal or DX12). In this case, you could try using the
[`iced_glow`] renderer:

First, check if it works with

```console
cargo run --features iced/glow --package game_of_life
```

and then use it in your project with

```toml
iced = { version = "0.9", default-features = false, features = ["glow"] }
```

__NOTE:__ Chances are you have hardware that supports at least OpenGL 2.1 or OpenGL ES 2.0,
but if you don't, right now there's no software fallback, so it means your hardware
doesn't support Iced.

[built-in renderer]: https://github.com/iced-rs/iced/blob/master/ECOSYSTEM.md#Renderers

## Contributing / Feedback

Contributions are greatly appreciated! If you want to contribute, please
Expand Down
2 changes: 2 additions & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ repository = "https://github.com/iced-rs/iced"

[dependencies]
bitflags = "1.2"
thiserror = "1"
twox-hash = { version = "1.5", default-features = false }

[dependencies.palette]
version = "0.6"
Expand Down
23 changes: 23 additions & 0 deletions core/src/clipboard.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//! Access the clipboard.

/// A buffer for short-term storage and transfer within and between
/// applications.
pub trait Clipboard {
/// Reads the current content of the [`Clipboard`] as text.
fn read(&self) -> Option<String>;

/// Writes the given text contents to the [`Clipboard`].
fn write(&mut self, contents: String);
}

/// A null implementation of the [`Clipboard`] trait.
#[derive(Debug, Clone, Copy)]
pub struct Null;

impl Clipboard for Null {
fn read(&self) -> Option<String> {
None
}

fn write(&mut self, _contents: String) {}
}
67 changes: 46 additions & 21 deletions native/src/element.rs → core/src/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,41 +90,65 @@ impl<'a, Message, Renderer> Element<'a, Message, Renderer> {
/// We compose the previous __messages__ with the index of the counter
/// producing them. Let's implement our __view logic__ now:
///
/// ```
/// ```no_run
/// # mod counter {
/// # type Text<'a> = iced_native::widget::Text<'a, iced_native::renderer::Null>;
/// #
/// # #[derive(Debug, Clone, Copy)]
/// # pub enum Message {}
/// # pub struct Counter;
/// #
/// # impl Counter {
/// # pub fn view(&mut self) -> Text {
/// # Text::new("")
/// # pub fn view(
/// # &self,
/// # ) -> iced_core::Element<Message, iced_core::renderer::Null> {
/// # unimplemented!()
/// # }
/// # }
/// # }
/// #
/// # mod iced_wgpu {
/// # pub use iced_native::renderer::Null as Renderer;
/// # }
/// # mod iced {
/// # pub use iced_core::renderer::Null as Renderer;
/// # pub use iced_core::Element;
/// #
/// # use counter::Counter;
/// # pub mod widget {
/// # pub struct Row<Message> {
/// # _t: std::marker::PhantomData<Message>,
/// # }
/// #
/// # struct ManyCounters {
/// # counters: Vec<Counter>,
/// # }
/// # impl<Message> Row<Message> {
/// # pub fn new() -> Self {
/// # unimplemented!()
/// # }
/// #
/// # #[derive(Debug, Clone, Copy)]
/// # pub enum Message {
/// # Counter(usize, counter::Message)
/// # pub fn spacing(mut self, _: u32) -> Self {
/// # unimplemented!()
/// # }
/// #
/// # pub fn push(
/// # mut self,
/// # _: iced_core::Element<Message, iced_core::renderer::Null>,
/// # ) -> Self {
/// # unimplemented!()
/// # }
/// # }
/// # }
/// # }
/// use iced_native::Element;
/// use iced_native::widget::Row;
/// use iced_wgpu::Renderer;
/// #
/// use counter::Counter;
///
/// use iced::widget::Row;
/// use iced::{Element, Renderer};
///
/// struct ManyCounters {
/// counters: Vec<Counter>,
/// }
///
/// #[derive(Debug, Clone, Copy)]
/// pub enum Message {
/// Counter(usize, counter::Message),
/// }
///
/// impl ManyCounters {
/// pub fn view(&mut self) -> Row<Message, Renderer> {
/// pub fn view(&mut self) -> Row<Message> {
/// // We can quickly populate a `Row` by folding over our counters
/// self.counters.iter_mut().enumerate().fold(
/// Row::new().spacing(20),
Expand All @@ -137,9 +161,10 @@ impl<'a, Message, Renderer> Element<'a, Message, Renderer> {
/// // Here we turn our `Element<counter::Message>` into
/// // an `Element<Message>` by combining the `index` and the
/// // message of the `element`.
/// element.map(move |message| Message::Counter(index, message))
/// element
/// .map(move |message| Message::Counter(index, message)),
/// )
/// }
/// },
/// )
/// }
/// }
Expand Down
2 changes: 1 addition & 1 deletion native/src/event.rs → core/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl Status {
/// `Captured` takes precedence over `Ignored`:
///
/// ```
/// use iced_native::event::Status;
/// use iced_core::event::Status;
///
/// assert_eq!(Status::Ignored.merge(Status::Ignored), Status::Ignored);
/// assert_eq!(Status::Ignored.merge(Status::Captured), Status::Captured);
Expand Down
Loading

0 comments on commit 669f7cc

Please sign in to comment.