Skip to content
Merged
Show file tree
Hide file tree
Changes from 168 commits
Commits
Show all changes
180 commits
Select commit Hold shift + click to select a range
b9a9576
Remove `iced_glow`, `glyph-brush`, and `wgpu_glyph` dependencies
hecrj Jan 6, 2023
baf51a8
Draft `glyphon` implementation of text pipeline for `iced_wgpu`
hecrj Jan 31, 2023
ba258f8
Implement support for multiple text layers in `iced_wgpu`
hecrj Feb 1, 2023
98a16fd
Implement proper text alignment support in `iced_wgpu`
hecrj Feb 1, 2023
c68edb3
Fix `TextInput` line height
hecrj Feb 1, 2023
bb27982
Convert sRGB to linear RGB for text in `iced_wgpu`
hecrj Feb 1, 2023
032e860
Fix `PickList` line height
hecrj Feb 1, 2023
1d0c44f
Implement basic text caching in `iced_wgpu`
hecrj Feb 2, 2023
02fc7e6
Trim text `render_cache` after rendering in `iced_wgpu`
hecrj Feb 2, 2023
6b70771
Avoid unnecessary `Vec` allocation in text pipeline
hecrj Feb 2, 2023
c8e8b1a
Use `bounds` directly for `measure` in text pipeline
hecrj Feb 2, 2023
0a324f0
Implement `hit_test` for `text::Pipeline` in `iced_wgpu`
hecrj Feb 2, 2023
a7580e0
Count `layout_runs` instead of using `visible_lines` in `text::Pipeli…
hecrj Feb 4, 2023
b29de28
Overhaul `Font` type to allow font family selection
hecrj Feb 4, 2023
238154a
Implement `font::load` command in `iced_native`
hecrj Feb 4, 2023
5a82fc6
Use floating coordinates directly in `text::Pipeline`
hecrj Feb 4, 2023
d282536
Load `Iced-Icons.ttf` font in `text::Pipeline::new`
hecrj Feb 4, 2023
17470bf
Fix `clippy` lints :tada:
hecrj Feb 4, 2023
da41820
Disable `std` feature for `twox-hash` to fix Wasm build
hecrj Feb 4, 2023
b4dd9b6
Update `glyphon` fork (sRGB support)
hecrj Feb 4, 2023
de7fc63
Fix `test` workflow
hecrj Feb 4, 2023
a2ab9e9
Use `Pixels` for `Text::size`
hecrj Feb 4, 2023
eb3cd3a
Fix `overlay::Menu` line height
hecrj Feb 5, 2023
32309f0
Introduce `Weight` enum to `font`
hecrj Feb 5, 2023
6cf4a10
Stop reusing `SwashCache` in `text::Pipeline`
hecrj Feb 5, 2023
f37b87f
Avoid allocating `text_areas` in `text::Pipeline`
hecrj Feb 5, 2023
15d257a
Stop truncating the `renderers` in `text::Pipeline`
hecrj Feb 5, 2023
dd80772
Set a minimum `height` for `Buffer` of `size * 1.2`
hecrj Feb 5, 2023
7d4c63d
Set `Attrs::monospaced` if `Font::Monospace` is selected
hecrj Feb 5, 2023
c8befa8
Fix useless `f32` conversions and please `clippy`
hecrj Feb 5, 2023
680ea5d
Refactor `quad::Pipeline` to `prepare` and `render` architecture
hecrj Feb 6, 2023
a970f34
Apply `ceil` to text bounds when drawing
hecrj Feb 7, 2023
77b5949
Fix rendering order for `quad::Pipeline`
hecrj Feb 7, 2023
34c963f
Remove unnecessary borrow in `quad::Pipeline`
hecrj Feb 7, 2023
363966e
Refactor `image::Pipeline` into `prepare` and `render` architecture
hecrj Feb 7, 2023
23ed352
Fix needless borrows in `image::Pipeline`
hecrj Feb 7, 2023
b8c1809
Refactor `triangle::Pipeline` into `prepare` and `render` architecture
hecrj Feb 7, 2023
730d6a0
Reuse a `RenderPass` as much as possible in `iced_wgpu`
hecrj Feb 7, 2023
21886d7
Use my GitHub fork of `glyphon`
hecrj Feb 7, 2023
ddbf93a
Set scissoring properly in `text::Pipeline`
hecrj Feb 8, 2023
05c787c
Grow atlas in `text::Pipeline` when necessary
hecrj Feb 8, 2023
0715d7d
Update `glyphon` in `iced_wgpu`
hecrj Feb 8, 2023
2097a56
Provide some margin to static buffers when growing
hecrj Feb 9, 2023
17a4d81
Collapse conditional and please `clippy`
hecrj Feb 9, 2023
51844c5
Trim `Cache` every 300 frames in `text::Pipeline`
hecrj Feb 10, 2023
26e902f
Compute grapheme index in `find_cursor_position` for `TextInput`
hecrj Feb 10, 2023
a059747
Remove `iced_glutin` and `iced_glow` leftovers
hecrj Feb 10, 2023
b2c87cd
Make `iced_wgpu` a mandatory dependency
hecrj Feb 10, 2023
700262e
Fix `checkbox` example
hecrj Feb 24, 2023
8059c40
Fix `clippy` lints
hecrj Feb 24, 2023
368cadd
Merge pull request #1697 from iced-rs/text-glyphon
hecrj Feb 24, 2023
5100b5d
Introduce `iced_renderer` subcrate featuring runtime renderer fallback
hecrj Feb 24, 2023
27e21a8
Merge branch 'update/svg-deps' into feature/software-renderer
hecrj Feb 25, 2023
a01bc86
Trim measurements in `renderer::Backend`
hecrj Feb 25, 2023
8c373cd
Scaffold `iced_tiny_skia` and connect it to `iced_renderer`
hecrj Feb 25, 2023
535d7a4
Implement basic presentation with `softbuffer` for `iced_tiny_skia`
hecrj Feb 25, 2023
445b31c
Resize `Surface::buffer` instead of reallocating in `iced_tiny_skia`
hecrj Feb 25, 2023
df5d664
Draft support for `Quad` and `Clip` primitives in `iced_tiny_skia`
hecrj Feb 25, 2023
744f302
Use `Surface::buffer` directly for drawing in `iced_tiny_skia`
hecrj Feb 25, 2023
64fb722
Draft text support in `iced_tiny_skia`
hecrj Feb 26, 2023
3386402
Implement text alignment support in `iced_tiny_skia`
hecrj Feb 26, 2023
4067c42
Fix glyphs with color mask in `iced_tiny_skia`
hecrj Feb 26, 2023
53573cf
Draw debug overlay in `iced_tiny_skia`
hecrj Feb 26, 2023
fbb14bf
Implement `border_radius` support for quads in `iced_tiny_skia`
hecrj Feb 26, 2023
4e615a6
Fix `clippy` lints
hecrj Feb 27, 2023
37ce30f
Use `kurbo` to approximate arcs in `iced_tiny_skia`
hecrj Feb 27, 2023
8750d83
Short-circuit rectangle path building in `iced_tiny_skia`
hecrj Feb 27, 2023
3105ad2
Remove useless `f32` conversion in `iced_tiny_skia`
hecrj Feb 27, 2023
11b2c3b
Reuse text buffers independently of color in `iced_wgpu`
hecrj Feb 27, 2023
c1ff803
Implement basic glyph cache in `iced_tiny_skia`
hecrj Feb 27, 2023
151daf9
Remove unnecessary `cast_slice` in `iced_tiny_skia`
hecrj Feb 27, 2023
fd06de5
Use `get_image_uncached` in `iced_tiny_skia`
hecrj Feb 28, 2023
3f6e28f
Use `iced_renderer` instead of `iced_graphics` in root crate
hecrj Feb 28, 2023
5fd5d1c
Implement `Canvas` support for `iced_tiny_skia`
hecrj Mar 1, 2023
5c0427e
Fix `Clip` primitive translation in `iced_tiny_skia`
hecrj Mar 1, 2023
838fd96
Disable `anti_alias` for `Frame::fill_rectangle` in `iced_tiny_skia`
hecrj Mar 1, 2023
119cf2e
Remove magic boolean in `into_paint`
hecrj Mar 1, 2023
350427e
Fix missing `qr_code` module in `iced_native`
hecrj Mar 1, 2023
868f79d
Reuse `ClipMask` in `iced_tiny_skia`
hecrj Mar 1, 2023
bbeaf10
Mark `Primitive` as `non-exhaustive` in `iced_graphics`
hecrj Mar 3, 2023
d13d19b
Rename `canvas::frame` to `canvas` in `iced_wgpu`
hecrj Mar 3, 2023
6cc48b5
Move `Canvas` and `QRCode` to `iced` crate
hecrj Mar 3, 2023
c54409d
Remove `canvas` leftovers in `iced_native`
hecrj Mar 3, 2023
3a0d34c
Create `iced_widget` subcrate and re-organize the whole codebase
hecrj Mar 4, 2023
bacbaee
Merge branch 'advanced-text' into feature/software-renderer
hecrj Mar 4, 2023
5fed065
Update `glyphon` in `iced_wgpu`
hecrj Mar 4, 2023
f4cf488
Remove generic `Hasher` and `Event` from `subscription::Recipe`
hecrj Mar 5, 2023
cfb8abb
Use `no_run` for widget doc-tests
hecrj Mar 5, 2023
43414bb
Fix `wasm-bindgen` backend in `iced_futures`
hecrj Mar 5, 2023
8af69be
Converge `Command` types from `iced_futures` and `iced_native`
hecrj Mar 5, 2023
99e0a71
Rename `iced_native` to `iced_runtime`
hecrj Mar 5, 2023
1c36446
Fix `README` of `iced_runtime`
hecrj Mar 5, 2023
06bbcc3
Move `webgl` feature selection for `wgpu` into `iced_wgpu`
hecrj Mar 5, 2023
9b4bcd2
Introduce backend feature flags in `iced_renderer`
hecrj Mar 6, 2023
3a26baa
Remove `image` abstractions in `iced_graphics`
hecrj Mar 7, 2023
bb49e17
Implement `raster` pipeline in `iced_tiny_skia`
hecrj Mar 7, 2023
5b3977d
Implement `vector` pipeline in `iced_tiny_skia`
hecrj Mar 7, 2023
a8d55ce
Trim `raster` cache in `iced_tiny_skia`
hecrj Mar 7, 2023
81d154d
Use default features in `svg` example
hecrj Mar 7, 2023
0850f52
Use `ceil` to avoid cut text in `iced_tiny_skia`
hecrj Mar 7, 2023
24c3d20
Tell `clippy` to go learn the borrow rules
hecrj Mar 7, 2023
d3900e0
Enable renderer backends in `integration` example
hecrj Mar 7, 2023
aa4b5bb
Merge branch 'master' into feature/software-renderer
hecrj Mar 7, 2023
424ac81
Implement color filter support for `Primitive::Svg` in `iced_tiny_skia`
hecrj Mar 9, 2023
caf2836
Merge pull request #1748 from iced-rs/feature/software-renderer
hecrj Mar 9, 2023
c8f637f
Fix panic rendering an out of bounds clip in `iced_tiny_skia`
hecrj Mar 17, 2023
ea50ec8
Trim text `Buffer` cache every frame in `iced_wgpu` and `iced_tiny_skia`
hecrj Mar 17, 2023
d1dc62e
Merge branch 'master' into advanced-text
hecrj Mar 17, 2023
5f9e7f6
Update `cosmic-text` to latest :tada:
hecrj Mar 19, 2023
2e23686
Export `iced_core::mouse` in `advanced` module
hecrj Mar 28, 2023
6d90f76
Export `iced_graphics` in `advanced` module (for now)
hecrj Mar 28, 2023
703ef71
Export `Pixels` in root crate
hecrj Mar 28, 2023
472fbdf
Export `Hasher` in `advanced` module
hecrj Mar 29, 2023
707de9d
Introduce support for `Font` attributes
hecrj Mar 29, 2023
0b459c8
Introduce `font::Stretch`
hecrj Mar 30, 2023
04c0ba0
Warn about invalid paths in `iced_tiny_skia` instead of panicking
hecrj Apr 3, 2023
6fae8bf
Implement `Frame::clip` for `iced_tiny_skia`
hecrj Apr 3, 2023
0f7abff
Draft (very) basic incremental rendering for `iced_tiny_skia`
hecrj Mar 21, 2023
6270c33
Keep playing with incremental rendering (still very slow)
hecrj Apr 4, 2023
f8cd1fa
Group damage regions by area increase
hecrj Apr 5, 2023
4cae262
Implement `PartialEq` and `Eq` for `image::Bytes`
hecrj Apr 5, 2023
1bba9a0
Fix `Svg` and `Image` primitives in `iced_tiny_skia`
hecrj Apr 5, 2023
4ede482
Present new frame only when damaged in `iced_tiny_skia`
hecrj Apr 5, 2023
e134a82
Switch debug mode to fade old primitives and display damage in `iced_…
hecrj Apr 5, 2023
92d61e5
Use `softbuffer` fork with owned pixel buffer
hecrj Apr 5, 2023
940a47e
Revert "Use `softbuffer` fork with owned pixel buffer"
hecrj Apr 5, 2023
c0431ae
Update `wgpu` and `cosmic-text`
hecrj Apr 8, 2023
3ee3673
Merge branch 'advanced-text' into incremental-rendering
hecrj Apr 8, 2023
16e6efe
Use `pixels` for presentation in `iced_tiny_skia` when possible
hecrj Apr 8, 2023
1872f7f
Use `*_from_env` helpers from `wgpu` in `iced_wgpu`
hecrj Apr 8, 2023
42b2e9b
Support `ICED_BACKEND` environment variable
hecrj Apr 8, 2023
c2249d2
Fix copy-pasted panic description in `iced_renderer`
hecrj Apr 8, 2023
ba07abe
Expand bounds of `Text` primitives a bit further
hecrj Apr 8, 2023
d206b82
Update `glyphon`
hecrj Apr 8, 2023
4bae457
Merge branch 'master' into advanced-text
hecrj Apr 17, 2023
e373010
Update `glyphon` to latest `dev`
hecrj Apr 17, 2023
619ba92
Merge branch 'advanced-text' into incremental-rendering
hecrj Apr 17, 2023
435b54e
Revert "Use `pixels` for presentation in `iced_tiny_skia` when possible"
hecrj Apr 26, 2023
d6345ff
Remove `dbg!` statement leftover
hecrj Apr 26, 2023
f0fa5f7
Remove `debug` overlay from `iced_tiny_skia` for now
hecrj Apr 26, 2023
e63cc18
Fix `Candidate::build` in `compositor` of `iced_renderer`
hecrj Apr 26, 2023
9c63eb7
Update `tiny-skia` and `resvg`
hecrj Apr 26, 2023
d953d12
Fix incorrect `wgpu` version for Wasm builds in `iced_wgpu`
hecrj Apr 26, 2023
af0303f
Move damage tracking logic to `compositor` in `iced_tiny_skia`
hecrj Apr 27, 2023
92d808e
Fix double reference in `compositor` in `iced_tiny_skia`
hecrj Apr 27, 2023
88d3247
Fix build of `integration` example for Wasm target
hecrj Apr 27, 2023
200a29c
Fix unused import in `triangle` pipeline for Wasm target in `iced_wgpu`
hecrj Apr 27, 2023
38f82ab
Expand damage regions of `Clip` primitives a bit
hecrj Apr 27, 2023
eb1b2bf
Invalidate `last_primitives` on resize in `iced_tiny_skia`
hecrj Apr 27, 2023
a755472
Remove unnecessary `last_` prefix in `Surface` of `iced_tiny_skia`
hecrj Apr 27, 2023
c31ab8e
Merge pull request #1811 from iced-rs/incremental-rendering
hecrj Apr 27, 2023
47016a3
Do not require `Copy` for text `StyleSheet::Style`
ids1024 Apr 27, 2023
57a276e
Merge pull request #1814 from ids1024/advanced-text
hecrj Apr 28, 2023
33b5a90
Make basic text shaping the default shaping strategy
hecrj Apr 18, 2023
4bd290a
Introduce `text::Shaping` enum and replace magic boolean
hecrj Apr 19, 2023
edf3432
Update `glyphon` and `cosmic-text`
hecrj May 1, 2023
2d7d9a1
Merge pull request #1822 from iced-rs/basic-shaping
hecrj May 2, 2023
8e8808f
Merge branch 'master' into advanced-text
hecrj May 2, 2023
9499a8f
Support configurable `LineHeight` in text widgets
hecrj May 4, 2023
7ae549a
Merge pull request #1828 from iced-rs/feature/line-height
hecrj May 5, 2023
c189ef6
Use `LineHeight::default` in `iced_wgpu::layer`
hecrj May 8, 2023
2bc4880
Warn about unsupported primitives in `iced_tiny_skia`
hecrj May 8, 2023
91ef07e
Warn about unsupported primitives in `iced_wgpu`
hecrj May 8, 2023
b8c2cca
Merge branch 'master' into advanced-text
hecrj May 8, 2023
16bf8fc
Export `Shaping` and `LineHeight` in `widget::text`
hecrj May 8, 2023
180cb07
Add `line_height` to `checkbox::Icon`
hecrj May 8, 2023
c6d9221
Round paragraph position until we implement subpixel glyph positioning
hecrj May 8, 2023
9a8b30d
Clip text that exceeds section bounds in `iced_wgpu`
hecrj May 8, 2023
3f1c8a8
fix: tiny-skia svg premultiply final filtered color
wash2 May 9, 2023
75439ff
fix: border radius typo
wash2 May 9, 2023
f0c8737
Add `line_height` to `pick_list::Icon`
hecrj May 9, 2023
f75b8bd
Increase default `LineHeight` to `Relative(1.3)`
hecrj May 9, 2023
1400b51
Fix bounds of `PickList` text label
hecrj May 9, 2023
22e82dd
Merge pull request #1842 from wash2/fix-typo
hecrj May 9, 2023
422b4de
Merge pull request #1841 from wash2/fix-svg-color-filter
hecrj May 9, 2023
dd04c0b
Bundle `tiny-skia` backend together with `iced_renderer`
hecrj May 10, 2023
8622e99
Write missing documentation in `iced_graphics`
hecrj May 11, 2023
de638f4
Write missing documentation in `iced_wgpu`
hecrj May 11, 2023
b601948
Write missing documentation in `iced_widget`
hecrj May 11, 2023
63d3fc6
Remove OpenGL mentions in `README`s
hecrj May 11, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
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
53 changes: 20 additions & 33 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ keywords = ["gui", "ui", "graphics", "interface", "widgets"]
categories = ["gui"]

