diff options
author | 2022-03-09 14:10:15 +0700 | |
---|---|---|
committer | 2022-03-09 14:10:15 +0700 | |
commit | 12c1a3f829c801022d45f1a294d8fc7fa10606e5 (patch) | |
tree | 05cc7a7981f13063831e7397129ea30a14a6d97a /src | |
parent | 7d9ab71790ba0395681490f3af4d3899bb09ab09 (diff) | |
download | iced-12c1a3f829c801022d45f1a294d8fc7fa10606e5.tar.gz iced-12c1a3f829c801022d45f1a294d8fc7fa10606e5.tar.bz2 iced-12c1a3f829c801022d45f1a294d8fc7fa10606e5.zip |
Remove redundant `widget` modules in subcrates
Instead, we can define the type aliases just once in the root crate!
Diffstat (limited to 'src')
-rw-r--r-- | src/pure.rs | 1 | ||||
-rw-r--r-- | src/widget.rs | 219 |
2 files changed, 180 insertions, 40 deletions
diff --git a/src/pure.rs b/src/pure.rs index 5cab5fd9..2a2984db 100644 --- a/src/pure.rs +++ b/src/pure.rs @@ -41,6 +41,7 @@ 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>; diff --git a/src/widget.rs b/src/widget.rs index c619bcfa..9cc0832f 100644 --- a/src/widget.rs +++ b/src/widget.rs @@ -13,53 +13,192 @@ //! //! These widgets have their own module with a `State` type. For instance, a //! [`TextInput`] has some [`text_input::State`]. -pub use crate::renderer::widget::{ - button, checkbox, container, pane_grid, pick_list, progress_bar, radio, - rule, scrollable, slider, text_input, toggler, tooltip, Column, Row, Space, - Text, -}; - -#[cfg(any(feature = "canvas", feature = "glow_canvas"))] -#[cfg_attr( - docsrs, - doc(cfg(any(feature = "canvas", feature = "glow_canvas"))) -)] -pub use crate::renderer::widget::canvas; - -#[cfg(any(feature = "qr_code", feature = "glow_qr_code"))] -#[cfg_attr( - docsrs, - doc(cfg(any(feature = "qr_code", feature = "glow_qr_code"))) -)] -pub use crate::renderer::widget::qr_code; - -#[cfg_attr(docsrs, doc(cfg(feature = "image")))] + +/// A container that distributes its contents vertically. +pub type Column<'a, Message> = + iced_native::widget::Column<'a, Message, crate::Renderer>; + +/// A container that distributes its contents horizontally. +pub type Row<'a, Message> = + iced_native::widget::Row<'a, Message, crate::Renderer>; + +/// A paragraph of text. +pub type Text = iced_native::widget::Text<crate::Renderer>; + +pub mod button { + //! Allow your users to perform actions by pressing a button. + //! + //! A [`Button`] has some local [`State`]. + pub use iced_native::widget::button::{State, Style, StyleSheet}; + + /// A widget that produces a message when clicked. + pub type Button<'a, Message> = + iced_native::widget::Button<'a, Message, crate::Renderer>; +} + +pub mod checkbox { + //! Show toggle controls using checkboxes. + pub use iced_native::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_native::widget::container::{Style, StyleSheet}; + + /// An element decorating some content. + pub type Container<'a, Message> = + iced_native::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_native::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_native::widget::PaneGrid<'a, Message, crate::Renderer>; + + /// The content of a [`Pane`]. + pub type Content<'a, Message> = + iced_native::widget::pane_grid::Content<'a, Message, crate::Renderer>; + + /// The title bar of a [`Pane`]. + pub type TitleBar<'a, Message> = + iced_native::widget::pane_grid::TitleBar<'a, Message, crate::Renderer>; +} + +pub mod pick_list { + //! Display a dropdown list of selectable values. + pub use iced_native::overlay::menu::Style as Menu; + pub use iced_native::widget::pick_list::{State, Style, StyleSheet}; + + /// A widget allowing the selection of a single value from a list of options. + pub type PickList<'a, T, Message> = + iced_native::widget::PickList<'a, T, Message, crate::Renderer>; +} + +pub mod radio { + //! Create choices using radio buttons. + pub use iced_native::widget::radio::{Style, StyleSheet}; + + /// A circular button representing a choice. + pub type Radio<'a, Message> = + iced_native::widget::Radio<'a, Message, crate::Renderer>; +} + +pub mod scrollable { + //! Navigate an endless amount of content with a scrollbar. + pub use iced_native::widget::scrollable::{ + style::Scrollbar, style::Scroller, State, StyleSheet, + }; + + /// A widget that can vertically display an infinite amount of content + /// with a scrollbar. + pub type Scrollable<'a, Message> = + iced_native::widget::Scrollable<'a, Message, crate::Renderer>; +} + +pub mod toggler { + //! Show toggle controls using togglers. + pub use iced_native::widget::toggler::{Style, StyleSheet}; + + /// A toggler widget. + pub type Toggler<'a, Message> = + iced_native::widget::Toggler<'a, Message, crate::Renderer>; +} + +pub mod text_input { + //! Display fields that can be filled with text. + //! + //! A [`TextInput`] has some local [`State`]. + use crate::Renderer; + + pub use iced_native::widget::text_input::{State, Style, StyleSheet}; + + /// A field that can be filled with text. + pub type TextInput<'a, Message> = + iced_native::widget::TextInput<'a, Message, Renderer>; +} + +pub mod tooltip { + //! Display a widget over another. + pub use iced_native::widget::tooltip::Position; + + /// A widget allowing the selection of a single value from a list of options. + pub type Tooltip<'a, Message> = + iced_native::widget::Tooltip<'a, Message, crate::Renderer>; +} + +pub use iced_native::widget::progress_bar; +pub use iced_native::widget::rule; +pub use iced_native::widget::slider; +pub use iced_native::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; +pub use tooltip::Tooltip; + +#[cfg(feature = "canvas")] +pub use iced_graphics::widget::canvas; + +#[cfg(feature = "image")] pub mod image { //! Display images in your user interface. - pub use crate::runtime::image::Handle; - pub use crate::runtime::widget::image::viewer; - pub use crate::runtime::widget::image::{Image, Viewer}; + pub use iced_native::image::Handle; + + /// A frame that displays an image. + pub type Image = iced_native::widget::Image<Handle>; + + pub use iced_native::widget::image::viewer; + pub use viewer::Viewer; } -#[cfg_attr(docsrs, doc(cfg(feature = "svg")))] +#[cfg(feature = "qr_code")] +pub use iced_graphics::widget::qr_code; + +#[cfg(feature = "svg")] pub mod svg { - //! Display vector graphics in your user interface. - pub use crate::runtime::svg::Handle; - pub use crate::runtime::widget::svg::Svg; + //! Display vector graphics in your application. + pub use iced_native::svg::Handle; + pub use iced_native::widget::Svg; } -#[doc(no_inline)] -pub use { - button::Button, checkbox::Checkbox, container::Container, image::Image, - pane_grid::PaneGrid, pick_list::PickList, progress_bar::ProgressBar, - radio::Radio, rule::Rule, scrollable::Scrollable, slider::Slider, svg::Svg, - text_input::TextInput, toggler::Toggler, tooltip::Tooltip, -}; - -#[cfg(any(feature = "canvas", feature = "glow_canvas"))] -#[doc(no_inline)] +#[cfg(feature = "canvas")] pub use canvas::Canvas; -#[cfg(any(feature = "qr_code", feature = "glow_qr_code"))] -#[doc(no_inline)] +#[cfg(feature = "image")] +pub use image::Image; + +#[cfg(feature = "qr_code")] pub use qr_code::QRCode; + +#[cfg(feature = "svg")] +pub use svg::Svg; |