diff --git a/Cargo.toml b/Cargo.toml index c62b5c9f..63ccb82e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -56,7 +56,6 @@ members = [ "examples/bezier_tool", "examples/clock", "examples/color_palette", - "examples/combo_box", "examples/counter", "examples/custom_widget", "examples/download_progress", @@ -65,6 +64,7 @@ members = [ "examples/geometry", "examples/integration", "examples/pane_grid", + "examples/pick_list", "examples/pokedex", "examples/progress_bar", "examples/solar_system", diff --git a/examples/combo_box/Cargo.toml b/examples/pick_list/Cargo.toml similarity index 66% rename from examples/combo_box/Cargo.toml rename to examples/pick_list/Cargo.toml index 7e1e4133..a87d7217 100644 --- a/examples/combo_box/Cargo.toml +++ b/examples/pick_list/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "combo_box" +name = "pick_list" version = "0.1.0" authors = ["Héctor Ramón Jiménez "] edition = "2018" @@ -7,5 +7,3 @@ publish = false [dependencies] iced = { path = "../..", features = ["debug"] } -iced_native = { path = "../../native" } -iced_wgpu = { path = "../../wgpu" } diff --git a/examples/combo_box/README.md b/examples/pick_list/README.md similarity index 100% rename from examples/combo_box/README.md rename to examples/pick_list/README.md diff --git a/examples/combo_box/src/main.rs b/examples/pick_list/src/main.rs similarity index 89% rename from examples/combo_box/src/main.rs rename to examples/pick_list/src/main.rs index 416e9f76..4eb368d1 100644 --- a/examples/combo_box/src/main.rs +++ b/examples/pick_list/src/main.rs @@ -1,6 +1,6 @@ use iced::{ - button, combo_box, scrollable, Align, Button, ComboBox, Container, Element, - Length, Sandbox, Scrollable, Settings, Space, Text, + button, pick_list, scrollable, Align, Button, Container, Element, Length, + PickList, Sandbox, Scrollable, Settings, Space, Text, }; pub fn main() { @@ -11,7 +11,7 @@ pub fn main() { struct Example { scroll: scrollable::State, button: button::State, - combo_box: combo_box::State, + pick_list: pick_list::State, selected_language: Language, } @@ -29,7 +29,7 @@ impl Sandbox for Example { } fn title(&self) -> String { - String::from("Combo box - Iced") + String::from("Pick list - Iced") } fn update(&mut self, message: Message) { @@ -42,8 +42,8 @@ impl Sandbox for Example { } fn view(&mut self) -> Element { - let combo_box = ComboBox::new( - &mut self.combo_box, + let pick_list = PickList::new( + &mut self.pick_list, &Language::ALL[..], Some(self.selected_language), Message::LanguageSelected, @@ -58,7 +58,7 @@ impl Sandbox for Example { .spacing(10) .push(Space::with_height(Length::Units(800))) .push(Text::new("Which is your favorite language?")) - .push(combo_box); + .push(pick_list); content = content .push(button) diff --git a/glow/src/widget.rs b/glow/src/widget.rs index c8f16725..4e2fedc5 100644 --- a/glow/src/widget.rs +++ b/glow/src/widget.rs @@ -11,9 +11,9 @@ use crate::Renderer; pub mod button; pub mod checkbox; -pub mod combo_box; pub mod container; pub mod pane_grid; +pub mod pick_list; pub mod progress_bar; pub mod radio; pub mod scrollable; @@ -25,12 +25,12 @@ pub use button::Button; #[doc(no_inline)] pub use checkbox::Checkbox; #[doc(no_inline)] -pub use combo_box::ComboBox; -#[doc(no_inline)] pub use container::Container; #[doc(no_inline)] pub use pane_grid::PaneGrid; #[doc(no_inline)] +pub use pick_list::PickList; +#[doc(no_inline)] pub use progress_bar::ProgressBar; #[doc(no_inline)] pub use radio::Radio; diff --git a/glow/src/widget/combo_box.rs b/glow/src/widget/combo_box.rs deleted file mode 100644 index 20feeaca..00000000 --- a/glow/src/widget/combo_box.rs +++ /dev/null @@ -1,9 +0,0 @@ -//! Display a dropdown list of selectable values. -pub use iced_native::combo_box::State; - -pub use iced_graphics::combo_box::{Style, StyleSheet}; -pub use iced_graphics::overlay::menu::Style as Menu; - -/// A widget allowing the selection of a single value from a list of options. -pub type ComboBox<'a, T, Message> = - iced_native::ComboBox<'a, T, Message, crate::Renderer>; diff --git a/glow/src/widget/pick_list.rs b/glow/src/widget/pick_list.rs new file mode 100644 index 00000000..fccc68c9 --- /dev/null +++ b/glow/src/widget/pick_list.rs @@ -0,0 +1,9 @@ +//! Display a dropdown list of selectable values. +pub use iced_native::pick_list::State; + +pub use iced_graphics::overlay::menu::Style as Menu; +pub use iced_graphics::pick_list::{Style, StyleSheet}; + +/// A widget allowing the selection of a single value from a list of options. +pub type PickList<'a, T, Message> = + iced_native::PickList<'a, T, Message, crate::Renderer>; diff --git a/graphics/src/widget.rs b/graphics/src/widget.rs index a0d06999..94a65011 100644 --- a/graphics/src/widget.rs +++ b/graphics/src/widget.rs @@ -9,10 +9,10 @@ //! ``` pub mod button; pub mod checkbox; -pub mod combo_box; pub mod container; pub mod image; pub mod pane_grid; +pub mod pick_list; pub mod progress_bar; pub mod radio; pub mod scrollable; @@ -34,6 +34,8 @@ pub use container::Container; #[doc(no_inline)] pub use pane_grid::PaneGrid; #[doc(no_inline)] +pub use pick_list::PickList; +#[doc(no_inline)] pub use progress_bar::ProgressBar; #[doc(no_inline)] pub use radio::Radio; diff --git a/graphics/src/widget/combo_box.rs b/graphics/src/widget/pick_list.rs similarity index 91% rename from graphics/src/widget/combo_box.rs rename to graphics/src/widget/pick_list.rs index f200c2b7..f42a8707 100644 --- a/graphics/src/widget/combo_box.rs +++ b/graphics/src/widget/pick_list.rs @@ -6,14 +6,14 @@ use iced_native::{ }; use iced_style::menu; -pub use iced_native::combo_box::State; -pub use iced_style::combo_box::{Style, StyleSheet}; +pub use iced_native::pick_list::State; +pub use iced_style::pick_list::{Style, StyleSheet}; /// A widget allowing the selection of a single value from a list of options. -pub type ComboBox<'a, T, Message, Backend> = - iced_native::ComboBox<'a, T, Message, Renderer>; +pub type PickList<'a, T, Message, Backend> = + iced_native::PickList<'a, T, Message, Renderer>; -impl iced_native::combo_box::Renderer for Renderer +impl iced_native::pick_list::Renderer for Renderer where B: Backend + backend::Text, { diff --git a/native/src/widget.rs b/native/src/widget.rs index 931b4739..8539e519 100644 --- a/native/src/widget.rs +++ b/native/src/widget.rs @@ -23,10 +23,10 @@ pub mod button; pub mod checkbox; pub mod column; -pub mod combo_box; pub mod container; pub mod image; pub mod pane_grid; +pub mod pick_list; pub mod progress_bar; pub mod radio; pub mod row; @@ -44,14 +44,14 @@ pub use checkbox::Checkbox; #[doc(no_inline)] pub use column::Column; #[doc(no_inline)] -pub use combo_box::ComboBox; -#[doc(no_inline)] pub use container::Container; #[doc(no_inline)] pub use image::Image; #[doc(no_inline)] pub use pane_grid::PaneGrid; #[doc(no_inline)] +pub use pick_list::PickList; +#[doc(no_inline)] pub use progress_bar::ProgressBar; #[doc(no_inline)] pub use radio::Radio; diff --git a/native/src/widget/combo_box.rs b/native/src/widget/pick_list.rs similarity index 85% rename from native/src/widget/combo_box.rs rename to native/src/widget/pick_list.rs index fefaf8ff..9f62e550 100644 --- a/native/src/widget/combo_box.rs +++ b/native/src/widget/pick_list.rs @@ -9,7 +9,7 @@ use std::borrow::Cow; /// A widget for selecting a single value from a list of options. #[allow(missing_debug_implementations)] -pub struct ComboBox<'a, T, Message, Renderer: self::Renderer> +pub struct PickList<'a, T, Message, Renderer: self::Renderer> where [T]: ToOwned>, { @@ -25,25 +25,25 @@ where is_open: bool, } -/// The local state of a [`ComboBox`]. +/// The local state of a [`PickList`]. /// -/// [`ComboBox`]: struct.ComboBox.html +/// [`PickList`]: struct.PickList.html #[derive(Debug, Clone, Default)] pub struct State { menu: menu::State, } impl<'a, T: 'a, Message, Renderer: self::Renderer> - ComboBox<'a, T, Message, Renderer> + PickList<'a, T, Message, Renderer> where T: ToString, [T]: ToOwned>, { - /// Creates a new [`ComboBox`] with the given [`State`], a list of options, + /// Creates a new [`PickList`] with the given [`State`], a list of options, /// the current selected value, and the message to produce when an option is /// selected. /// - /// [`ComboBox`]: struct.ComboBox.html + /// [`PickList`]: struct.PickList.html /// [`State`]: struct.State.html pub fn new( state: &'a mut State, @@ -67,41 +67,41 @@ where } } - /// Sets the width of the [`ComboBox`]. + /// Sets the width of the [`PickList`]. /// - /// [`ComboBox`]: struct.ComboBox.html + /// [`PickList`]: struct.PickList.html pub fn width(mut self, width: Length) -> Self { self.width = width; self } - /// Sets the padding of the [`ComboBox`]. + /// Sets the padding of the [`PickList`]. /// - /// [`ComboBox`]: struct.ComboBox.html + /// [`PickList`]: struct.PickList.html pub fn padding(mut self, padding: u16) -> Self { self.padding = padding; self } - /// Sets the text size of the [`ComboBox`]. + /// Sets the text size of the [`PickList`]. /// - /// [`ComboBox`]: struct.ComboBox.html + /// [`PickList`]: struct.PickList.html pub fn text_size(mut self, size: u16) -> Self { self.text_size = Some(size); self } - /// Sets the font of the [`ComboBox`]. + /// Sets the font of the [`PickList`]. /// - /// [`ComboBox`]: struct.ComboBox.html + /// [`PickList`]: struct.PickList.html pub fn font(mut self, font: Renderer::Font) -> Self { self.font = font; self } - /// Sets the style of the [`ComboBox`]. + /// Sets the style of the [`PickList`]. /// - /// [`ComboBox`]: struct.ComboBox.html + /// [`PickList`]: struct.PickList.html pub fn style( mut self, style: impl Into<::Style>, @@ -112,7 +112,7 @@ where } impl<'a, T: 'a, Message, Renderer> Widget - for ComboBox<'a, T, Message, Renderer> + for PickList<'a, T, Message, Renderer> where T: Clone + ToString + Eq, [T]: ToOwned>, @@ -265,35 +265,35 @@ where } } -/// The renderer of a [`ComboBox`]. +/// The renderer of a [`PickList`]. /// /// Your [renderer] will need to implement this trait before being -/// able to use a [`ComboBox`] in your user interface. +/// able to use a [`PickList`] in your user interface. /// -/// [`ComboBox`]: struct.ComboBox.html +/// [`PickList`]: struct.PickList.html /// [renderer]: ../../renderer/index.html pub trait Renderer: text::Renderer + menu::Renderer { - /// The default padding of a [`ComboBox`]. + /// The default padding of a [`PickList`]. /// - /// [`ComboBox`]: struct.ComboBox.html + /// [`PickList`]: struct.PickList.html const DEFAULT_PADDING: u16; - /// The [`ComboBox`] style supported by this renderer. + /// The [`PickList`] style supported by this renderer. /// - /// [`ComboBox`]: struct.ComboBox.html + /// [`PickList`]: struct.PickList.html type Style: Default; - /// Returns the style of the [`Menu`] of the [`ComboBox`]. + /// Returns the style of the [`Menu`] of the [`PickList`]. /// /// [`Menu`]: ../../overlay/menu/struct.Menu.html - /// [`ComboBox`]: struct.ComboBox.html + /// [`PickList`]: struct.PickList.html fn menu_style( style: &::Style, ) -> ::Style; - /// Draws a [`ComboBox`]. + /// Draws a [`PickList`]. /// - /// [`ComboBox`]: struct.ComboBox.html + /// [`PickList`]: struct.PickList.html fn draw( &mut self, bounds: Rectangle, @@ -307,7 +307,7 @@ pub trait Renderer: text::Renderer + menu::Renderer { } impl<'a, T: 'a, Message, Renderer> Into> - for ComboBox<'a, T, Message, Renderer> + for PickList<'a, T, Message, Renderer> where T: Clone + ToString + Eq, [T]: ToOwned>, diff --git a/src/widget.rs b/src/widget.rs index 034f02cd..b26f14d4 100644 --- a/src/widget.rs +++ b/src/widget.rs @@ -19,7 +19,7 @@ #[cfg(not(target_arch = "wasm32"))] mod platform { pub use crate::renderer::widget::{ - button, checkbox, combo_box, container, pane_grid, progress_bar, radio, + button, checkbox, container, pane_grid, pick_list, progress_bar, radio, scrollable, slider, text_input, Column, Row, Space, Text, }; @@ -44,10 +44,10 @@ mod platform { #[doc(no_inline)] pub use { - button::Button, checkbox::Checkbox, combo_box::ComboBox, - container::Container, image::Image, pane_grid::PaneGrid, - progress_bar::ProgressBar, radio::Radio, scrollable::Scrollable, - slider::Slider, svg::Svg, text_input::TextInput, + button::Button, checkbox::Checkbox, container::Container, image::Image, + pane_grid::PaneGrid, pick_list::PickList, progress_bar::ProgressBar, + radio::Radio, scrollable::Scrollable, slider::Slider, svg::Svg, + text_input::TextInput, }; #[cfg(any(feature = "canvas", feature = "glow_canvas"))] diff --git a/style/src/lib.rs b/style/src/lib.rs index b19d6600..8e402bb1 100644 --- a/style/src/lib.rs +++ b/style/src/lib.rs @@ -6,9 +6,9 @@ pub use iced_core::{Background, Color}; pub mod button; pub mod checkbox; -pub mod combo_box; pub mod container; pub mod menu; +pub mod pick_list; pub mod progress_bar; pub mod radio; pub mod scrollable; diff --git a/style/src/combo_box.rs b/style/src/pick_list.rs similarity index 97% rename from style/src/combo_box.rs rename to style/src/pick_list.rs index 4d0c4e46..fbd431c0 100644 --- a/style/src/combo_box.rs +++ b/style/src/pick_list.rs @@ -1,7 +1,7 @@ use crate::menu; use iced_core::{Background, Color}; -/// The appearance of a combo box. +/// The appearance of a pick list. #[derive(Debug, Clone, Copy)] pub struct Style { pub text_color: Color, diff --git a/wgpu/src/widget.rs b/wgpu/src/widget.rs index 0f390c8d..ced64332 100644 --- a/wgpu/src/widget.rs +++ b/wgpu/src/widget.rs @@ -11,9 +11,9 @@ use crate::Renderer; pub mod button; pub mod checkbox; -pub mod combo_box; pub mod container; pub mod pane_grid; +pub mod pick_list; pub mod progress_bar; pub mod radio; pub mod scrollable; @@ -25,12 +25,12 @@ pub use button::Button; #[doc(no_inline)] pub use checkbox::Checkbox; #[doc(no_inline)] -pub use combo_box::ComboBox; -#[doc(no_inline)] pub use container::Container; #[doc(no_inline)] pub use pane_grid::PaneGrid; #[doc(no_inline)] +pub use pick_list::PickList; +#[doc(no_inline)] pub use progress_bar::ProgressBar; #[doc(no_inline)] pub use radio::Radio; diff --git a/wgpu/src/widget/combo_box.rs b/wgpu/src/widget/combo_box.rs deleted file mode 100644 index 20feeaca..00000000 --- a/wgpu/src/widget/combo_box.rs +++ /dev/null @@ -1,9 +0,0 @@ -//! Display a dropdown list of selectable values. -pub use iced_native::combo_box::State; - -pub use iced_graphics::combo_box::{Style, StyleSheet}; -pub use iced_graphics::overlay::menu::Style as Menu; - -/// A widget allowing the selection of a single value from a list of options. -pub type ComboBox<'a, T, Message> = - iced_native::ComboBox<'a, T, Message, crate::Renderer>; diff --git a/wgpu/src/widget/pick_list.rs b/wgpu/src/widget/pick_list.rs new file mode 100644 index 00000000..fccc68c9 --- /dev/null +++ b/wgpu/src/widget/pick_list.rs @@ -0,0 +1,9 @@ +//! Display a dropdown list of selectable values. +pub use iced_native::pick_list::State; + +pub use iced_graphics::overlay::menu::Style as Menu; +pub use iced_graphics::pick_list::{Style, StyleSheet}; + +/// A widget allowing the selection of a single value from a list of options. +pub type PickList<'a, T, Message> = + iced_native::PickList<'a, T, Message, crate::Renderer>;