Rename `ComboBox` to `PickList`

This commit is contained in:
Héctor Ramón Jiménez 2020-07-10 02:50:47 +02:00
parent 2118a726f8
commit 73b8ae8e5e
17 changed files with 80 additions and 80 deletions

View File

@ -56,7 +56,6 @@ members = [
"examples/bezier_tool", "examples/bezier_tool",
"examples/clock", "examples/clock",
"examples/color_palette", "examples/color_palette",
"examples/combo_box",
"examples/counter", "examples/counter",
"examples/custom_widget", "examples/custom_widget",
"examples/download_progress", "examples/download_progress",
@ -65,6 +64,7 @@ members = [
"examples/geometry", "examples/geometry",
"examples/integration", "examples/integration",
"examples/pane_grid", "examples/pane_grid",
"examples/pick_list",
"examples/pokedex", "examples/pokedex",
"examples/progress_bar", "examples/progress_bar",
"examples/solar_system", "examples/solar_system",

View File

@ -1,5 +1,5 @@
[package] [package]
name = "combo_box" name = "pick_list"
version = "0.1.0" version = "0.1.0"
authors = ["Héctor Ramón Jiménez <hector0193@gmail.com>"] authors = ["Héctor Ramón Jiménez <hector0193@gmail.com>"]
edition = "2018" edition = "2018"
@ -7,5 +7,3 @@ publish = false
[dependencies] [dependencies]
iced = { path = "../..", features = ["debug"] } iced = { path = "../..", features = ["debug"] }
iced_native = { path = "../../native" }
iced_wgpu = { path = "../../wgpu" }

View File

@ -1,6 +1,6 @@
use iced::{ use iced::{
button, combo_box, scrollable, Align, Button, ComboBox, Container, Element, button, pick_list, scrollable, Align, Button, Container, Element, Length,
Length, Sandbox, Scrollable, Settings, Space, Text, PickList, Sandbox, Scrollable, Settings, Space, Text,
}; };
pub fn main() { pub fn main() {
@ -11,7 +11,7 @@ pub fn main() {
struct Example { struct Example {
scroll: scrollable::State, scroll: scrollable::State,
button: button::State, button: button::State,
combo_box: combo_box::State, pick_list: pick_list::State,
selected_language: Language, selected_language: Language,
} }
@ -29,7 +29,7 @@ impl Sandbox for Example {
} }
fn title(&self) -> String { fn title(&self) -> String {
String::from("Combo box - Iced") String::from("Pick list - Iced")
} }
fn update(&mut self, message: Message) { fn update(&mut self, message: Message) {
@ -42,8 +42,8 @@ impl Sandbox for Example {
} }
fn view(&mut self) -> Element<Message> { fn view(&mut self) -> Element<Message> {
let combo_box = ComboBox::new( let pick_list = PickList::new(
&mut self.combo_box, &mut self.pick_list,
&Language::ALL[..], &Language::ALL[..],
Some(self.selected_language), Some(self.selected_language),
Message::LanguageSelected, Message::LanguageSelected,
@ -58,7 +58,7 @@ impl Sandbox for Example {
.spacing(10) .spacing(10)
.push(Space::with_height(Length::Units(800))) .push(Space::with_height(Length::Units(800)))
.push(Text::new("Which is your favorite language?")) .push(Text::new("Which is your favorite language?"))
.push(combo_box); .push(pick_list);
content = content content = content
.push(button) .push(button)

View File

@ -11,9 +11,9 @@ use crate::Renderer;
pub mod button; pub mod button;
pub mod checkbox; pub mod checkbox;
pub mod combo_box;
pub mod container; pub mod container;
pub mod pane_grid; pub mod pane_grid;
pub mod pick_list;
pub mod progress_bar; pub mod progress_bar;
pub mod radio; pub mod radio;
pub mod scrollable; pub mod scrollable;
@ -25,12 +25,12 @@ pub use button::Button;
#[doc(no_inline)] #[doc(no_inline)]
pub use checkbox::Checkbox; pub use checkbox::Checkbox;
#[doc(no_inline)] #[doc(no_inline)]
pub use combo_box::ComboBox;
#[doc(no_inline)]
pub use container::Container; pub use container::Container;
#[doc(no_inline)] #[doc(no_inline)]
pub use pane_grid::PaneGrid; pub use pane_grid::PaneGrid;
#[doc(no_inline)] #[doc(no_inline)]
pub use pick_list::PickList;
#[doc(no_inline)]
pub use progress_bar::ProgressBar; pub use progress_bar::ProgressBar;
#[doc(no_inline)] #[doc(no_inline)]
pub use radio::Radio; pub use radio::Radio;

View File

@ -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>;

View File

@ -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>;

View File

@ -9,10 +9,10 @@
//! ``` //! ```
pub mod button; pub mod button;
pub mod checkbox; pub mod checkbox;
pub mod combo_box;
pub mod container; pub mod container;
pub mod image; pub mod image;
pub mod pane_grid; pub mod pane_grid;
pub mod pick_list;
pub mod progress_bar; pub mod progress_bar;
pub mod radio; pub mod radio;
pub mod scrollable; pub mod scrollable;
@ -34,6 +34,8 @@ pub use container::Container;
#[doc(no_inline)] #[doc(no_inline)]
pub use pane_grid::PaneGrid; pub use pane_grid::PaneGrid;
#[doc(no_inline)] #[doc(no_inline)]
pub use pick_list::PickList;
#[doc(no_inline)]
pub use progress_bar::ProgressBar; pub use progress_bar::ProgressBar;
#[doc(no_inline)] #[doc(no_inline)]
pub use radio::Radio; pub use radio::Radio;

View File

@ -6,14 +6,14 @@ use iced_native::{
}; };
use iced_style::menu; use iced_style::menu;
pub use iced_native::combo_box::State; pub use iced_native::pick_list::State;
pub use iced_style::combo_box::{Style, StyleSheet}; pub use iced_style::pick_list::{Style, StyleSheet};
/// A widget allowing the selection of a single value from a list of options. /// A widget allowing the selection of a single value from a list of options.
pub type ComboBox<'a, T, Message, Backend> = pub type PickList<'a, T, Message, Backend> =
iced_native::ComboBox<'a, T, Message, Renderer<Backend>>; iced_native::PickList<'a, T, Message, Renderer<Backend>>;
impl<B> iced_native::combo_box::Renderer for Renderer<B> impl<B> iced_native::pick_list::Renderer for Renderer<B>
where where
B: Backend + backend::Text, B: Backend + backend::Text,
{ {

View File

@ -23,10 +23,10 @@
pub mod button; pub mod button;
pub mod checkbox; pub mod checkbox;
pub mod column; pub mod column;
pub mod combo_box;
pub mod container; pub mod container;
pub mod image; pub mod image;
pub mod pane_grid; pub mod pane_grid;
pub mod pick_list;
pub mod progress_bar; pub mod progress_bar;
pub mod radio; pub mod radio;
pub mod row; pub mod row;
@ -44,14 +44,14 @@ pub use checkbox::Checkbox;
#[doc(no_inline)] #[doc(no_inline)]
pub use column::Column; pub use column::Column;
#[doc(no_inline)] #[doc(no_inline)]
pub use combo_box::ComboBox;
#[doc(no_inline)]
pub use container::Container; pub use container::Container;
#[doc(no_inline)] #[doc(no_inline)]
pub use image::Image; pub use image::Image;
#[doc(no_inline)] #[doc(no_inline)]
pub use pane_grid::PaneGrid; pub use pane_grid::PaneGrid;
#[doc(no_inline)] #[doc(no_inline)]
pub use pick_list::PickList;
#[doc(no_inline)]
pub use progress_bar::ProgressBar; pub use progress_bar::ProgressBar;
#[doc(no_inline)] #[doc(no_inline)]
pub use radio::Radio; pub use radio::Radio;

View File

@ -9,7 +9,7 @@ use std::borrow::Cow;
/// A widget for selecting a single value from a list of options. /// A widget for selecting a single value from a list of options.
#[allow(missing_debug_implementations)] #[allow(missing_debug_implementations)]
pub struct ComboBox<'a, T, Message, Renderer: self::Renderer> pub struct PickList<'a, T, Message, Renderer: self::Renderer>
where where
[T]: ToOwned<Owned = Vec<T>>, [T]: ToOwned<Owned = Vec<T>>,
{ {
@ -25,25 +25,25 @@ where
is_open: bool, 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)] #[derive(Debug, Clone, Default)]
pub struct State { pub struct State {
menu: menu::State, menu: menu::State,
} }
impl<'a, T: 'a, Message, Renderer: self::Renderer> impl<'a, T: 'a, Message, Renderer: self::Renderer>
ComboBox<'a, T, Message, Renderer> PickList<'a, T, Message, Renderer>
where where
T: ToString, T: ToString,
[T]: ToOwned<Owned = Vec<T>>, [T]: ToOwned<Owned = Vec<T>>,
{ {
/// 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 /// the current selected value, and the message to produce when an option is
/// selected. /// selected.
/// ///
/// [`ComboBox`]: struct.ComboBox.html /// [`PickList`]: struct.PickList.html
/// [`State`]: struct.State.html /// [`State`]: struct.State.html
pub fn new( pub fn new(
state: &'a mut State, 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 { pub fn width(mut self, width: Length) -> Self {
self.width = width; self.width = width;
self 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 { pub fn padding(mut self, padding: u16) -> Self {
self.padding = padding; self.padding = padding;
self 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 { pub fn text_size(mut self, size: u16) -> Self {
self.text_size = Some(size); self.text_size = Some(size);
self 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 { pub fn font(mut self, font: Renderer::Font) -> Self {
self.font = font; self.font = font;
self self
} }
/// Sets the style of the [`ComboBox`]. /// Sets the style of the [`PickList`].
/// ///
/// [`ComboBox`]: struct.ComboBox.html /// [`PickList`]: struct.PickList.html
pub fn style( pub fn style(
mut self, mut self,
style: impl Into<<Renderer as self::Renderer>::Style>, style: impl Into<<Renderer as self::Renderer>::Style>,
@ -112,7 +112,7 @@ where
} }
impl<'a, T: 'a, Message, Renderer> Widget<Message, Renderer> impl<'a, T: 'a, Message, Renderer> Widget<Message, Renderer>
for ComboBox<'a, T, Message, Renderer> for PickList<'a, T, Message, Renderer>
where where
T: Clone + ToString + Eq, T: Clone + ToString + Eq,
[T]: ToOwned<Owned = Vec<T>>, [T]: ToOwned<Owned = Vec<T>>,
@ -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 /// 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 /// [renderer]: ../../renderer/index.html
pub trait Renderer: text::Renderer + menu::Renderer { 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; 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; 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 /// [`Menu`]: ../../overlay/menu/struct.Menu.html
/// [`ComboBox`]: struct.ComboBox.html /// [`PickList`]: struct.PickList.html
fn menu_style( fn menu_style(
style: &<Self as Renderer>::Style, style: &<Self as Renderer>::Style,
) -> <Self as menu::Renderer>::Style; ) -> <Self as menu::Renderer>::Style;
/// Draws a [`ComboBox`]. /// Draws a [`PickList`].
/// ///
/// [`ComboBox`]: struct.ComboBox.html /// [`PickList`]: struct.PickList.html
fn draw( fn draw(
&mut self, &mut self,
bounds: Rectangle, bounds: Rectangle,
@ -307,7 +307,7 @@ pub trait Renderer: text::Renderer + menu::Renderer {
} }
impl<'a, T: 'a, Message, Renderer> Into<Element<'a, Message, Renderer>> impl<'a, T: 'a, Message, Renderer> Into<Element<'a, Message, Renderer>>
for ComboBox<'a, T, Message, Renderer> for PickList<'a, T, Message, Renderer>
where where
T: Clone + ToString + Eq, T: Clone + ToString + Eq,
[T]: ToOwned<Owned = Vec<T>>, [T]: ToOwned<Owned = Vec<T>>,

View File

@ -19,7 +19,7 @@
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
mod platform { mod platform {
pub use crate::renderer::widget::{ 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, scrollable, slider, text_input, Column, Row, Space, Text,
}; };
@ -44,10 +44,10 @@ mod platform {
#[doc(no_inline)] #[doc(no_inline)]
pub use { pub use {
button::Button, checkbox::Checkbox, combo_box::ComboBox, button::Button, checkbox::Checkbox, container::Container, image::Image,
container::Container, image::Image, pane_grid::PaneGrid, pane_grid::PaneGrid, pick_list::PickList, progress_bar::ProgressBar,
progress_bar::ProgressBar, radio::Radio, scrollable::Scrollable, radio::Radio, scrollable::Scrollable, slider::Slider, svg::Svg,
slider::Slider, svg::Svg, text_input::TextInput, text_input::TextInput,
}; };
#[cfg(any(feature = "canvas", feature = "glow_canvas"))] #[cfg(any(feature = "canvas", feature = "glow_canvas"))]

View File

@ -6,9 +6,9 @@ pub use iced_core::{Background, Color};
pub mod button; pub mod button;
pub mod checkbox; pub mod checkbox;
pub mod combo_box;
pub mod container; pub mod container;
pub mod menu; pub mod menu;
pub mod pick_list;
pub mod progress_bar; pub mod progress_bar;
pub mod radio; pub mod radio;
pub mod scrollable; pub mod scrollable;

View File

@ -1,7 +1,7 @@
use crate::menu; use crate::menu;
use iced_core::{Background, Color}; use iced_core::{Background, Color};
/// The appearance of a combo box. /// The appearance of a pick list.
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy)]
pub struct Style { pub struct Style {
pub text_color: Color, pub text_color: Color,

View File

@ -11,9 +11,9 @@ use crate::Renderer;
pub mod button; pub mod button;
pub mod checkbox; pub mod checkbox;
pub mod combo_box;
pub mod container; pub mod container;
pub mod pane_grid; pub mod pane_grid;
pub mod pick_list;
pub mod progress_bar; pub mod progress_bar;
pub mod radio; pub mod radio;
pub mod scrollable; pub mod scrollable;
@ -25,12 +25,12 @@ pub use button::Button;
#[doc(no_inline)] #[doc(no_inline)]
pub use checkbox::Checkbox; pub use checkbox::Checkbox;
#[doc(no_inline)] #[doc(no_inline)]
pub use combo_box::ComboBox;
#[doc(no_inline)]
pub use container::Container; pub use container::Container;
#[doc(no_inline)] #[doc(no_inline)]
pub use pane_grid::PaneGrid; pub use pane_grid::PaneGrid;
#[doc(no_inline)] #[doc(no_inline)]
pub use pick_list::PickList;
#[doc(no_inline)]
pub use progress_bar::ProgressBar; pub use progress_bar::ProgressBar;
#[doc(no_inline)] #[doc(no_inline)]
pub use radio::Radio; pub use radio::Radio;

View File

@ -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>;

View File

@ -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>;