Merge branch 'master' into explicit-text-caching
This commit is contained in:
commit
b8e5693a30
178 changed files with 1768 additions and 1388 deletions
|
|
@ -1,14 +1,18 @@
|
|||
[package]
|
||||
name = "iced_widget"
|
||||
version = "0.1.3"
|
||||
authors = ["Héctor Ramón Jiménez <hector0193@gmail.com>"]
|
||||
edition = "2021"
|
||||
description = "The built-in widgets for Iced"
|
||||
license = "MIT"
|
||||
repository = "https://github.com/iced-rs/iced"
|
||||
documentation = "https://docs.rs/iced_widget"
|
||||
keywords = ["gui", "ui", "graphics", "interface", "widgets"]
|
||||
categories = ["gui"]
|
||||
description = "The built-in widgets for iced"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
authors.workspace = true
|
||||
license.workspace = true
|
||||
repository.workspace = true
|
||||
homepage.workspace = true
|
||||
categories.workspace = true
|
||||
keywords.workspace = true
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
rustdoc-args = ["--cfg", "docsrs"]
|
||||
all-features = true
|
||||
|
||||
[features]
|
||||
lazy = ["ouroboros"]
|
||||
|
|
@ -18,31 +22,16 @@ canvas = ["iced_renderer/geometry"]
|
|||
qr_code = ["canvas", "qrcode"]
|
||||
|
||||
[dependencies]
|
||||
unicode-segmentation = "1.6"
|
||||
num-traits = "0.2"
|
||||
thiserror = "1"
|
||||
iced_renderer.workspace = true
|
||||
iced_runtime.workspace = true
|
||||
iced_style.workspace = true
|
||||
|
||||
[dependencies.iced_runtime]
|
||||
version = "0.1"
|
||||
path = "../runtime"
|
||||
num-traits.workspace = true
|
||||
thiserror.workspace = true
|
||||
unicode-segmentation.workspace = true
|
||||
|
||||
[dependencies.iced_renderer]
|
||||
version = "0.1"
|
||||
path = "../renderer"
|
||||
ouroboros.workspace = true
|
||||
ouroboros.optional = true
|
||||
|
||||
[dependencies.iced_style]
|
||||
version = "0.9"
|
||||
path = "../style"
|
||||
|
||||
[dependencies.ouroboros]
|
||||
version = "0.17"
|
||||
optional = true
|
||||
|
||||
[dependencies.qrcode]
|
||||
version = "0.12"
|
||||
optional = true
|
||||
default-features = false
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
rustdoc-args = ["--cfg", "docsrs"]
|
||||
all-features = true
|
||||
qrcode.workspace = true
|
||||
qrcode.optional = true
|
||||
|
|
|
|||
|
|
@ -119,9 +119,9 @@ where
|
|||
/// Sets the style variant of this [`Button`].
|
||||
pub fn style(
|
||||
mut self,
|
||||
style: <Renderer::Theme as StyleSheet>::Style,
|
||||
style: impl Into<<Renderer::Theme as StyleSheet>::Style>,
|
||||
) -> Self {
|
||||
self.style = style;
|
||||
self.style = style.into();
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ pub use crate::core::event::Status;
|
|||
|
||||
/// A [`Canvas`] event.
|
||||
///
|
||||
/// [`Canvas`]: crate::widget::Canvas
|
||||
/// [`Canvas`]: crate::Canvas
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub enum Event {
|
||||
/// A mouse event.
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use crate::graphics::geometry;
|
|||
/// A [`Program`] can mutate internal state and produce messages for an
|
||||
/// application.
|
||||
///
|
||||
/// [`Canvas`]: crate::widget::Canvas
|
||||
/// [`Canvas`]: crate::Canvas
|
||||
pub trait Program<Message, Renderer = crate::Renderer>
|
||||
where
|
||||
Renderer: geometry::Renderer,
|
||||
|
|
@ -26,7 +26,7 @@ where
|
|||
///
|
||||
/// By default, this method does and returns nothing.
|
||||
///
|
||||
/// [`Canvas`]: crate::widget::Canvas
|
||||
/// [`Canvas`]: crate::Canvas
|
||||
fn update(
|
||||
&self,
|
||||
_state: &mut Self::State,
|
||||
|
|
@ -42,8 +42,9 @@ where
|
|||
/// [`Geometry`] can be easily generated with a [`Frame`] or stored in a
|
||||
/// [`Cache`].
|
||||
///
|
||||
/// [`Frame`]: crate::widget::canvas::Frame
|
||||
/// [`Cache`]: crate::widget::canvas::Cache
|
||||
/// [`Geometry`]: crate::canvas::Geometry
|
||||
/// [`Frame`]: crate::canvas::Frame
|
||||
/// [`Cache`]: crate::canvas::Cache
|
||||
fn draw(
|
||||
&self,
|
||||
state: &Self::State,
|
||||
|
|
@ -58,7 +59,7 @@ where
|
|||
/// The interaction returned will be in effect even if the cursor position
|
||||
/// is out of bounds of the program's [`Canvas`].
|
||||
///
|
||||
/// [`Canvas`]: crate::widget::Canvas
|
||||
/// [`Canvas`]: crate::Canvas
|
||||
fn mouse_interaction(
|
||||
&self,
|
||||
_state: &Self::State,
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ where
|
|||
self
|
||||
}
|
||||
|
||||
/// Sets the text [`LineHeight`] of the [`Checkbox`].
|
||||
/// Sets the text [`text::LineHeight`] of the [`Checkbox`].
|
||||
pub fn text_line_height(
|
||||
mut self,
|
||||
line_height: impl Into<text::LineHeight>,
|
||||
|
|
@ -136,9 +136,9 @@ where
|
|||
self
|
||||
}
|
||||
|
||||
/// Sets the [`Font`] of the text of the [`Checkbox`].
|
||||
/// Sets the [`Renderer::Font`] of the text of the [`Checkbox`].
|
||||
///
|
||||
/// [`Font`]: crate::text::Renderer::Font
|
||||
/// [`Renderer::Font`]: crate::core::text::Renderer
|
||||
pub fn font(mut self, font: impl Into<Renderer::Font>) -> Self {
|
||||
self.font = Some(font.into());
|
||||
self
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ use std::time::Instant;
|
|||
///
|
||||
/// This widget is composed by a [`TextInput`] that can be filled with the text
|
||||
/// to search for corresponding values from the list of options that are displayed
|
||||
/// as a [`Menu`].
|
||||
/// as a Menu.
|
||||
#[allow(missing_debug_implementations)]
|
||||
pub struct ComboBox<'a, T, Message, Renderer = crate::Renderer>
|
||||
where
|
||||
|
|
@ -131,14 +131,16 @@ where
|
|||
self
|
||||
}
|
||||
|
||||
/// Sets the [`Font`] of the [`ComboBox`].
|
||||
/// Sets the [`Renderer::Font`] of the [`ComboBox`].
|
||||
///
|
||||
/// [`Renderer::Font`]: text::Renderer
|
||||
pub fn font(mut self, font: Renderer::Font) -> Self {
|
||||
self.text_input = self.text_input.font(font);
|
||||
self.font = Some(font);
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the [`Icon`] of the [`ComboBox`].
|
||||
/// Sets the [`text_input::Icon`] of the [`ComboBox`].
|
||||
pub fn icon(mut self, icon: text_input::Icon<Renderer::Font>) -> Self {
|
||||
self.text_input = self.text_input.icon(icon);
|
||||
self
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ use std::ops::RangeInclusive;
|
|||
|
||||
/// Creates a [`Column`] with the given children.
|
||||
///
|
||||
/// [`Column`]: widget::Column
|
||||
/// [`Column`]: crate::Column
|
||||
#[macro_export]
|
||||
macro_rules! column {
|
||||
() => (
|
||||
|
|
@ -39,7 +39,7 @@ macro_rules! column {
|
|||
|
||||
/// Creates a [`Row`] with the given children.
|
||||
///
|
||||
/// [`Row`]: widget::Row
|
||||
/// [`Row`]: crate::Row
|
||||
#[macro_export]
|
||||
macro_rules! row {
|
||||
() => (
|
||||
|
|
@ -52,7 +52,7 @@ macro_rules! row {
|
|||
|
||||
/// Creates a new [`Container`] with the provided content.
|
||||
///
|
||||
/// [`Container`]: widget::Container
|
||||
/// [`Container`]: crate::Container
|
||||
pub fn container<'a, Message, Renderer>(
|
||||
content: impl Into<Element<'a, Message, Renderer>>,
|
||||
) -> Container<'a, Message, Renderer>
|
||||
|
|
@ -82,7 +82,7 @@ where
|
|||
|
||||
/// Creates a new [`Row`] with the given children.
|
||||
///
|
||||
/// [`Row`]: widget::Row
|
||||
/// [`Row`]: crate::Row
|
||||
pub fn row<Message, Renderer>(
|
||||
children: Vec<Element<'_, Message, Renderer>>,
|
||||
) -> Row<'_, Message, Renderer> {
|
||||
|
|
@ -91,7 +91,7 @@ pub fn row<Message, Renderer>(
|
|||
|
||||
/// Creates a new [`Scrollable`] with the provided content.
|
||||
///
|
||||
/// [`Scrollable`]: widget::Scrollable
|
||||
/// [`Scrollable`]: crate::Scrollable
|
||||
pub fn scrollable<'a, Message, Renderer>(
|
||||
content: impl Into<Element<'a, Message, Renderer>>,
|
||||
) -> Scrollable<'a, Message, Renderer>
|
||||
|
|
@ -104,7 +104,7 @@ where
|
|||
|
||||
/// Creates a new [`Button`] with the provided content.
|
||||
///
|
||||
/// [`Button`]: widget::Button
|
||||
/// [`Button`]: crate::Button
|
||||
pub fn button<'a, Message, Renderer>(
|
||||
content: impl Into<Element<'a, Message, Renderer>>,
|
||||
) -> Button<'a, Message, Renderer>
|
||||
|
|
@ -118,8 +118,8 @@ where
|
|||
|
||||
/// Creates a new [`Tooltip`] with the provided content, tooltip text, and [`tooltip::Position`].
|
||||
///
|
||||
/// [`Tooltip`]: widget::Tooltip
|
||||
/// [`tooltip::Position`]: widget::tooltip::Position
|
||||
/// [`Tooltip`]: crate::Tooltip
|
||||
/// [`tooltip::Position`]: crate::tooltip::Position
|
||||
pub fn tooltip<'a, Message, Renderer>(
|
||||
content: impl Into<Element<'a, Message, Renderer>>,
|
||||
tooltip: impl ToString,
|
||||
|
|
@ -134,7 +134,7 @@ where
|
|||
|
||||
/// Creates a new [`Text`] widget with the provided content.
|
||||
///
|
||||
/// [`Text`]: widget::Text
|
||||
/// [`Text`]: core::widget::Text
|
||||
pub fn text<'a, Renderer>(text: impl ToString) -> Text<'a, Renderer>
|
||||
where
|
||||
Renderer: core::text::Renderer,
|
||||
|
|
@ -145,7 +145,7 @@ where
|
|||
|
||||
/// Creates a new [`Checkbox`].
|
||||
///
|
||||
/// [`Checkbox`]: widget::Checkbox
|
||||
/// [`Checkbox`]: crate::Checkbox
|
||||
pub fn checkbox<'a, Message, Renderer>(
|
||||
label: impl Into<String>,
|
||||
is_checked: bool,
|
||||
|
|
@ -160,7 +160,7 @@ where
|
|||
|
||||
/// Creates a new [`Radio`].
|
||||
///
|
||||
/// [`Radio`]: widget::Radio
|
||||
/// [`Radio`]: crate::Radio
|
||||
pub fn radio<Message, Renderer, V>(
|
||||
label: impl Into<String>,
|
||||
value: V,
|
||||
|
|
@ -178,7 +178,7 @@ where
|
|||
|
||||
/// Creates a new [`Toggler`].
|
||||
///
|
||||
/// [`Toggler`]: widget::Toggler
|
||||
/// [`Toggler`]: crate::Toggler
|
||||
pub fn toggler<'a, Message, Renderer>(
|
||||
label: impl Into<Option<String>>,
|
||||
is_checked: bool,
|
||||
|
|
@ -193,7 +193,7 @@ where
|
|||
|
||||
/// Creates a new [`TextInput`].
|
||||
///
|
||||
/// [`TextInput`]: widget::TextInput
|
||||
/// [`TextInput`]: crate::TextInput
|
||||
pub fn text_input<'a, Message, Renderer>(
|
||||
placeholder: &str,
|
||||
value: &str,
|
||||
|
|
@ -208,7 +208,7 @@ where
|
|||
|
||||
/// Creates a new [`Slider`].
|
||||
///
|
||||
/// [`Slider`]: widget::Slider
|
||||
/// [`Slider`]: crate::Slider
|
||||
pub fn slider<'a, T, Message, Renderer>(
|
||||
range: std::ops::RangeInclusive<T>,
|
||||
value: T,
|
||||
|
|
@ -225,7 +225,7 @@ where
|
|||
|
||||
/// Creates a new [`VerticalSlider`].
|
||||
///
|
||||
/// [`VerticalSlider`]: widget::VerticalSlider
|
||||
/// [`VerticalSlider`]: crate::VerticalSlider
|
||||
pub fn vertical_slider<'a, T, Message, Renderer>(
|
||||
range: std::ops::RangeInclusive<T>,
|
||||
value: T,
|
||||
|
|
@ -242,7 +242,7 @@ where
|
|||
|
||||
/// Creates a new [`PickList`].
|
||||
///
|
||||
/// [`PickList`]: widget::PickList
|
||||
/// [`PickList`]: crate::PickList
|
||||
pub fn pick_list<'a, Message, Renderer, T>(
|
||||
options: impl Into<Cow<'a, [T]>>,
|
||||
selected: Option<T>,
|
||||
|
|
@ -264,7 +264,7 @@ where
|
|||
|
||||
/// Creates a new [`ComboBox`].
|
||||
///
|
||||
/// [`ComboBox`]: widget::ComboBox
|
||||
/// [`ComboBox`]: crate::ComboBox
|
||||
pub fn combo_box<'a, T, Message, Renderer>(
|
||||
state: &'a combo_box::State<T>,
|
||||
placeholder: &str,
|
||||
|
|
@ -281,21 +281,21 @@ where
|
|||
|
||||
/// Creates a new horizontal [`Space`] with the given [`Length`].
|
||||
///
|
||||
/// [`Space`]: widget::Space
|
||||
/// [`Space`]: crate::Space
|
||||
pub fn horizontal_space(width: impl Into<Length>) -> Space {
|
||||
Space::with_width(width)
|
||||
}
|
||||
|
||||
/// Creates a new vertical [`Space`] with the given [`Length`].
|
||||
///
|
||||
/// [`Space`]: widget::Space
|
||||
/// [`Space`]: crate::Space
|
||||
pub fn vertical_space(height: impl Into<Length>) -> Space {
|
||||
Space::with_height(height)
|
||||
}
|
||||
|
||||
/// Creates a horizontal [`Rule`] with the given height.
|
||||
///
|
||||
/// [`Rule`]: widget::Rule
|
||||
/// [`Rule`]: crate::Rule
|
||||
pub fn horizontal_rule<Renderer>(height: impl Into<Pixels>) -> Rule<Renderer>
|
||||
where
|
||||
Renderer: core::Renderer,
|
||||
|
|
@ -306,7 +306,7 @@ where
|
|||
|
||||
/// Creates a vertical [`Rule`] with the given width.
|
||||
///
|
||||
/// [`Rule`]: widget::Rule
|
||||
/// [`Rule`]: crate::Rule
|
||||
pub fn vertical_rule<Renderer>(width: impl Into<Pixels>) -> Rule<Renderer>
|
||||
where
|
||||
Renderer: core::Renderer,
|
||||
|
|
@ -321,7 +321,7 @@ where
|
|||
/// * an inclusive range of possible values, and
|
||||
/// * the current value of the [`ProgressBar`].
|
||||
///
|
||||
/// [`ProgressBar`]: widget::ProgressBar
|
||||
/// [`ProgressBar`]: crate::ProgressBar
|
||||
pub fn progress_bar<Renderer>(
|
||||
range: RangeInclusive<f32>,
|
||||
value: f32,
|
||||
|
|
@ -335,7 +335,7 @@ where
|
|||
|
||||
/// Creates a new [`Image`].
|
||||
///
|
||||
/// [`Image`]: widget::Image
|
||||
/// [`Image`]: crate::Image
|
||||
#[cfg(feature = "image")]
|
||||
pub fn image<Handle>(handle: impl Into<Handle>) -> crate::Image<Handle> {
|
||||
crate::Image::new(handle.into())
|
||||
|
|
@ -343,8 +343,8 @@ pub fn image<Handle>(handle: impl Into<Handle>) -> crate::Image<Handle> {
|
|||
|
||||
/// Creates a new [`Svg`] widget from the given [`Handle`].
|
||||
///
|
||||
/// [`Svg`]: widget::Svg
|
||||
/// [`Handle`]: widget::svg::Handle
|
||||
/// [`Svg`]: crate::Svg
|
||||
/// [`Handle`]: crate::svg::Handle
|
||||
#[cfg(feature = "svg")]
|
||||
pub fn svg<Renderer>(
|
||||
handle: impl Into<core::svg::Handle>,
|
||||
|
|
@ -357,6 +357,8 @@ where
|
|||
}
|
||||
|
||||
/// Creates a new [`Canvas`].
|
||||
///
|
||||
/// [`Canvas`]: crate::Canvas
|
||||
#[cfg(feature = "canvas")]
|
||||
pub fn canvas<P, Message, Renderer>(
|
||||
program: P,
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#![doc(
|
||||
html_logo_url = "https://raw.githubusercontent.com/iced-rs/iced/9ab6923e943f784985e9ef9ca28b10278297225d/docs/logo.svg"
|
||||
)]
|
||||
#![forbid(unsafe_code, rust_2018_idioms)]
|
||||
#![deny(
|
||||
missing_debug_implementations,
|
||||
missing_docs,
|
||||
|
|
@ -10,9 +11,9 @@
|
|||
clippy::from_over_into,
|
||||
clippy::needless_borrow,
|
||||
clippy::new_without_default,
|
||||
clippy::useless_conversion
|
||||
clippy::useless_conversion,
|
||||
rustdoc::broken_intra_doc_links
|
||||
)]
|
||||
#![forbid(unsafe_code, rust_2018_idioms)]
|
||||
#![allow(clippy::inherent_to_string, clippy::type_complexity)]
|
||||
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
|
||||
pub use iced_renderer as renderer;
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ where
|
|||
self
|
||||
}
|
||||
|
||||
/// Sets the text [`LineHeight`] of the [`Menu`].
|
||||
/// Sets the text [`text::LineHeight`] of the [`Menu`].
|
||||
pub fn text_line_height(
|
||||
mut self,
|
||||
line_height: impl Into<text::LineHeight>,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//! 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,
|
||||
|
|
@ -49,7 +49,7 @@ use crate::core::{
|
|||
/// A collection of panes distributed using either vertical or horizontal splits
|
||||
/// to completely fill the space available.
|
||||
///
|
||||
/// [](https://gfycat.com/frailfreshairedaleterrier)
|
||||
/// 
|
||||
///
|
||||
/// This distribution of space is common in tiling window managers (like
|
||||
/// [`awesome`](https://awesomewm.org/), [`i3`](https://i3wm.org/), or even
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use crate::pane_grid::Axis;
|
|||
|
||||
/// The arrangement of a [`PaneGrid`].
|
||||
///
|
||||
/// [`PaneGrid`]: crate::widget::PaneGrid
|
||||
/// [`PaneGrid`]: super::PaneGrid
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum Configuration<T> {
|
||||
/// A split of the available space.
|
||||
|
|
@ -21,6 +21,6 @@ pub enum Configuration<T> {
|
|||
},
|
||||
/// A [`Pane`].
|
||||
///
|
||||
/// [`Pane`]: crate::widget::pane_grid::Pane
|
||||
/// [`Pane`]: super::Pane
|
||||
Pane(T),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use crate::pane_grid::{Draggable, TitleBar};
|
|||
|
||||
/// The content of a [`Pane`].
|
||||
///
|
||||
/// [`Pane`]: crate::widget::pane_grid::Pane
|
||||
/// [`Pane`]: super::Pane
|
||||
#[allow(missing_debug_implementations)]
|
||||
pub struct Content<'a, Message, Renderer = crate::Renderer>
|
||||
where
|
||||
|
|
@ -87,7 +87,7 @@ where
|
|||
|
||||
/// Draws the [`Content`] with the provided [`Renderer`] and [`Layout`].
|
||||
///
|
||||
/// [`Renderer`]: crate::Renderer
|
||||
/// [`Renderer`]: crate::core::Renderer
|
||||
pub fn draw(
|
||||
&self,
|
||||
tree: &Tree,
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use std::collections::BTreeMap;
|
|||
|
||||
/// A layout node of a [`PaneGrid`].
|
||||
///
|
||||
/// [`PaneGrid`]: crate::widget::PaneGrid
|
||||
/// [`PaneGrid`]: super::PaneGrid
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum Node {
|
||||
/// The region of this [`Node`] is split into two.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/// A rectangular region in a [`PaneGrid`] used to display widgets.
|
||||
///
|
||||
/// [`PaneGrid`]: crate::widget::PaneGrid
|
||||
/// [`PaneGrid`]: super::PaneGrid
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub struct Pane(pub(super) usize);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/// A divider that splits a region in a [`PaneGrid`] into two different panes.
|
||||
///
|
||||
/// [`PaneGrid`]: crate::widget::PaneGrid
|
||||
/// [`PaneGrid`]: super::PaneGrid
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub struct Split(pub(super) usize);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//! The state of a [`PaneGrid`].
|
||||
//!
|
||||
//! [`PaneGrid`]: crate::widget::PaneGrid
|
||||
//! [`PaneGrid`]: super::PaneGrid
|
||||
use crate::core::{Point, Size};
|
||||
use crate::pane_grid::{
|
||||
Axis, Configuration, Direction, Edge, Node, Pane, Region, Split, Target,
|
||||
|
|
@ -18,23 +18,23 @@ use std::collections::HashMap;
|
|||
/// provided to the view function of [`PaneGrid::new`] for displaying each
|
||||
/// [`Pane`].
|
||||
///
|
||||
/// [`PaneGrid`]: crate::widget::PaneGrid
|
||||
/// [`PaneGrid::new`]: crate::widget::PaneGrid::new
|
||||
/// [`PaneGrid`]: super::PaneGrid
|
||||
/// [`PaneGrid::new`]: super::PaneGrid::new
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct State<T> {
|
||||
/// The panes of the [`PaneGrid`].
|
||||
///
|
||||
/// [`PaneGrid`]: crate::widget::PaneGrid
|
||||
/// [`PaneGrid`]: super::PaneGrid
|
||||
pub panes: HashMap<Pane, T>,
|
||||
|
||||
/// The internal state of the [`PaneGrid`].
|
||||
///
|
||||
/// [`PaneGrid`]: crate::widget::PaneGrid
|
||||
/// [`PaneGrid`]: super::PaneGrid
|
||||
pub internal: Internal,
|
||||
|
||||
/// The maximized [`Pane`] of the [`PaneGrid`].
|
||||
///
|
||||
/// [`PaneGrid`]: crate::widget::PaneGrid
|
||||
/// [`PaneGrid`]: super::PaneGrid
|
||||
pub(super) maximized: Option<Pane>,
|
||||
}
|
||||
|
||||
|
|
@ -236,6 +236,8 @@ impl<T> State<T> {
|
|||
}
|
||||
|
||||
/// Move [`Pane`] to an [`Edge`] of the [`PaneGrid`].
|
||||
///
|
||||
/// [`PaneGrid`]: super::PaneGrid
|
||||
pub fn move_to_edge(&mut self, pane: &Pane, edge: Edge) {
|
||||
match edge {
|
||||
Edge::Top => {
|
||||
|
|
@ -269,8 +271,8 @@ impl<T> State<T> {
|
|||
/// If you want to swap panes on drag and drop in your [`PaneGrid`], you
|
||||
/// will need to call this method when handling a [`DragEvent`].
|
||||
///
|
||||
/// [`PaneGrid`]: crate::widget::PaneGrid
|
||||
/// [`DragEvent`]: crate::widget::pane_grid::DragEvent
|
||||
/// [`PaneGrid`]: super::PaneGrid
|
||||
/// [`DragEvent`]: super::DragEvent
|
||||
pub fn swap(&mut self, a: &Pane, b: &Pane) {
|
||||
self.internal.layout.update(&|node| match node {
|
||||
Node::Split { .. } => {}
|
||||
|
|
@ -292,8 +294,8 @@ impl<T> State<T> {
|
|||
/// If you want to enable resize interactions in your [`PaneGrid`], you will
|
||||
/// need to call this method when handling a [`ResizeEvent`].
|
||||
///
|
||||
/// [`PaneGrid`]: crate::widget::PaneGrid
|
||||
/// [`ResizeEvent`]: crate::widget::pane_grid::ResizeEvent
|
||||
/// [`PaneGrid`]: super::PaneGrid
|
||||
/// [`ResizeEvent`]: super::ResizeEvent
|
||||
pub fn resize(&mut self, split: &Split, ratio: f32) {
|
||||
let _ = self.internal.layout.resize(split, ratio);
|
||||
}
|
||||
|
|
@ -315,7 +317,7 @@ impl<T> State<T> {
|
|||
/// Maximize the given [`Pane`]. Only this pane will be rendered by the
|
||||
/// [`PaneGrid`] until [`Self::restore()`] is called.
|
||||
///
|
||||
/// [`PaneGrid`]: crate::widget::PaneGrid
|
||||
/// [`PaneGrid`]: super::PaneGrid
|
||||
pub fn maximize(&mut self, pane: &Pane) {
|
||||
self.maximized = Some(*pane);
|
||||
}
|
||||
|
|
@ -323,14 +325,14 @@ impl<T> State<T> {
|
|||
/// Restore the currently maximized [`Pane`] to it's normal size. All panes
|
||||
/// will be rendered by the [`PaneGrid`].
|
||||
///
|
||||
/// [`PaneGrid`]: crate::widget::PaneGrid
|
||||
/// [`PaneGrid`]: super::PaneGrid
|
||||
pub fn restore(&mut self) {
|
||||
let _ = self.maximized.take();
|
||||
}
|
||||
|
||||
/// Returns the maximized [`Pane`] of the [`PaneGrid`].
|
||||
///
|
||||
/// [`PaneGrid`]: crate::widget::PaneGrid
|
||||
/// [`PaneGrid`]: super::PaneGrid
|
||||
pub fn maximized(&self) -> Option<Pane> {
|
||||
self.maximized
|
||||
}
|
||||
|
|
@ -338,7 +340,7 @@ impl<T> State<T> {
|
|||
|
||||
/// The internal state of a [`PaneGrid`].
|
||||
///
|
||||
/// [`PaneGrid`]: crate::widget::PaneGrid
|
||||
/// [`PaneGrid`]: super::PaneGrid
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Internal {
|
||||
layout: Node,
|
||||
|
|
@ -349,7 +351,7 @@ impl Internal {
|
|||
/// Initializes the [`Internal`] state of a [`PaneGrid`] from a
|
||||
/// [`Configuration`].
|
||||
///
|
||||
/// [`PaneGrid`]: crate::widget::PaneGrid
|
||||
/// [`PaneGrid`]: super::PaneGrid
|
||||
pub fn from_configuration<T>(
|
||||
panes: &mut HashMap<Pane, T>,
|
||||
content: Configuration<T>,
|
||||
|
|
@ -394,16 +396,16 @@ impl Internal {
|
|||
|
||||
/// The current action of a [`PaneGrid`].
|
||||
///
|
||||
/// [`PaneGrid`]: crate::widget::PaneGrid
|
||||
/// [`PaneGrid`]: super::PaneGrid
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub enum Action {
|
||||
/// The [`PaneGrid`] is idle.
|
||||
///
|
||||
/// [`PaneGrid`]: crate::widget::PaneGrid
|
||||
/// [`PaneGrid`]: super::PaneGrid
|
||||
Idle,
|
||||
/// A [`Pane`] in the [`PaneGrid`] is being dragged.
|
||||
///
|
||||
/// [`PaneGrid`]: crate::widget::PaneGrid
|
||||
/// [`PaneGrid`]: super::PaneGrid
|
||||
Dragging {
|
||||
/// The [`Pane`] being dragged.
|
||||
pane: Pane,
|
||||
|
|
@ -412,7 +414,7 @@ pub enum Action {
|
|||
},
|
||||
/// A [`Split`] in the [`PaneGrid`] is being dragged.
|
||||
///
|
||||
/// [`PaneGrid`]: crate::widget::PaneGrid
|
||||
/// [`PaneGrid`]: super::PaneGrid
|
||||
Resizing {
|
||||
/// The [`Split`] being dragged.
|
||||
split: Split,
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ use crate::core::{
|
|||
|
||||
/// The title bar of a [`Pane`].
|
||||
///
|
||||
/// [`Pane`]: crate::widget::pane_grid::Pane
|
||||
/// [`Pane`]: super::Pane
|
||||
#[allow(missing_debug_implementations)]
|
||||
pub struct TitleBar<'a, Message, Renderer = crate::Renderer>
|
||||
where
|
||||
|
|
@ -75,7 +75,7 @@ where
|
|||
/// [`TitleBar`] is hovered.
|
||||
///
|
||||
/// [`controls`]: Self::controls
|
||||
/// [`Pane`]: crate::widget::pane_grid::Pane
|
||||
/// [`Pane`]: super::Pane
|
||||
pub fn always_show_controls(mut self) -> Self {
|
||||
self.always_show_controls = true;
|
||||
self
|
||||
|
|
@ -114,7 +114,7 @@ where
|
|||
|
||||
/// Draws the [`TitleBar`] with the provided [`Renderer`] and [`Layout`].
|
||||
///
|
||||
/// [`Renderer`]: crate::Renderer
|
||||
/// [`Renderer`]: crate::core::Renderer
|
||||
pub fn draw(
|
||||
&self,
|
||||
tree: &Tree,
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ where
|
|||
self
|
||||
}
|
||||
|
||||
/// Sets the text [`LineHeight`] of the [`PickList`].
|
||||
/// Sets the text [`text::LineHeight`] of the [`PickList`].
|
||||
pub fn text_line_height(
|
||||
mut self,
|
||||
line_height: impl Into<text::LineHeight>,
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ impl<'a, Message, Theme> Widget<Message, Renderer<Theme>> for QRCode<'a> {
|
|||
let geometry =
|
||||
self.state.cache.draw(renderer, bounds.size(), |frame| {
|
||||
// Scale units to cell size
|
||||
frame.scale(f32::from(self.cell_size));
|
||||
frame.scale(self.cell_size);
|
||||
|
||||
// Draw background
|
||||
frame.fill_rectangle(
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ where
|
|||
self
|
||||
}
|
||||
|
||||
/// Sets the text [`LineHeight`] of the [`Radio`] button.
|
||||
/// Sets the text [`text::LineHeight`] of the [`Radio`] button.
|
||||
pub fn text_line_height(
|
||||
mut self,
|
||||
line_height: impl Into<text::LineHeight>,
|
||||
|
|
|
|||
|
|
@ -1151,6 +1151,16 @@ impl Viewport {
|
|||
|
||||
RelativeOffset { x, y }
|
||||
}
|
||||
|
||||
/// Returns the bounds of the current [`Viewport`].
|
||||
pub fn bounds(&self) -> Rectangle {
|
||||
self.bounds
|
||||
}
|
||||
|
||||
/// Returns the content bounds of the current [`Viewport`].
|
||||
pub fn content_bounds(&self) -> Rectangle {
|
||||
self.content_bounds
|
||||
}
|
||||
}
|
||||
|
||||
impl State {
|
||||
|
|
|
|||
|
|
@ -137,8 +137,8 @@ where
|
|||
}
|
||||
|
||||
/// Sets the step size of the [`Slider`].
|
||||
pub fn step(mut self, step: T) -> Self {
|
||||
self.step = step;
|
||||
pub fn step(mut self, step: impl Into<T>) -> Self {
|
||||
self.step = step.into();
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@ where
|
|||
self
|
||||
}
|
||||
|
||||
/// Sets the [`LineHeight`] of the [`TextInput`].
|
||||
/// Sets the [`text::LineHeight`] of the [`TextInput`].
|
||||
pub fn line_height(
|
||||
mut self,
|
||||
line_height: impl Into<text::LineHeight>,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use unicode_segmentation::UnicodeSegmentation;
|
|||
|
||||
/// The value of a [`TextInput`].
|
||||
///
|
||||
/// [`TextInput`]: crate::widget::TextInput
|
||||
/// [`TextInput`]: super::TextInput
|
||||
// TODO: Reduce allocations, cache results (?)
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Value {
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ where
|
|||
self
|
||||
}
|
||||
|
||||
/// Sets the text [`LineHeight`] of the [`Toggler`].
|
||||
/// Sets the text [`text::LineHeight`] of the [`Toggler`].
|
||||
pub fn text_line_height(
|
||||
mut self,
|
||||
line_height: impl Into<text::LineHeight>,
|
||||
|
|
@ -136,9 +136,9 @@ where
|
|||
self
|
||||
}
|
||||
|
||||
/// Sets the [`Font`] of the text of the [`Toggler`]
|
||||
/// Sets the [`Renderer::Font`] of the text of the [`Toggler`]
|
||||
///
|
||||
/// [`Font`]: crate::text::Renderer::Font
|
||||
/// [`Renderer::Font`]: crate::core::text::Renderer
|
||||
pub fn font(mut self, font: impl Into<Renderer::Font>) -> Self {
|
||||
self.font = Some(font.into());
|
||||
self
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue