Export widget modules in iced_pure
... and fix collisions with the new `helpers`
This commit is contained in:
parent
cdd906f563
commit
d7100fd259
31 changed files with 378 additions and 232 deletions
|
|
@ -9,3 +9,4 @@ publish = false
|
|||
iced = { path = "../../..", features = ["debug", "pure"] }
|
||||
iced_native = { path = "../../../native" }
|
||||
iced_lazy = { path = "../../../lazy", features = ["pure"] }
|
||||
iced_pure = { path = "../../../pure" }
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use iced::pure::widget::container;
|
||||
use iced::pure::container;
|
||||
use iced::pure::{Element, Sandbox};
|
||||
use iced::{Length, Settings};
|
||||
|
||||
|
|
@ -47,12 +47,12 @@ impl Sandbox for Component {
|
|||
}
|
||||
|
||||
mod numeric_input {
|
||||
use iced::pure::widget::Element;
|
||||
use iced::pure::widget::{row, text, text_input};
|
||||
use iced::pure::{button, row, text, text_input};
|
||||
use iced_lazy::pure::{self, Component};
|
||||
use iced_native::alignment::{self, Alignment};
|
||||
use iced_native::text;
|
||||
use iced_native::Length;
|
||||
use iced_pure::Element;
|
||||
|
||||
pub struct NumericInput<Message> {
|
||||
value: Option<u32>,
|
||||
|
|
@ -120,8 +120,6 @@ mod numeric_input {
|
|||
|
||||
fn view(&self, _state: &Self::State) -> Element<Event, Renderer> {
|
||||
let button = |label, on_press| {
|
||||
use iced::pure::widget::button;
|
||||
|
||||
button(
|
||||
text(label)
|
||||
.width(Length::Fill)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
use iced::pure::widget::{button, column, text};
|
||||
use iced::pure::{Element, Sandbox};
|
||||
use iced::pure::{button, column, text, Element, Sandbox};
|
||||
use iced::{Alignment, Settings};
|
||||
|
||||
pub fn main() -> iced::Result {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ mod style;
|
|||
|
||||
use grid::Grid;
|
||||
use iced::executor;
|
||||
use iced::pure::widget::{
|
||||
use iced::pure::{
|
||||
button, checkbox, column, container, pick_list, row, slider, text,
|
||||
};
|
||||
use iced::pure::{Application, Element};
|
||||
|
|
@ -207,8 +207,8 @@ fn view_controls<'a>(
|
|||
|
||||
mod grid {
|
||||
use crate::Preset;
|
||||
use iced::pure::canvas::event::{self, Event};
|
||||
use iced::pure::canvas::{
|
||||
use iced::pure::widget::canvas::event::{self, Event};
|
||||
use iced::pure::widget::canvas::{
|
||||
self, Cache, Canvas, Cursor, Frame, Geometry, Path, Text,
|
||||
};
|
||||
use iced::pure::Element;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use iced::alignment::{self, Alignment};
|
||||
use iced::executor;
|
||||
use iced::keyboard;
|
||||
use iced::pure::pane_grid::{self, PaneGrid};
|
||||
use iced::pure::widget::pane_grid::{self, PaneGrid};
|
||||
use iced::pure::{button, column, container, row, scrollable, text};
|
||||
use iced::pure::{Application, Element};
|
||||
use iced::{Color, Command, Length, Settings, Size, Subscription};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
use iced::pure::widget::{
|
||||
column, container, pick_list, scrollable, vertical_space,
|
||||
};
|
||||
use iced::pure::{column, container, pick_list, scrollable, vertical_space};
|
||||
use iced::pure::{Element, Sandbox};
|
||||
use iced::{Alignment, Length, Settings};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
use iced::alignment::{self, Alignment};
|
||||
use iced::pure::widget::{
|
||||
use iced::pure::widget::Text;
|
||||
use iced::pure::{
|
||||
button, checkbox, column, container, row, scrollable, text, text_input,
|
||||
Application, Element,
|
||||
};
|
||||
use iced::pure::{Application, Element, Text};
|
||||
use iced::window;
|
||||
use iced::{Command, Font, Length, Settings};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
use iced::alignment;
|
||||
use iced::pure::widget::{
|
||||
use iced::pure::widget::{Button, Column, Container, Slider};
|
||||
use iced::pure::{
|
||||
checkbox, column, container, horizontal_space, image, radio, row,
|
||||
scrollable, slider, text, text_input, toggler, vertical_space,
|
||||
};
|
||||
use iced::pure::{Button, Column, Container, Element, Sandbox, Slider};
|
||||
use iced::pure::{Element, Sandbox};
|
||||
use iced::{Color, Length, Settings};
|
||||
|
||||
pub fn main() -> iced::Result {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ use iced_native::mouse;
|
|||
use iced_native::renderer;
|
||||
use iced_native::{Clipboard, Length, Point, Rectangle, Shell, Size, Vector};
|
||||
use iced_pure::widget::tree::{self, Tree};
|
||||
use iced_pure::widget::{Element, Widget};
|
||||
use iced_pure::{Element, Widget};
|
||||
|
||||
/// A widget capable of drawing 2D graphics.
|
||||
///
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ use iced_native::layout::{self, Layout};
|
|||
use iced_native::mouse;
|
||||
use iced_native::renderer;
|
||||
use iced_native::{Clipboard, Length, Point, Rectangle, Shell, Size};
|
||||
use iced_pure::horizontal_space;
|
||||
use iced_pure::overlay;
|
||||
use iced_pure::widget::horizontal_space;
|
||||
use iced_pure::widget::tree::{self, Tree};
|
||||
use iced_pure::{Element, Widget};
|
||||
|
||||
|
|
|
|||
153
pure/src/helpers.rs
Normal file
153
pure/src/helpers.rs
Normal file
|
|
@ -0,0 +1,153 @@
|
|||
use crate::widget;
|
||||
use crate::Element;
|
||||
|
||||
use iced_native::Length;
|
||||
use std::borrow::Cow;
|
||||
use std::ops::RangeInclusive;
|
||||
|
||||
pub fn container<'a, Message, Renderer>(
|
||||
content: impl Into<Element<'a, Message, Renderer>>,
|
||||
) -> widget::Container<'a, Message, Renderer>
|
||||
where
|
||||
Renderer: iced_native::Renderer,
|
||||
{
|
||||
widget::Container::new(content)
|
||||
}
|
||||
|
||||
pub fn column<'a, Message, Renderer>() -> widget::Column<'a, Message, Renderer>
|
||||
{
|
||||
widget::Column::new()
|
||||
}
|
||||
|
||||
pub fn row<'a, Message, Renderer>() -> widget::Row<'a, Message, Renderer> {
|
||||
widget::Row::new()
|
||||
}
|
||||
|
||||
pub fn scrollable<'a, Message, Renderer>(
|
||||
content: impl Into<Element<'a, Message, Renderer>>,
|
||||
) -> widget::Scrollable<'a, Message, Renderer>
|
||||
where
|
||||
Renderer: iced_native::Renderer,
|
||||
{
|
||||
widget::Scrollable::new(content)
|
||||
}
|
||||
|
||||
pub fn button<'a, Message, Renderer>(
|
||||
content: impl Into<Element<'a, Message, Renderer>>,
|
||||
) -> widget::Button<'a, Message, Renderer> {
|
||||
widget::Button::new(content)
|
||||
}
|
||||
|
||||
pub fn text<Renderer>(text: impl Into<String>) -> widget::Text<Renderer>
|
||||
where
|
||||
Renderer: iced_native::text::Renderer,
|
||||
{
|
||||
widget::Text::new(text)
|
||||
}
|
||||
|
||||
pub fn checkbox<'a, Message, Renderer>(
|
||||
label: impl Into<String>,
|
||||
is_checked: bool,
|
||||
f: impl Fn(bool) -> Message + 'a,
|
||||
) -> widget::Checkbox<'a, Message, Renderer>
|
||||
where
|
||||
Renderer: iced_native::text::Renderer,
|
||||
{
|
||||
widget::Checkbox::new(is_checked, label, f)
|
||||
}
|
||||
|
||||
pub fn radio<'a, Message, Renderer, V>(
|
||||
label: impl Into<String>,
|
||||
value: V,
|
||||
selected: Option<V>,
|
||||
on_click: impl FnOnce(V) -> Message,
|
||||
) -> widget::Radio<'a, Message, Renderer>
|
||||
where
|
||||
Message: Clone,
|
||||
Renderer: iced_native::text::Renderer,
|
||||
V: Copy + Eq,
|
||||
{
|
||||
widget::Radio::new(value, label, selected, on_click)
|
||||
}
|
||||
|
||||
pub fn toggler<'a, Message, Renderer>(
|
||||
label: impl Into<Option<String>>,
|
||||
is_checked: bool,
|
||||
f: impl Fn(bool) -> Message + 'a,
|
||||
) -> widget::Toggler<'a, Message, Renderer>
|
||||
where
|
||||
Renderer: iced_native::text::Renderer,
|
||||
{
|
||||
widget::Toggler::new(is_checked, label, f)
|
||||
}
|
||||
|
||||
pub fn text_input<'a, Message, Renderer>(
|
||||
placeholder: &str,
|
||||
value: &str,
|
||||
on_change: impl Fn(String) -> Message + 'a,
|
||||
) -> widget::TextInput<'a, Message, Renderer>
|
||||
where
|
||||
Message: Clone,
|
||||
Renderer: iced_native::text::Renderer,
|
||||
{
|
||||
widget::TextInput::new(placeholder, value, on_change)
|
||||
}
|
||||
|
||||
pub fn slider<'a, Message, T>(
|
||||
range: std::ops::RangeInclusive<T>,
|
||||
value: T,
|
||||
on_change: impl Fn(T) -> Message + 'a,
|
||||
) -> widget::Slider<'a, T, Message>
|
||||
where
|
||||
Message: Clone,
|
||||
T: Copy + From<u8> + std::cmp::PartialOrd,
|
||||
{
|
||||
widget::Slider::new(range, value, on_change)
|
||||
}
|
||||
|
||||
pub fn pick_list<'a, Message, Renderer, T>(
|
||||
options: impl Into<Cow<'a, [T]>>,
|
||||
selected: Option<T>,
|
||||
on_selected: impl Fn(T) -> Message + 'a,
|
||||
) -> widget::PickList<'a, T, Message, Renderer>
|
||||
where
|
||||
T: ToString + Eq + 'static,
|
||||
[T]: ToOwned<Owned = Vec<T>>,
|
||||
Renderer: iced_native::text::Renderer,
|
||||
{
|
||||
widget::PickList::new(options, selected, on_selected)
|
||||
}
|
||||
|
||||
pub fn image<Handle>(handle: impl Into<Handle>) -> widget::Image<Handle> {
|
||||
widget::Image::new(handle.into())
|
||||
}
|
||||
|
||||
pub fn horizontal_space(width: Length) -> widget::Space {
|
||||
widget::Space::with_width(width)
|
||||
}
|
||||
|
||||
pub fn vertical_space(height: Length) -> widget::Space {
|
||||
widget::Space::with_height(height)
|
||||
}
|
||||
|
||||
/// Creates a horizontal [`Rule`] with the given height.
|
||||
pub fn horizontal_rule<'a>(height: u16) -> widget::Rule<'a> {
|
||||
widget::Rule::horizontal(height)
|
||||
}
|
||||
|
||||
/// Creates a vertical [`Rule`] with the given width.
|
||||
pub fn vertical_rule<'a>(width: u16) -> widget::Rule<'a> {
|
||||
widget::Rule::horizontal(width)
|
||||
}
|
||||
|
||||
/// Creates a new [`ProgressBar`].
|
||||
///
|
||||
/// It expects:
|
||||
/// * an inclusive range of possible values
|
||||
/// * the current value of the [`ProgressBar`]
|
||||
pub fn progress_bar<'a>(
|
||||
range: RangeInclusive<f32>,
|
||||
value: f32,
|
||||
) -> widget::ProgressBar<'a> {
|
||||
widget::ProgressBar::new(range, value)
|
||||
}
|
||||
|
|
@ -1,9 +1,14 @@
|
|||
pub mod helpers;
|
||||
pub mod overlay;
|
||||
pub mod widget;
|
||||
|
||||
pub(crate) mod flex;
|
||||
|
||||
pub use widget::*;
|
||||
mod element;
|
||||
|
||||
pub use element::Element;
|
||||
pub use helpers::*;
|
||||
pub use widget::Widget;
|
||||
|
||||
use iced_native::event::{self, Event};
|
||||
use iced_native::layout::{self, Layout};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::Tree;
|
||||
use crate::widget::Tree;
|
||||
|
||||
use iced_native::Layout;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,29 +1,27 @@
|
|||
pub mod button;
|
||||
pub mod checkbox;
|
||||
pub mod container;
|
||||
pub mod image;
|
||||
pub mod pane_grid;
|
||||
pub mod pick_list;
|
||||
pub mod progress_bar;
|
||||
pub mod radio;
|
||||
pub mod rule;
|
||||
pub mod scrollable;
|
||||
pub mod slider;
|
||||
pub mod text_input;
|
||||
pub mod toggler;
|
||||
pub mod tree;
|
||||
|
||||
mod button;
|
||||
mod checkbox;
|
||||
mod column;
|
||||
mod container;
|
||||
mod element;
|
||||
mod pick_list;
|
||||
mod radio;
|
||||
mod row;
|
||||
mod scrollable;
|
||||
mod slider;
|
||||
mod space;
|
||||
mod text;
|
||||
mod text_input;
|
||||
mod toggler;
|
||||
|
||||
pub use button::Button;
|
||||
pub use checkbox::Checkbox;
|
||||
pub use column::Column;
|
||||
pub use container::Container;
|
||||
pub use element::Element;
|
||||
pub use image::Image;
|
||||
pub use pane_grid::PaneGrid;
|
||||
pub use pick_list::PickList;
|
||||
|
|
@ -46,9 +44,6 @@ use iced_native::overlay;
|
|||
use iced_native::renderer;
|
||||
use iced_native::{Clipboard, Length, Point, Rectangle, Shell};
|
||||
|
||||
use std::borrow::Cow;
|
||||
use std::ops::RangeInclusive;
|
||||
|
||||
pub trait Widget<Message, Renderer> {
|
||||
fn width(&self) -> Length;
|
||||
|
||||
|
|
@ -117,149 +112,3 @@ pub trait Widget<Message, Renderer> {
|
|||
None
|
||||
}
|
||||
}
|
||||
|
||||
pub fn container<'a, Message, Renderer>(
|
||||
content: impl Into<Element<'a, Message, Renderer>>,
|
||||
) -> Container<'a, Message, Renderer>
|
||||
where
|
||||
Renderer: iced_native::Renderer,
|
||||
{
|
||||
Container::new(content)
|
||||
}
|
||||
|
||||
pub fn column<'a, Message, Renderer>() -> Column<'a, Message, Renderer> {
|
||||
Column::new()
|
||||
}
|
||||
|
||||
pub fn row<'a, Message, Renderer>() -> Row<'a, Message, Renderer> {
|
||||
Row::new()
|
||||
}
|
||||
|
||||
pub fn scrollable<'a, Message, Renderer>(
|
||||
content: impl Into<Element<'a, Message, Renderer>>,
|
||||
) -> Scrollable<'a, Message, Renderer>
|
||||
where
|
||||
Renderer: iced_native::Renderer,
|
||||
{
|
||||
Scrollable::new(content)
|
||||
}
|
||||
|
||||
pub fn button<'a, Message, Renderer>(
|
||||
content: impl Into<Element<'a, Message, Renderer>>,
|
||||
) -> Button<'a, Message, Renderer> {
|
||||
Button::new(content)
|
||||
}
|
||||
|
||||
pub fn text<Renderer>(text: impl Into<String>) -> Text<Renderer>
|
||||
where
|
||||
Renderer: iced_native::text::Renderer,
|
||||
{
|
||||
Text::new(text)
|
||||
}
|
||||
|
||||
pub fn checkbox<'a, Message, Renderer>(
|
||||
label: impl Into<String>,
|
||||
is_checked: bool,
|
||||
f: impl Fn(bool) -> Message + 'a,
|
||||
) -> Checkbox<'a, Message, Renderer>
|
||||
where
|
||||
Renderer: iced_native::text::Renderer,
|
||||
{
|
||||
Checkbox::new(is_checked, label, f)
|
||||
}
|
||||
|
||||
pub fn radio<'a, Message, Renderer, V>(
|
||||
label: impl Into<String>,
|
||||
value: V,
|
||||
selected: Option<V>,
|
||||
on_click: impl FnOnce(V) -> Message,
|
||||
) -> Radio<'a, Message, Renderer>
|
||||
where
|
||||
Message: Clone,
|
||||
Renderer: iced_native::text::Renderer,
|
||||
V: Copy + Eq,
|
||||
{
|
||||
Radio::new(value, label, selected, on_click)
|
||||
}
|
||||
|
||||
pub fn toggler<'a, Message, Renderer>(
|
||||
label: impl Into<Option<String>>,
|
||||
is_checked: bool,
|
||||
f: impl Fn(bool) -> Message + 'a,
|
||||
) -> Toggler<'a, Message, Renderer>
|
||||
where
|
||||
Renderer: iced_native::text::Renderer,
|
||||
{
|
||||
Toggler::new(is_checked, label, f)
|
||||
}
|
||||
|
||||
pub fn text_input<'a, Message, Renderer>(
|
||||
placeholder: &str,
|
||||
value: &str,
|
||||
on_change: impl Fn(String) -> Message + 'a,
|
||||
) -> TextInput<'a, Message, Renderer>
|
||||
where
|
||||
Message: Clone,
|
||||
Renderer: iced_native::text::Renderer,
|
||||
{
|
||||
TextInput::new(placeholder, value, on_change)
|
||||
}
|
||||
|
||||
pub fn slider<'a, Message, T>(
|
||||
range: std::ops::RangeInclusive<T>,
|
||||
value: T,
|
||||
on_change: impl Fn(T) -> Message + 'a,
|
||||
) -> Slider<'a, T, Message>
|
||||
where
|
||||
Message: Clone,
|
||||
T: Copy + From<u8> + std::cmp::PartialOrd,
|
||||
{
|
||||
Slider::new(range, value, on_change)
|
||||
}
|
||||
|
||||
pub fn pick_list<'a, Message, Renderer, T>(
|
||||
options: impl Into<Cow<'a, [T]>>,
|
||||
selected: Option<T>,
|
||||
on_selected: impl Fn(T) -> Message + 'a,
|
||||
) -> PickList<'a, T, Message, Renderer>
|
||||
where
|
||||
T: ToString + Eq + 'static,
|
||||
[T]: ToOwned<Owned = Vec<T>>,
|
||||
Renderer: iced_native::text::Renderer,
|
||||
{
|
||||
PickList::new(options, selected, on_selected)
|
||||
}
|
||||
|
||||
pub fn image<Handle>(handle: impl Into<Handle>) -> Image<Handle> {
|
||||
Image::new(handle.into())
|
||||
}
|
||||
|
||||
pub fn horizontal_space(width: Length) -> Space {
|
||||
Space::with_width(width)
|
||||
}
|
||||
|
||||
pub fn vertical_space(height: Length) -> Space {
|
||||
Space::with_height(height)
|
||||
}
|
||||
|
||||
/// Creates a horizontal [`Rule`] with the given height.
|
||||
pub fn horizontal_rule<'a>(height: u16) -> Rule<'a> {
|
||||
Rule::horizontal(height)
|
||||
}
|
||||
|
||||
/// Creates a vertical [`Rule`] with the given width.
|
||||
pub fn vertical_rule<'a>(width: u16) -> Rule<'a> {
|
||||
Rule::horizontal(width)
|
||||
}
|
||||
|
||||
/// Creates a new [`ProgressBar`].
|
||||
///
|
||||
/// It expects:
|
||||
/// * an inclusive range of possible values
|
||||
/// * the current value of the [`ProgressBar`]
|
||||
pub fn progress_bar<'a>(
|
||||
range: RangeInclusive<f32>,
|
||||
value: f32,
|
||||
) -> ProgressBar<'a> {
|
||||
ProgressBar::new(range, value)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::overlay;
|
||||
use crate::widget::tree::{self, Tree};
|
||||
use crate::widget::{Element, Widget};
|
||||
use crate::{Element, Widget};
|
||||
|
||||
use iced_native::event::{self, Event};
|
||||
use iced_native::layout;
|
||||
|
|
@ -10,9 +10,10 @@ use iced_native::widget::button;
|
|||
use iced_native::{
|
||||
Clipboard, Layout, Length, Padding, Point, Rectangle, Shell,
|
||||
};
|
||||
use iced_style::button::StyleSheet;
|
||||
|
||||
pub use button::State;
|
||||
pub use iced_style::button::{Style, StyleSheet};
|
||||
|
||||
use button::State;
|
||||
|
||||
pub struct Button<'a, Message, Renderer> {
|
||||
content: Element<'a, Message, Renderer>,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
use crate::{Element, Tree, Widget};
|
||||
use crate::widget::Tree;
|
||||
use crate::{Element, Widget};
|
||||
|
||||
use iced_native::event::{self, Event};
|
||||
use iced_native::layout::{self, Layout};
|
||||
|
|
@ -7,7 +8,7 @@ use iced_native::renderer;
|
|||
use iced_native::text;
|
||||
use iced_native::{Clipboard, Length, Point, Rectangle, Shell};
|
||||
|
||||
pub use iced_native::widget::Checkbox;
|
||||
pub use iced_native::widget::checkbox::{Checkbox, Style, StyleSheet};
|
||||
|
||||
impl<'a, Message, Renderer> Widget<Message, Renderer>
|
||||
for Checkbox<'a, Message, Renderer>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
use crate::flex;
|
||||
use crate::overlay;
|
||||
use crate::widget::{Element, Tree, Widget};
|
||||
use crate::widget::Tree;
|
||||
use crate::{Element, Widget};
|
||||
|
||||
use iced_native::event::{self, Event};
|
||||
use iced_native::layout::{self, Layout};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
//! Decorate content and apply alignment.
|
||||
use crate::{Element, Tree, Widget};
|
||||
use crate::widget::Tree;
|
||||
use crate::{Element, Widget};
|
||||
|
||||
use iced_native::alignment;
|
||||
use iced_native::event::{self, Event};
|
||||
|
|
|
|||
|
|
@ -54,7 +54,8 @@ pub use iced_style::pane_grid::{Line, StyleSheet};
|
|||
/// ## Example
|
||||
///
|
||||
/// ```
|
||||
/// # use iced_pure::widget::{pane_grid, text};
|
||||
/// # use iced_pure::widget::pane_grid;
|
||||
/// # use iced_pure::text;
|
||||
/// #
|
||||
/// # type PaneGrid<'a, Message> =
|
||||
/// # iced_pure::widget::PaneGrid<'a, Message, iced_native::renderer::Null>;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
use crate::{Element, Tree, Widget};
|
||||
use crate::widget::Tree;
|
||||
use crate::{Element, Widget};
|
||||
|
||||
use iced_native::event::{self, Event};
|
||||
use iced_native::layout::{self, Layout};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
use crate::{Element, Tree, Widget};
|
||||
use crate::widget::Tree;
|
||||
use crate::{Element, Widget};
|
||||
|
||||
use iced_native::event::{self, Event};
|
||||
use iced_native::layout::{self, Layout};
|
||||
|
|
@ -7,7 +8,7 @@ use iced_native::renderer;
|
|||
use iced_native::text;
|
||||
use iced_native::{Clipboard, Length, Point, Rectangle, Shell};
|
||||
|
||||
pub use iced_native::widget::Radio;
|
||||
pub use iced_native::widget::radio::{Radio, Style, StyleSheet};
|
||||
|
||||
impl<'a, Message, Renderer> Widget<Message, Renderer>
|
||||
for Radio<'a, Message, Renderer>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
use crate::flex;
|
||||
use crate::overlay;
|
||||
use crate::widget::{Element, Tree, Widget};
|
||||
use crate::widget::Tree;
|
||||
use crate::{Element, Widget};
|
||||
|
||||
use iced_native::event::{self, Event};
|
||||
use iced_native::layout::{self, Layout};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
use crate::{Element, Tree, Widget};
|
||||
use crate::widget::Tree;
|
||||
use crate::{Element, Widget};
|
||||
|
||||
use iced_native::event::{self, Event};
|
||||
use iced_native::layout::{self, Layout};
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use iced_native::renderer;
|
|||
use iced_native::widget::scrollable;
|
||||
use iced_native::{Clipboard, Length, Point, Rectangle, Shell, Vector};
|
||||
|
||||
pub use iced_style::scrollable::StyleSheet;
|
||||
pub use iced_style::scrollable::{Scrollbar, Scroller, StyleSheet};
|
||||
|
||||
/// A widget that can vertically display an infinite amount of content with a
|
||||
/// scrollbar.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
use crate::{Element, Tree, Widget};
|
||||
use crate::widget::Tree;
|
||||
use crate::{Element, Widget};
|
||||
|
||||
use iced_native::event::{self, Event};
|
||||
use iced_native::layout::{self, Layout};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
use crate::{Element, Tree, Widget};
|
||||
use crate::widget::Tree;
|
||||
use crate::{Element, Widget};
|
||||
|
||||
use iced_native::layout::{self, Layout};
|
||||
use iced_native::renderer;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::widget::tree::{self, Tree};
|
||||
use crate::widget::{Element, Widget};
|
||||
use crate::{Element, Widget};
|
||||
|
||||
use iced_native::event::{self, Event};
|
||||
use iced_native::layout::{self, Layout};
|
||||
|
|
@ -9,7 +9,7 @@ use iced_native::text;
|
|||
use iced_native::widget::text_input;
|
||||
use iced_native::{Clipboard, Length, Padding, Point, Rectangle, Shell};
|
||||
|
||||
pub use iced_style::text_input::StyleSheet;
|
||||
pub use iced_style::text_input::{Style, StyleSheet};
|
||||
|
||||
/// A field that can be filled with text.
|
||||
///
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::widget::Element;
|
||||
use crate::Element;
|
||||
|
||||
use std::any::{self, Any};
|
||||
|
||||
|
|
|
|||
37
src/pure.rs
37
src/pure.rs
|
|
@ -17,33 +17,7 @@
|
|||
//! [the original widgets]: crate::widget
|
||||
//! [`button::State`]: crate::widget::button::State
|
||||
//! [impure `Application`]: crate::Application
|
||||
pub use iced_pure::{
|
||||
Button as _, Column as _, Element as _, Image as _, Row as _, Text as _, *,
|
||||
};
|
||||
|
||||
/// A generic, pure [`Widget`].
|
||||
pub type Element<'a, Message> =
|
||||
iced_pure::Element<'a, Message, crate::Renderer>;
|
||||
|
||||
/// A pure container widget.
|
||||
pub type Container<'a, Message> =
|
||||
iced_pure::Container<'a, Message, crate::Renderer>;
|
||||
|
||||
/// A pure column widget.
|
||||
pub type Column<'a, Message> = iced_pure::Column<'a, Message, crate::Renderer>;
|
||||
|
||||
/// A pure row widget.
|
||||
pub type Row<'a, Message> = iced_pure::Row<'a, Message, crate::Renderer>;
|
||||
|
||||
/// A pure button widget.
|
||||
pub type Button<'a, Message> = iced_pure::Button<'a, Message, crate::Renderer>;
|
||||
|
||||
/// A pure text widget.
|
||||
pub type Text = iced_pure::Text<crate::Renderer>;
|
||||
|
||||
#[cfg(feature = "image")]
|
||||
/// A pure image widget.
|
||||
pub type Image = iced_pure::Image<crate::widget::image::Handle>;
|
||||
pub mod widget;
|
||||
|
||||
mod application;
|
||||
mod sandbox;
|
||||
|
|
@ -51,8 +25,9 @@ mod sandbox;
|
|||
pub use application::Application;
|
||||
pub use sandbox::Sandbox;
|
||||
|
||||
#[cfg(feature = "canvas")]
|
||||
pub use iced_graphics::widget::pure::canvas;
|
||||
pub use iced_pure::helpers::*;
|
||||
pub use iced_pure::{Pure, State};
|
||||
|
||||
#[cfg(feature = "canvas")]
|
||||
pub use canvas::Canvas;
|
||||
/// A generic, pure [`Widget`].
|
||||
pub type Element<'a, Message> =
|
||||
iced_pure::Element<'a, Message, crate::Renderer>;
|
||||
|
|
|
|||
155
src/pure/widget.rs
Normal file
155
src/pure/widget.rs
Normal file
|
|
@ -0,0 +1,155 @@
|
|||
//! Pure versions of the widgets.
|
||||
|
||||
/// A container that distributes its contents vertically.
|
||||
pub type Column<'a, Message> =
|
||||
iced_pure::widget::Column<'a, Message, crate::Renderer>;
|
||||
|
||||
/// A container that distributes its contents horizontally.
|
||||
pub type Row<'a, Message> =
|
||||
iced_pure::widget::Row<'a, Message, crate::Renderer>;
|
||||
|
||||
/// A paragraph of text.
|
||||
pub type Text = iced_pure::widget::Text<crate::Renderer>;
|
||||
|
||||
pub mod button {
|
||||
//! Allow your users to perform actions by pressing a button.
|
||||
pub use iced_pure::widget::button::{Style, StyleSheet};
|
||||
|
||||
/// A widget that produces a message when clicked.
|
||||
pub type Button<'a, Message> =
|
||||
iced_pure::widget::Button<'a, Message, crate::Renderer>;
|
||||
}
|
||||
|
||||
pub mod checkbox {
|
||||
//! Show toggle controls using checkboxes.
|
||||
pub use iced_pure::widget::checkbox::{Style, StyleSheet};
|
||||
|
||||
/// A box that can be checked.
|
||||
pub type Checkbox<'a, Message> =
|
||||
iced_native::widget::Checkbox<'a, Message, crate::Renderer>;
|
||||
}
|
||||
|
||||
pub mod container {
|
||||
//! Decorate content and apply alignment.
|
||||
pub use iced_pure::widget::container::{Style, StyleSheet};
|
||||
|
||||
/// An element decorating some content.
|
||||
pub type Container<'a, Message> =
|
||||
iced_pure::widget::Container<'a, Message, crate::Renderer>;
|
||||
}
|
||||
|
||||
pub mod pane_grid {
|
||||
//! Let your users split regions of your application and organize layout dynamically.
|
||||
//!
|
||||
//! [](https://gfycat.com/mixedflatjellyfish)
|
||||
//!
|
||||
//! # Example
|
||||
//! The [`pane_grid` example] showcases how to use a [`PaneGrid`] with resizing,
|
||||
//! drag and drop, and hotkey support.
|
||||
//!
|
||||
//! [`pane_grid` example]: https://github.com/iced-rs/iced/tree/0.3/examples/pane_grid
|
||||
pub use iced_pure::widget::pane_grid::{
|
||||
Axis, Configuration, Direction, DragEvent, Line, Node, Pane,
|
||||
ResizeEvent, Split, State, StyleSheet,
|
||||
};
|
||||
|
||||
/// A collection of panes distributed using either vertical or horizontal splits
|
||||
/// to completely fill the space available.
|
||||
///
|
||||
/// [](https://gfycat.com/mixedflatjellyfish)
|
||||
pub type PaneGrid<'a, Message> =
|
||||
iced_pure::widget::PaneGrid<'a, Message, crate::Renderer>;
|
||||
|
||||
/// The content of a [`Pane`].
|
||||
pub type Content<'a, Message> =
|
||||
iced_pure::widget::pane_grid::Content<'a, Message, crate::Renderer>;
|
||||
|
||||
/// The title bar of a [`Pane`].
|
||||
pub type TitleBar<'a, Message> =
|
||||
iced_pure::widget::pane_grid::TitleBar<'a, Message, crate::Renderer>;
|
||||
}
|
||||
|
||||
pub mod pick_list {
|
||||
//! Display a dropdown list of selectable values.
|
||||
pub use iced_pure::overlay::menu::Style as Menu;
|
||||
pub use iced_pure::widget::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_pure::widget::PickList<'a, T, Message, crate::Renderer>;
|
||||
}
|
||||
|
||||
pub mod radio {
|
||||
//! Create choices using radio buttons.
|
||||
pub use iced_pure::widget::radio::{Style, StyleSheet};
|
||||
|
||||
/// A circular button representing a choice.
|
||||
pub type Radio<'a, Message> =
|
||||
iced_pure::widget::Radio<'a, Message, crate::Renderer>;
|
||||
}
|
||||
|
||||
pub mod scrollable {
|
||||
//! Navigate an endless amount of content with a scrollbar.
|
||||
pub use iced_pure::widget::scrollable::{Scrollbar, Scroller, StyleSheet};
|
||||
|
||||
/// A widget that can vertically display an infinite amount of content
|
||||
/// with a scrollbar.
|
||||
pub type Scrollable<'a, Message> =
|
||||
iced_pure::widget::Scrollable<'a, Message, crate::Renderer>;
|
||||
}
|
||||
|
||||
pub mod toggler {
|
||||
//! Show toggle controls using togglers.
|
||||
pub use iced_pure::widget::toggler::{Style, StyleSheet};
|
||||
|
||||
/// A toggler widget.
|
||||
pub type Toggler<'a, Message> =
|
||||
iced_pure::widget::Toggler<'a, Message, crate::Renderer>;
|
||||
}
|
||||
|
||||
pub mod text_input {
|
||||
//! Display fields that can be filled with text.
|
||||
use crate::Renderer;
|
||||
|
||||
pub use iced_pure::widget::text_input::{Style, StyleSheet};
|
||||
|
||||
/// A field that can be filled with text.
|
||||
pub type TextInput<'a, Message> =
|
||||
iced_pure::widget::TextInput<'a, Message, Renderer>;
|
||||
}
|
||||
|
||||
pub use iced_pure::widget::progress_bar;
|
||||
pub use iced_pure::widget::rule;
|
||||
pub use iced_pure::widget::slider;
|
||||
pub use iced_pure::widget::Space;
|
||||
|
||||
pub use button::Button;
|
||||
pub use checkbox::Checkbox;
|
||||
pub use container::Container;
|
||||
pub use pane_grid::PaneGrid;
|
||||
pub use pick_list::PickList;
|
||||
pub use progress_bar::ProgressBar;
|
||||
pub use radio::Radio;
|
||||
pub use rule::Rule;
|
||||
pub use scrollable::Scrollable;
|
||||
pub use slider::Slider;
|
||||
pub use text_input::TextInput;
|
||||
pub use toggler::Toggler;
|
||||
|
||||
#[cfg(feature = "canvas")]
|
||||
pub use iced_graphics::widget::pure::canvas;
|
||||
|
||||
#[cfg(feature = "image")]
|
||||
pub mod image {
|
||||
//! Display images in your user interface.
|
||||
pub use iced_native::image::Handle;
|
||||
|
||||
/// A frame that displays an image.
|
||||
pub type Image = iced_pure::widget::Image<Handle>;
|
||||
}
|
||||
|
||||
#[cfg(feature = "canvas")]
|
||||
pub use canvas::Canvas;
|
||||
|
||||
#[cfg(feature = "image")]
|
||||
pub use image::Image;
|
||||
Loading…
Add table
Add a link
Reference in a new issue