From dc18fca47a312f7e7e5857a3ef48b414aaed6199 Mon Sep 17 00:00:00 2001 From: genusistimelord Date: Wed, 30 Aug 2023 16:43:20 -0400 Subject: [PATCH] Release 0.7.0, Removed IconText --- CHANGELOG.md | 5 + Cargo.toml | 2 +- README.md | 4 +- src/lib.rs | 4 - src/native/helpers.rs | 12 -- src/native/icon_text.rs | 205 ----------------------------- src/native/mod.rs | 6 - src/native/overlay/color_picker.rs | 2 - src/native/overlay/date_picker.rs | 44 +++++-- src/native/overlay/time_picker.rs | 40 ++++-- 10 files changed, 71 insertions(+), 253 deletions(-) delete mode 100644 src/native/icon_text.rs diff --git a/CHANGELOG.md b/CHANGELOG.md index 02c3fb24..db5dd5c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.7.0] - 2023-08-30 + ### Added - DynamicHeight to menu bar @latidoremi . - [Breaking] Custom Style Options for all widgets. @@ -14,10 +16,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Changed current width to content_width for `NumberInput`. +- (Breaking) Removed `Icon_text`, Use `Iced::widget::Text` instead. ### Fixed - TabBars hieght issue within container. - number input buttons not rendering correctly when they are oversized. +- Fixed SFUIRounded family name to be correct. +- number input scrolling to be normal scrolling instead of inversed scrolling @Redhawk18. ## [0.6.0] - 2023-07-28 diff --git a/Cargo.toml b/Cargo.toml index d4d3a021..fb4158ab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "iced_aw" -version = "0.6.0" +version = "0.7.0" authors = ["Kaiden42 ", "Andrew Wheeler "] edition = "2021" description = "Additional widgets for the Iced GUI library" diff --git a/README.md b/README.md index 8eaa2def..12e14ec7 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Include `iced_aw` as a dependency in your `Cargo.toml`: ```toml [dependencies] iced = "0.10.0" -iced_aw = { version = "0.6.0", default-features = false, features = [...] } +iced_aw = { version = "0.7.0", default-features = false, features = [...] } ``` ## Versioning @@ -23,7 +23,7 @@ iced_aw = { version = "0.6.0", default-features = false, features = [...] } | -------------- | ----------------- | | 0.8 | 0.4 | | 0.9 | 0.5 | -| 0.10 | 0.6 | +| 0.10 | 0.6, 0.7 | ## Widgets diff --git a/src/lib.rs b/src/lib.rs index 15615730..746153d3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -62,10 +62,6 @@ mod platform { #[cfg(feature = "icons")] pub use {crate::graphics::icons::Icon, crate::graphics::icons::ICON_FONT}; - #[doc(no_inline)] - #[cfg(feature = "icon_text")] - pub use {crate::native::icon_text, crate::native::icon_text::IconText}; - #[doc(no_inline)] #[cfg(feature = "badge")] pub use {crate::native::badge, crate::style::BadgeStyles, badge::Badge}; diff --git a/src/native/helpers.rs b/src/native/helpers.rs index c8bbbdd4..a9598e15 100644 --- a/src/native/helpers.rs +++ b/src/native/helpers.rs @@ -238,18 +238,6 @@ where crate::Wrap::with_elements_vertical(children) } -#[cfg(feature = "icon_text")] -/// Shortcut helper to create an [`IconText`] Widget. -/// -/// [`IconText`]: crate::IconText -#[must_use] -pub fn icon_text(label: impl Into) -> crate::IconText -where - Renderer: core::text::Renderer, -{ - crate::IconText::new(label) -} - #[cfg(feature = "modal")] /// Shortcut helper to create a [`Modal`] Widget. /// diff --git a/src/native/icon_text.rs b/src/native/icon_text.rs deleted file mode 100644 index ae4f1c65..00000000 --- a/src/native/icon_text.rs +++ /dev/null @@ -1,205 +0,0 @@ -//! Text widget for rendering icons. -//! -//! Nearly a complete copy of the `iced_widget::Text` widget, but with the -//! icons font as a default font. Maybe I'll find a better way in the future. -//! -//! //! *This API requires the following crate features to be activated: `icon_text`* -use iced_widget::{ - core::{ - self, - alignment::{Horizontal, Vertical}, - layout::{Limits, Node}, - mouse::Cursor, - renderer, - widget::Tree, - Color, Element, Layout, Length, Rectangle, Widget, - }, - text::LineHeight, -}; - -use crate::graphics::icons::ICON_FONT; -/// Text widget with icon font. -#[allow(missing_debug_implementations)] -pub struct IconText = crate::Renderer> { - /// The content of the [`IconText`](IconText). - content: String, - /// The optional size of the [`IconText`](IconText). - size: Option, - /// The optional color of the [`IconText`](IconText). - color: Option, - /// The optional font of the [`IconText`](IconText). - font: Option, - /// The width of the [`IconText`](IconText). - width: Length, - /// The height of the [`IconText`](IconText). - height: Length, - /// The horizontal alignment of the [`IconText`](IconText). - horizontal_alignment: Horizontal, - /// The vertical alignment of the [`IconText`](IconText). - vertical_alignment: Vertical, -} - -impl> IconText { - /// Creates a new [`IconText`](IconText) with the given icon label. - /// - /// It expects: - /// * the label to be displayed as an icon on the [`IconText`](IconText). - pub fn new>(label: T) -> Self { - Self { - content: label.into(), - size: None, - color: None, - font: None, - width: Length::Shrink, - height: Length::Shrink, - horizontal_alignment: Horizontal::Center, - vertical_alignment: Vertical::Center, - } - } - - /// Sets the size of the [`IconText`](IconText). - #[must_use] - pub fn size(mut self, size: f32) -> Self { - self.size = Some(size); - self - } - - /// Sets the [`Color`](core::Color) of the [`IconText`](IconText). - #[must_use] - pub fn color>(mut self, color: C) -> Self { - self.color = Some(color.into()); - self - } - - /// Sets the [`Font`](core::Font) of the [`IconText`](IconText). - #[must_use] - pub fn font(mut self, font: impl Into) -> Self { - self.font = Some(font.into()); - self - } - - /// Sets the width of the [`IconText`](IconText) boundaries. - #[must_use] - pub fn width(mut self, width: Length) -> Self { - self.width = width; - self - } - - /// Sets the height of the [`IconText`](IconText) boundaries. - #[must_use] - pub fn height(mut self, height: Length) -> Self { - self.height = height; - self - } - - /// Sets the [`Horizontal `](core::alignment::Horizontal ) - /// of the [`IconText`](IconText). - #[must_use] - pub fn horizontal_alignment(mut self, alignment: Horizontal) -> Self { - self.horizontal_alignment = alignment; - self - } - - /// Sets the [`Vertical `](core::alignment::Vertical ) - /// of the [`IconText`](IconText). - #[must_use] - pub fn vertical_alignment(mut self, alignment: Vertical) -> Self { - self.vertical_alignment = alignment; - self - } -} - -impl Widget for IconText -where - Renderer: core::Renderer + core::text::Renderer, -{ - fn width(&self) -> Length { - self.width - } - - fn height(&self) -> Length { - self.height - } - - fn layout(&self, renderer: &Renderer, limits: &Limits) -> Node { - let limits = limits.width(self.width).height(self.height); - - let size = self.size.unwrap_or_else(|| renderer.default_size()); - - let bounds = limits.max(); - - let size = renderer.measure( - &self.content, - size, - LineHeight::Relative(1.3), - self.font.unwrap_or_default(), - bounds, - iced_widget::text::Shaping::Advanced, - ); - - let size = limits.resolve(size); - - Node::new(size) - } - - fn draw( - &self, - _state: &Tree, - renderer: &mut Renderer, - _theme: &Renderer::Theme, - style: &renderer::Style, - layout: Layout<'_>, - _cursor: Cursor, - _viewport: &Rectangle, - ) { - let bounds = layout.bounds(); - - let x = match self.horizontal_alignment { - Horizontal::Left => bounds.x, - Horizontal::Center => bounds.center_x(), - Horizontal::Right => bounds.x + bounds.width, - }; - - let y = match self.vertical_alignment { - Vertical::Top => bounds.y, - Vertical::Center => bounds.center_y(), - Vertical::Bottom => bounds.y + bounds.height, - }; - - renderer.fill_text(core::text::Text { - content: &self.content, - bounds: Rectangle { x, y, ..bounds }, - size: self.size.unwrap_or_else(|| renderer.default_size()), - color: self.color.unwrap_or(style.text_color), - font: self.font.unwrap_or(ICON_FONT), - horizontal_alignment: self.horizontal_alignment, - vertical_alignment: self.vertical_alignment, - line_height: LineHeight::Relative(1.3), - shaping: iced_widget::text::Shaping::Advanced, - }); - } -} - -impl<'a, Message, Renderer> From> for Element<'a, Message, Renderer> -where - Renderer: core::Renderer + core::text::Renderer + 'a, -{ - fn from(icon: IconText) -> Element<'a, Message, Renderer> { - Element::new(icon) - } -} - -impl> Clone for IconText { - fn clone(&self) -> Self { - Self { - content: self.content.clone(), - size: self.size, - color: self.color, - font: self.font, - width: self.width, - height: self.height, - horizontal_alignment: self.horizontal_alignment, - vertical_alignment: self.vertical_alignment, - } - } -} diff --git a/src/native/mod.rs b/src/native/mod.rs index 6d71462b..32455200 100644 --- a/src/native/mod.rs +++ b/src/native/mod.rs @@ -64,12 +64,6 @@ pub type Grid<'a, Message, Renderer> = grid::Grid<'a, Message, Renderer>; #[cfg(feature = "grid")] pub use grid::Strategy; -#[cfg(feature = "icon_text")] -pub mod icon_text; -#[cfg(feature = "icon_text")] -/// Text widget with icon font. -pub type IconText = crate::native::icon_text::IconText; - #[cfg(feature = "modal")] pub mod modal; #[cfg(feature = "modal")] diff --git a/src/native/overlay/color_picker.rs b/src/native/overlay/color_picker.rs index 15e5e9d6..ea59f51b 100644 --- a/src/native/overlay/color_picker.rs +++ b/src/native/overlay/color_picker.rs @@ -30,7 +30,6 @@ use crate::{ overlay::Position, }, graphics::icons::{icon_to_char, Icon}, - //native::IconText, style::{ color_picker::{Appearance, StyleSheet}, style_state::StyleState, @@ -101,7 +100,6 @@ where ) .width(Length::Fill) .on_press(on_cancel.clone()), - //IconText submit_button: Button::new( iced_widget::Text::new(icon_to_char(Icon::Check).to_string()) .horizontal_alignment(alignment::Horizontal::Center) diff --git a/src/native/overlay/date_picker.rs b/src/native/overlay/date_picker.rs index c46125ea..3e82d5aa 100644 --- a/src/native/overlay/date_picker.rs +++ b/src/native/overlay/date_picker.rs @@ -1,10 +1,8 @@ //! Use a date picker as an input element for picking dates. //! //! *This API requires the following crate features to be activated: `date_picker`* -use std::collections::HashMap; use chrono::{Datelike, Local, NaiveDate}; - use iced_widget::{ button, container, core::{ @@ -23,6 +21,7 @@ use iced_widget::{ renderer::Renderer, text, Button, Column, Container, Row, Text, }; +use std::collections::HashMap; use crate::{ core::{ @@ -30,8 +29,7 @@ use crate::{ overlay::Position, }, date_picker, - graphics::icons::{Icon, ICON_FONT}, - native::IconText, + graphics::icons::{icon_to_char, Icon, ICON_FONT}, style::style_state::StyleState, }; @@ -89,12 +87,22 @@ where DatePickerOverlay { state: overlay_state, - cancel_button: Button::new(IconText::new(Icon::X).width(Length::Fill)) - .width(Length::Fill) - .on_press(on_cancel.clone()), - submit_button: Button::new(IconText::new(Icon::Check).width(Length::Fill)) - .width(Length::Fill) - .on_press(on_cancel), // Sending a fake message + cancel_button: Button::new( + text::Text::new(icon_to_char(Icon::X).to_string()) + .font(ICON_FONT) + .horizontal_alignment(Horizontal::Center) + .width(Length::Fill), + ) + .width(Length::Fill) + .on_press(on_cancel.clone()), + submit_button: Button::new( + text::Text::new(icon_to_char(Icon::Check).to_string()) + .font(ICON_FONT) + .horizontal_alignment(Horizontal::Center) + .width(Length::Fill), + ) + .width(Length::Fill) + .on_press(on_cancel), // Sending a fake message on_submit, position, style, @@ -909,8 +917,20 @@ where { fn default() -> Self { Self { - cancel_button: Button::new(IconText::new(Icon::X)).into(), - submit_button: Button::new(IconText::new(Icon::Check)).into(), + cancel_button: Button::new( + text::Text::new(icon_to_char(Icon::X).to_string()) + .font(ICON_FONT) + .horizontal_alignment(Horizontal::Center) + .width(Length::Fill), + ) + .into(), + submit_button: Button::new( + text::Text::new(icon_to_char(Icon::Check).to_string()) + .font(ICON_FONT) + .horizontal_alignment(Horizontal::Center) + .width(Length::Fill), + ) + .into(), } } } diff --git a/src/native/overlay/time_picker.rs b/src/native/overlay/time_picker.rs index 964a5895..10a7070a 100644 --- a/src/native/overlay/time_picker.rs +++ b/src/native/overlay/time_picker.rs @@ -3,6 +3,7 @@ //! *This API requires the following crate features to be activated: `time_picker`* use std::collections::HashMap; +use crate::graphics::icons::{icon_to_char, ICON_FONT}; use crate::time_picker::{self, Time}; use crate::{ core::clock::{ @@ -11,7 +12,6 @@ use crate::{ SECOND_RADIUS_PERCENTAGE, }, core::{clock, overlay::Position, time::Period}, - native::IconText, style::style_state::StyleState, Icon, }; @@ -94,12 +94,22 @@ where TimePickerOverlay { state: overlay_state, - cancel_button: Button::new(IconText::new(Icon::X).width(Length::Fill)) - .width(Length::Fill) - .on_press(on_cancel.clone()), - submit_button: Button::new(IconText::new(Icon::Check).width(Length::Fill)) - .width(Length::Fill) - .on_press(on_cancel), // Sending a fake message + cancel_button: Button::new( + text::Text::new(icon_to_char(Icon::X).to_string()) + .font(ICON_FONT) + .horizontal_alignment(Horizontal::Center) + .width(Length::Fill), + ) + .width(Length::Fill) + .on_press(on_cancel.clone()), + submit_button: Button::new( + text::Text::new(icon_to_char(Icon::Check).to_string()) + .font(ICON_FONT) + .horizontal_alignment(Horizontal::Center) + .width(Length::Fill), + ) + .width(Length::Fill) + .on_press(on_cancel), // Sending a fake message on_submit, position, style, @@ -1656,8 +1666,20 @@ where { fn default() -> Self { Self { - cancel_button: Button::new(IconText::new(Icon::X)).into(), - submit_button: Button::new(IconText::new(Icon::Check)).into(), + cancel_button: Button::new( + text::Text::new(icon_to_char(Icon::X).to_string()) + .font(ICON_FONT) + .horizontal_alignment(Horizontal::Center) + .width(Length::Fill), + ) + .into(), + submit_button: Button::new( + text::Text::new(icon_to_char(Icon::Check).to_string()) + .font(ICON_FONT) + .horizontal_alignment(Horizontal::Center) + .width(Length::Fill), + ) + .into(), } } }