Skip to content

Commit

Permalink
Merge branch 'master' into 0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
hecrj committed Feb 18, 2023
2 parents fbca18d + 0d16569 commit f1db675
Show file tree
Hide file tree
Showing 132 changed files with 2,186 additions and 850 deletions.
53 changes: 52 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,56 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.8.0] - 2023-02-18
### Added
- Generic pixel units. [#1711](https://github.com/iced-rs/iced/pull/1711)
- `custom` method to `widget::Operation` trait. [#1649](https://github.com/iced-rs/iced/pull/1649)
- `Group` overlay. [#1655](https://github.com/iced-rs/iced/pull/1655)
- Standalone `draw` helper for `image`. [#1682](https://github.com/iced-rs/iced/pull/1682)
- Dynamic `pick_list::Handle`. [#1675](https://github.com/iced-rs/iced/pull/1675)
- `Id` support for `Container`. [#1695](https://github.com/iced-rs/iced/pull/1695)
- Custom `Checkbox` icon support. [#1707](https://github.com/iced-rs/iced/pull/1707)
- `window` action to change always on top setting. [#1587](https://github.com/iced-rs/iced/pull/1587)
- `window` action to fetch its unique identifier. [#1589](https://github.com/iced-rs/iced/pull/1589)

### Changed
- Annotated `Command` and `Subscription` with `#[must_use]`. [#1676](https://github.com/iced-rs/iced/pull/1676)
- Replaced `Fn` with `FnOnce` in `canvas::Cache::draw`. [#1694](https://github.com/iced-rs/iced/pull/1694)
- Used `[default]` on enum in `game_of_life` example. [#1660](https://github.com/iced-rs/iced/pull/1660)
- Made `QRCode` hide when data is empty in `qr_code` example. [#1665](https://github.com/iced-rs/iced/pull/1665)
- Replaced `Cow` with `Bytes` in `image` to accept any kind of data that implements `AsRef<[u8]>`. [#1551](https://github.com/iced-rs/iced/pull/1551)

### Fixed
- Blank window on application startup. [#1698](https://github.com/iced-rs/iced/pull/1698)
- Off-by-one pixel error on `pick_list` width. [#1679](https://github.com/iced-rs/iced/pull/1679)
- Missing `text_input` implementation in `operation::Map`. [#1678](https://github.com/iced-rs/iced/pull/1678)
- Widget-driven animations for `Component`. [#1685](https://github.com/iced-rs/iced/pull/1685)
- Layout translation in `overlay::Group`. [#1686](https://github.com/iced-rs/iced/pull/1686)
- Missing `is_over` implementation for overlays of `iced_lazy` widgets. [#1699](https://github.com/iced-rs/iced/pull/1699)
- Panic when overlay event processing removes overlay. [#1700](https://github.com/iced-rs/iced/pull/1700)
- Panic when using operations with components in certain cases. [#1701](https://github.com/iced-rs/iced/pull/1701)
- `TextInput` width when using padding. [#1706](https://github.com/iced-rs/iced/pull/1706)
- `iced_glow` crash on some hardware. [#1703](https://github.com/iced-rs/iced/pull/1703)
- Height of `overlay::Menu`. [#1714](https://github.com/iced-rs/iced/pull/1714)
- Size of images in `README`. [#1659](https://github.com/iced-rs/iced/pull/1659)
- New `clippy` lints. [#1681](https://github.com/iced-rs/iced/pull/1681)

Many thanks to...

- @13r0ck
- @bungoboingo
- @casperstorm
- @frey
- @greatest-ape
- @ids1024
- @Jedsek
- @nicksenger
- @Night-Hunter-NF
- @sdroege
- @Sn-Kinos
- @sushigiri
- @tarkah

## [0.7.0] - 2023-01-14
### Added
- Widget-driven animations. [#1647](https://github.com/iced-rs/iced/pull/1647)
Expand Down Expand Up @@ -364,7 +414,8 @@ Many thanks to...
### Added
- First release! :tada:

[Unreleased]: https://github.com/iced-rs/iced/compare/0.7.0...HEAD
[Unreleased]: https://github.com/iced-rs/iced/compare/0.8.0...HEAD
[0.8.0]: https://github.com/iced-rs/iced/compare/0.7.0...0.8.0
[0.7.0]: https://github.com/iced-rs/iced/compare/0.6.0...0.7.0
[0.6.0]: https://github.com/iced-rs/iced/compare/0.5.0...0.6.0
[0.5.0]: https://github.com/iced-rs/iced/compare/0.4.2...0.5.0
Expand Down
20 changes: 10 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "iced"
version = "0.7.0"
version = "0.8.0"
authors = ["Héctor Ramón Jiménez <hector0193@gmail.com>"]
edition = "2021"
description = "A cross-platform GUI library inspired by Elm"
Expand Down Expand Up @@ -66,13 +66,13 @@ members = [
]

[dependencies]
iced_core = { version = "0.7", path = "core" }
iced_futures = { version = "0.5", path = "futures" }
iced_native = { version = "0.8", path = "native" }
iced_graphics = { version = "0.6", path = "graphics" }
iced_winit = { version = "0.7", path = "winit", features = ["application"] }
iced_glutin = { version = "0.6", path = "glutin", optional = true }
iced_glow = { version = "0.6", path = "glow", optional = true }
iced_core = { version = "0.8", path = "core" }
iced_futures = { version = "0.6", path = "futures" }
iced_native = { version = "0.9", path = "native" }
iced_graphics = { version = "0.7", path = "graphics" }
iced_winit = { version = "0.8", path = "winit", features = ["application"] }
iced_glutin = { version = "0.7", path = "glutin", optional = true }
iced_glow = { version = "0.7", path = "glow", optional = true }
thiserror = "1.0"

[dependencies.image_rs]
Expand All @@ -81,10 +81,10 @@ package = "image"
optional = true

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

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

[package.metadata.docs.rs]
rustdoc-args = ["--cfg", "docsrs"]
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ A cross-platform GUI library for Rust focused on simplicity and type-safety.
Inspired by [Elm].

<a href="https://gfycat.com/littlesanehalicore">
<img src="https://thumbs.gfycat.com/LittleSaneHalicore-small.gif" height="350px">
<img src="https://thumbs.gfycat.com/LittleSaneHalicore-small.gif" width="275px">
</a>
<a href="https://gfycat.com/politeadorableiberianmole">
<img src="https://thumbs.gfycat.com/PoliteAdorableIberianmole-small.gif" height="350px">
<img src="https://thumbs.gfycat.com/PoliteAdorableIberianmole-small.gif" width="273px">
</a>

</div>
Expand Down Expand Up @@ -68,7 +68,7 @@ __Iced is currently experimental software.__ [Take a look at the roadmap],
Add `iced` as a dependency in your `Cargo.toml`:

```toml
iced = "0.7"
iced = "0.8"
```

If your project is using a Rust edition older than 2021, then you will need to
Expand Down Expand Up @@ -215,7 +215,7 @@ cargo run --features iced/glow --package game_of_life
and then use it in your project with

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

__NOTE:__ Chances are you have hardware that supports at least OpenGL 2.1 or OpenGL ES 2.0,
Expand Down
2 changes: 1 addition & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "iced_core"
version = "0.7.0"
version = "0.8.0"
authors = ["Héctor Ramón Jiménez <hector0193@gmail.com>"]
edition = "2021"
description = "The essential concepts of Iced"
Expand Down
2 changes: 1 addition & 1 deletion core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ This crate is meant to be a starting point for an Iced runtime.
Add `iced_core` as a dependency in your `Cargo.toml`:

```toml
iced_core = "0.7"
iced_core = "0.8"
```

__Iced moves fast and the `master` branch can contain breaking changes!__ If
Expand Down
14 changes: 10 additions & 4 deletions core/src/length.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// The strategy used to fill space in a specific dimension.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum Length {
/// Fill all the remaining space
Fill,
Expand All @@ -17,7 +17,7 @@ pub enum Length {
Shrink,

/// Fill a fixed amount of space
Units(u16),
Fixed(f32),
}

impl Length {
Expand All @@ -31,13 +31,19 @@ impl Length {
Length::Fill => 1,
Length::FillPortion(factor) => *factor,
Length::Shrink => 0,
Length::Units(_) => 0,
Length::Fixed(_) => 0,
}
}
}

impl From<f32> for Length {
fn from(amount: f32) -> Self {
Length::Fixed(amount)
}
}

impl From<u16> for Length {
fn from(units: u16) -> Self {
Length::Units(units)
Length::Fixed(f32::from(units))
}
}
4 changes: 3 additions & 1 deletion core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//! ![The foundations of the Iced ecosystem](https://github.com/iced-rs/iced/blob/0525d76ff94e828b7b21634fa94a747022001c83/docs/graphs/foundations.png?raw=true)
//!
//! [Iced]: https://github.com/iced-rs/iced
//! [`iced_native`]: https://github.com/iced-rs/iced/tree/0.7/native
//! [`iced_native`]: https://github.com/iced-rs/iced/tree/0.8/native
//! [`iced_web`]: https://github.com/iced-rs/iced_web
#![doc(
html_logo_url = "https://raw.githubusercontent.com/iced-rs/iced/9ab6923e943f784985e9ef9ca28b10278297225d/docs/logo.svg"
Expand Down Expand Up @@ -35,6 +35,7 @@ mod content_fit;
mod font;
mod length;
mod padding;
mod pixels;
mod point;
mod rectangle;
mod size;
Expand All @@ -47,6 +48,7 @@ pub use content_fit::ContentFit;
pub use font::Font;
pub use length::Length;
pub use padding::Padding;
pub use pixels::Pixels;
pub use point::Point;
pub use rectangle::Rectangle;
pub use size::Size;
Expand Down
73 changes: 53 additions & 20 deletions core/src/padding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,29 @@ use crate::Size;
/// let widget = Widget::new().padding([10, 20]); // top/bottom, left/right
/// let widget = Widget::new().padding([5, 10, 15, 20]); // top, right, bottom, left
/// ```
#[derive(Debug, Hash, Copy, Clone)]
#[derive(Debug, Copy, Clone)]
pub struct Padding {
/// Top padding
pub top: u16,
pub top: f32,
/// Right padding
pub right: u16,
pub right: f32,
/// Bottom padding
pub bottom: u16,
pub bottom: f32,
/// Left padding
pub left: u16,
pub left: f32,
}

impl Padding {
/// Padding of zero
pub const ZERO: Padding = Padding {
top: 0,
right: 0,
bottom: 0,
left: 0,
top: 0.0,
right: 0.0,
bottom: 0.0,
left: 0.0,
};

/// Create a Padding that is equal on all sides
pub const fn new(padding: u16) -> Padding {
pub const fn new(padding: f32) -> Padding {
Padding {
top: padding,
right: padding,
Expand All @@ -65,12 +65,12 @@ impl Padding {
}

/// Returns the total amount of vertical [`Padding`].
pub fn vertical(self) -> u16 {
pub fn vertical(self) -> f32 {
self.top + self.bottom
}

/// Returns the total amount of horizontal [`Padding`].
pub fn horizontal(self) -> u16 {
pub fn horizontal(self) -> f32 {
self.left + self.right
}

Expand All @@ -79,16 +79,49 @@ impl Padding {
let available = (outer - inner).max(Size::ZERO);

Padding {
top: self.top.min((available.height as u16) / 2),
right: self.right.min((available.width as u16) / 2),
bottom: self.bottom.min((available.height as u16) / 2),
left: self.left.min((available.width as u16) / 2),
top: self.top.min(available.height / 2.0),
right: self.right.min(available.width / 2.0),
bottom: self.bottom.min(available.height / 2.0),
left: self.left.min(available.width / 2.0),
}
}
}

impl From<u16> for Padding {
fn from(p: u16) -> Self {
Padding {
top: f32::from(p),
right: f32::from(p),
bottom: f32::from(p),
left: f32::from(p),
}
}
}

impl From<[u16; 2]> for Padding {
fn from(p: [u16; 2]) -> Self {
Padding {
top: f32::from(p[0]),
right: f32::from(p[1]),
bottom: f32::from(p[0]),
left: f32::from(p[1]),
}
}
}

impl From<[u16; 4]> for Padding {
fn from(p: [u16; 4]) -> Self {
Padding {
top: f32::from(p[0]),
right: f32::from(p[1]),
bottom: f32::from(p[2]),
left: f32::from(p[3]),
}
}
}

impl From<f32> for Padding {
fn from(p: f32) -> Self {
Padding {
top: p,
right: p,
Expand All @@ -98,8 +131,8 @@ impl From<u16> for Padding {
}
}

impl From<[u16; 2]> for Padding {
fn from(p: [u16; 2]) -> Self {
impl From<[f32; 2]> for Padding {
fn from(p: [f32; 2]) -> Self {
Padding {
top: p[0],
right: p[1],
Expand All @@ -109,8 +142,8 @@ impl From<[u16; 2]> for Padding {
}
}

impl From<[u16; 4]> for Padding {
fn from(p: [u16; 4]) -> Self {
impl From<[f32; 4]> for Padding {
fn from(p: [f32; 4]) -> Self {
Padding {
top: p[0],
right: p[1],
Expand Down
22 changes: 22 additions & 0 deletions core/src/pixels.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/// An amount of logical pixels.
///
/// Normally used to represent an amount of space, or the size of something.
///
/// This type is normally asked as an argument in a generic way
/// (e.g. `impl Into<Pixels>`) and, since `Pixels` implements `From` both for
/// `f32` and `u16`, you should be able to provide both integers and float
/// literals as needed.
#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
pub struct Pixels(pub f32);

impl From<f32> for Pixels {
fn from(amount: f32) -> Self {
Self(amount)
}
}

impl From<u16> for Pixels {
fn from(amount: u16) -> Self {
Self(f32::from(amount))
}
}
4 changes: 2 additions & 2 deletions core/src/size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ impl Size {
/// Increments the [`Size`] to account for the given padding.
pub fn pad(&self, padding: Padding) -> Self {
Size {
width: self.width + padding.horizontal() as f32,
height: self.height + padding.vertical() as f32,
width: self.width + padding.horizontal(),
height: self.height + padding.vertical(),
}
}

Expand Down
5 changes: 5 additions & 0 deletions core/src/vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ impl<T> Vector<T> {
}
}

impl Vector {
/// The zero [`Vector`].
pub const ZERO: Self = Self::new(0.0, 0.0);
}

impl<T> std::ops::Add for Vector<T>
where
T: std::ops::Add<Output = T>,
Expand Down
Loading

0 comments on commit f1db675

Please sign in to comment.