[features]
default = ["wgpu"]
default = ["wgpu", "tiny-skia"]
# Enable the `wgpu` GPU-accelerated renderer backend
wgpu = ["iced_renderer/wgpu"]
# Enable the `tiny-skia` software renderer backend
tiny-skia = ["iced_renderer/tiny-skia"]
# 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 +39,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 +50,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
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
111 changes: 97 additions & 14 deletions core/src/font.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,102 @@
//! Load and use fonts.
use std::hash::Hash;

/// A font.
#[derive(Debug, Clone, Copy, Default)]
pub enum Font {
/// The default font.
///
/// This is normally a font configured in a renderer or loaded from the
/// system.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub struct Font {
/// The [`Family`] of the [`Font`].
pub family: Family,
/// The [`Weight`] of the [`Font`].
pub weight: Weight,
/// The [`Stretch`] of the [`Font`].
pub stretch: Stretch,
/// Whether if the [`Font`] is monospaced or not.
pub monospaced: bool,
}

impl Font {
/// A non-monospaced sans-serif font with normal [`Weight`].
pub const DEFAULT: Font = Font {
family: Family::SansSerif,
weight: Weight::Normal,
stretch: Stretch::Normal,
monospaced: false,
};

/// A monospaced font with normal [`Weight`].
pub const MONOSPACE: Font = Font {
family: Family::Monospace,
monospaced: true,
..Self::DEFAULT
};

/// Creates a non-monospaced [`Font`] with the given [`Family::Name`] and
/// normal [`Weight`].
pub const fn with_name(name: &'static str) -> Self {
Font {
family: Family::Name(name),
..Self::DEFAULT
}
}
}

