summaryrefslogtreecommitdiffstats
path: root/widget/src
diff options
context:
space:
mode:
Diffstat (limited to 'widget/src')
-rw-r--r--widget/src/button.rs4
-rw-r--r--widget/src/checkbox.rs4
-rw-r--r--widget/src/column.rs19
-rw-r--r--widget/src/combo_box.rs4
-rw-r--r--widget/src/markdown.rs4
-rw-r--r--widget/src/qr_code.rs24
-rw-r--r--widget/src/row.rs19
-rw-r--r--widget/src/text/rich.rs2
8 files changed, 41 insertions, 39 deletions
diff --git a/widget/src/button.rs b/widget/src/button.rs
index 3323c0d3..552298bb 100644
--- a/widget/src/button.rs
+++ b/widget/src/button.rs
@@ -477,9 +477,9 @@ pub struct Style {
pub background: Option<Background>,
/// The text [`Color`] of the button.
pub text_color: Color,
- /// The [`Border`] of the buton.
+ /// The [`Border`] of the button.
pub border: Border,
- /// The [`Shadow`] of the butoon.
+ /// The [`Shadow`] of the button.
pub shadow: Shadow,
}
diff --git a/widget/src/checkbox.rs b/widget/src/checkbox.rs
index 4a3f35ed..4b2f6075 100644
--- a/widget/src/checkbox.rs
+++ b/widget/src/checkbox.rs
@@ -487,7 +487,7 @@ pub struct Style {
pub background: Background,
/// The icon [`Color`] of the checkbox.
pub icon_color: Color,
- /// The [`Border`] of hte checkbox.
+ /// The [`Border`] of the checkbox.
pub border: Border,
/// The text [`Color`] of the checkbox.
pub text_color: Option<Color>,
@@ -600,7 +600,7 @@ pub fn success(theme: &Theme, status: Status) -> Style {
}
}
-/// A danger checkbox; denoting a negaive toggle.
+/// A danger checkbox; denoting a negative toggle.
pub fn danger(theme: &Theme, status: Status) -> Style {
let palette = theme.extended_palette();
diff --git a/widget/src/column.rs b/widget/src/column.rs
index fc4653b9..213f68fc 100644
--- a/widget/src/column.rs
+++ b/widget/src/column.rs
@@ -320,24 +320,21 @@ where
viewport: &Rectangle,
) {
if let Some(clipped_viewport) = layout.bounds().intersection(viewport) {
+ let viewport = if self.clip {
+ &clipped_viewport
+ } else {
+ viewport
+ };
+
for ((child, state), layout) in self
.children
.iter()
.zip(&tree.children)
.zip(layout.children())
+ .filter(|(_, layout)| layout.bounds().intersects(viewport))
{
child.as_widget().draw(
- state,
- renderer,
- theme,
- style,
- layout,
- cursor,
- if self.clip {
- &clipped_viewport
- } else {
- viewport
- },
+ state, renderer, theme, style, layout, cursor, viewport,
);
}
}
diff --git a/widget/src/combo_box.rs b/widget/src/combo_box.rs
index fb661ad5..e300f1d0 100644
--- a/widget/src/combo_box.rs
+++ b/widget/src/combo_box.rs
@@ -608,8 +608,8 @@ where
..
}) = event
{
- let shift_modifer = modifiers.shift();
- match (named_key, shift_modifer) {
+ let shift_modifier = modifiers.shift();
+ match (named_key, shift_modifier) {
(key::Named::Enter, _) => {
if let Some(index) = &menu.hovered_option {
if let Some(option) =
diff --git a/widget/src/markdown.rs b/widget/src/markdown.rs
index 912ef2f5..d6bebb9b 100644
--- a/widget/src/markdown.rs
+++ b/widget/src/markdown.rs
@@ -1,6 +1,6 @@
//! Markdown widgets can parse and display Markdown.
//!
-//! You can enable the `highlighter` feature for syntax highligting
+//! You can enable the `highlighter` feature for syntax highlighting
//! in code blocks.
//!
//! Only the variants of [`Item`] are currently supported.
@@ -72,7 +72,7 @@ pub enum Item {
Paragraph(Text),
/// A code block.
///
- /// You can enable the `highlighter` feature for syntax highligting.
+ /// You can enable the `highlighter` feature for syntax highlighting.
CodeBlock(Text),
/// A list.
List {
diff --git a/widget/src/qr_code.rs b/widget/src/qr_code.rs
index 21dee6b1..d1834465 100644
--- a/widget/src/qr_code.rs
+++ b/widget/src/qr_code.rs
@@ -26,15 +26,15 @@ use crate::core::mouse;
use crate::core::renderer::{self, Renderer as _};
use crate::core::widget::tree::{self, Tree};
use crate::core::{
- Color, Element, Layout, Length, Point, Rectangle, Size, Theme, Vector,
- Widget,
+ Color, Element, Layout, Length, Pixels, Point, Rectangle, Size, Theme,
+ Vector, Widget,
};
use crate::Renderer;
use std::cell::RefCell;
use thiserror::Error;
-const DEFAULT_CELL_SIZE: u16 = 4;
+const DEFAULT_CELL_SIZE: f32 = 4.0;
const QUIET_ZONE: usize = 2;
/// A type of matrix barcode consisting of squares arranged in a grid which
@@ -66,7 +66,7 @@ where
Theme: Catalog,
{
data: &'a Data,
- cell_size: u16,
+ cell_size: f32,
class: Theme::Class<'a>,
}
@@ -84,8 +84,16 @@ where
}
/// Sets the size of the squares of the grid cell of the [`QRCode`].
- pub fn cell_size(mut self, cell_size: u16) -> Self {
- self.cell_size = cell_size;
+ pub fn cell_size(mut self, cell_size: impl Into<Pixels>) -> Self {
+ self.cell_size = cell_size.into().0;
+ self
+ }
+
+ /// Sets the size of the entire [`QRCode`].
+ pub fn total_size(mut self, total_size: impl Into<Pixels>) -> Self {
+ self.cell_size =
+ total_size.into().0 / (self.data.width + 2 * QUIET_ZONE) as f32;
+
self
}
@@ -133,8 +141,8 @@ where
_renderer: &Renderer,
_limits: &layout::Limits,
) -> layout::Node {
- let side_length = (self.data.width + 2 * QUIET_ZONE) as f32
- * f32::from(self.cell_size);
+ let side_length =
+ (self.data.width + 2 * QUIET_ZONE) as f32 * self.cell_size;
layout::Node::new(Size::new(side_length, side_length))
}
diff --git a/widget/src/row.rs b/widget/src/row.rs
index 75d5fb40..9c0fa97e 100644
--- a/widget/src/row.rs
+++ b/widget/src/row.rs
@@ -316,24 +316,21 @@ where
viewport: &Rectangle,
) {
if let Some(clipped_viewport) = layout.bounds().intersection(viewport) {
+ let viewport = if self.clip {
+ &clipped_viewport
+ } else {
+ viewport
+ };
+
for ((child, state), layout) in self
.children
.iter()
.zip(&tree.children)
.zip(layout.children())
+ .filter(|(_, layout)| layout.bounds().intersects(viewport))
{
child.as_widget().draw(
- state,
- renderer,
- theme,
- style,
- layout,
- cursor,
- if self.clip {
- &clipped_viewport
- } else {
- viewport
- },
+ state, renderer, theme, style, layout, cursor, viewport,
);
}
}
diff --git a/widget/src/text/rich.rs b/widget/src/text/rich.rs
index 921c55a5..3d241375 100644
--- a/widget/src/text/rich.rs
+++ b/widget/src/text/rich.rs
@@ -72,7 +72,7 @@ where
self
}
- /// Sets the defualt [`LineHeight`] of the [`Rich`] text.
+ /// Sets the default [`LineHeight`] of the [`Rich`] text.
pub fn line_height(mut self, line_height: impl Into<LineHeight>) -> Self {
self.line_height = line_height.into();
self