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/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",

View File

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

View File

@ -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<Message> {
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)

View File

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

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

View File

@ -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<Backend>>;
pub type PickList<'a, T, Message, 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
B: Backend + backend::Text,
{

View File

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

View File

@ -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<Owned = Vec<T>>,
{
@ -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<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
/// 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<<Renderer as self::Renderer>::Style>,
@ -112,7 +112,7 @@ where
}
impl<'a, T: 'a, Message, Renderer> Widget<Message, Renderer>
for ComboBox<'a, T, Message, Renderer>
for PickList<'a, T, Message, Renderer>
where
T: Clone + ToString + Eq,
[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
/// 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: &<Self as Renderer>::Style,
) -> <Self as menu::Renderer>::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<Element<'a, Message, Renderer>>
for ComboBox<'a, T, Message, Renderer>
for PickList<'a, T, Message, Renderer>
where
T: Clone + ToString + Eq,
[T]: ToOwned<Owned = Vec<T>>,

View File

@ -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"))]

View File

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

View File

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

View File

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

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