/// A font family.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub enum Family {
/// The name of a font family of choice.
Name(&'static str),

/// Serif fonts represent the formal text style for a script.
Serif,

/// Glyphs in sans-serif fonts, as the term is used in CSS, are generally low
/// contrast and have stroke endings that are plain — without any flaring,
/// cross stroke, or other ornamentation.
#[default]
Default,
SansSerif,

/// Glyphs in cursive fonts generally use a more informal script style, and
/// the result looks more like handwritten pen or brush writing than printed
/// letterwork.
Cursive,

/// Fantasy fonts are primarily decorative or expressive fonts that contain
/// decorative or expressive representations of characters.
Fantasy,

/// The sole criterion of a monospace font is that all glyphs have the same
/// fixed width.
Monospace,
}

/// An external font.
External {
/// The name of the external font
name: &'static str,
/// The weight of some text.
#[allow(missing_docs)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub enum Weight {
Thin,
ExtraLight,
Light,
#[default]
Normal,
Medium,
Semibold,
Bold,
ExtraBold,
Black,
}

/// The bytes of the external font
bytes: &'static [u8],
},
/// The width of some text.
#[allow(missing_docs)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub enum Stretch {
UltraCondensed,
ExtraCondensed,
Condensed,
SemiCondensed,
#[default]
Normal,
SemiExpanded,
Expanded,
ExtraExpanded,
UltraExpanded,
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 10 additions & 2 deletions native/src/image.rs → core/src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::path::PathBuf;
use std::sync::Arc;

/// A handle of some image data.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Handle {
id: u64,
data: Data,
Expand Down Expand Up @@ -110,6 +110,14 @@ impl std::hash::Hash for Bytes {
}
}

impl PartialEq for Bytes {
fn eq(&self, other: &Self) -> bool {
self.as_ref() == other.as_ref()
}
}

impl Eq for Bytes {}

impl AsRef<[u8]> for Bytes {
fn as_ref(&self) -> &[u8] {
self.0.as_ref().as_ref()
Expand All @@ -125,7 +133,7 @@ impl std::ops::Deref for Bytes {
}

/// The data of a raster image.
#[derive(Clone, Hash)]
#[derive(Clone, PartialEq, Eq, Hash)]
pub enum Data {
/// File data
Path(PathBuf),
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading