summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/src/keyboard/event.rs6
-rw-r--r--core/src/keyboard/key.rs2
-rw-r--r--core/src/keyboard/modifiers.rs2
-rw-r--r--core/src/text.rs4
-rw-r--r--core/src/window/event.rs12
-rw-r--r--examples/loading_spinners/src/circular.rs4
-rw-r--r--examples/qr_code/src/main.rs54
-rw-r--r--graphics/src/compositor.rs2
-rw-r--r--runtime/src/system.rs2
-rw-r--r--runtime/src/window.rs2
-rw-r--r--wgpu/src/geometry.rs2
-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
-rw-r--r--winit/src/conversion.rs2
20 files changed, 115 insertions, 59 deletions
diff --git a/core/src/keyboard/event.rs b/core/src/keyboard/event.rs
index 26c45717..6e483f5b 100644
--- a/core/src/keyboard/event.rs
+++ b/core/src/keyboard/event.rs
@@ -36,6 +36,12 @@ pub enum Event {
/// The key released.
key: Key,
+ /// The key released with all keyboard modifiers applied, except Ctrl.
+ modified_key: Key,
+
+ /// The physical key released.
+ physical_key: key::Physical,
+
/// The location of the key.
location: Location,
diff --git a/core/src/keyboard/key.rs b/core/src/keyboard/key.rs
index 479d999b..69a91902 100644
--- a/core/src/keyboard/key.rs
+++ b/core/src/keyboard/key.rs
@@ -203,7 +203,7 @@ pub enum Named {
Standby,
/// The WakeUp key. (`KEYCODE_WAKEUP`)
WakeUp,
- /// Initate the multi-candidate mode.
+ /// Initiate the multi-candidate mode.
AllCandidates,
Alphanumeric,
/// Initiate the Code Input mode to allow characters to be entered by
diff --git a/core/src/keyboard/modifiers.rs b/core/src/keyboard/modifiers.rs
index edbf6d38..00b31882 100644
--- a/core/src/keyboard/modifiers.rs
+++ b/core/src/keyboard/modifiers.rs
@@ -33,7 +33,7 @@ impl Modifiers {
/// This is normally the main modifier to be used for hotkeys.
///
/// On macOS, this is equivalent to `Self::LOGO`.
- /// Ohterwise, this is equivalent to `Self::CTRL`.
+ /// Otherwise, this is equivalent to `Self::CTRL`.
pub const COMMAND: Self = if cfg!(target_os = "macos") {
Self::LOGO
} else {
diff --git a/core/src/text.rs b/core/src/text.rs
index d7b7fee4..a9e3dce5 100644
--- a/core/src/text.rs
+++ b/core/src/text.rs
@@ -411,13 +411,13 @@ impl<'a, Link, Font> Span<'a, Link, Font> {
self
}
- /// Sets whether the [`Span`] shoud be underlined or not.
+ /// Sets whether the [`Span`] should be underlined or not.
pub fn underline(mut self, underline: bool) -> Self {
self.underline = underline;
self
}
- /// Sets whether the [`Span`] shoud be struck through or not.
+ /// Sets whether the [`Span`] should be struck through or not.
pub fn strikethrough(mut self, strikethrough: bool) -> Self {
self.strikethrough = strikethrough;
self
diff --git a/core/src/window/event.rs b/core/src/window/event.rs
index c9532e0d..4e2751ee 100644
--- a/core/src/window/event.rs
+++ b/core/src/window/event.rs
@@ -46,17 +46,29 @@ pub enum Event {
///
/// When the user hovers multiple files at once, this event will be emitted
/// for each file separately.
+ ///
+ /// ## Platform-specific
+ ///
+ /// - **Wayland:** Not implemented.
FileHovered(PathBuf),
/// A file has been dropped into the window.
///
/// When the user drops multiple files at once, this event will be emitted
/// for each file separately.
+ ///
+ /// ## Platform-specific
+ ///
+ /// - **Wayland:** Not implemented.
FileDropped(PathBuf),
/// A file was hovered, but has exited the window.
///
/// There will be a single `FilesHoveredLeft` event triggered even if
/// multiple files were hovered.
+ ///
+ /// ## Platform-specific
+ ///
+ /// - **Wayland:** Not implemented.
FilesHoveredLeft,
}
diff --git a/examples/loading_spinners/src/circular.rs b/examples/loading_spinners/src/circular.rs
index bf70e190..9239f01f 100644
--- a/examples/loading_spinners/src/circular.rs
+++ b/examples/loading_spinners/src/circular.rs
@@ -139,8 +139,8 @@ impl Animation {
progress: 0.0,
rotation: rotation.wrapping_add(
BASE_ROTATION_SPEED.wrapping_add(
- (f64::from(WRAP_ANGLE / (2.0 * Radians::PI)) * f64::MAX)
- as u32,
+ (f64::from(WRAP_ANGLE / (2.0 * Radians::PI))
+ * u32::MAX as f64) as u32,
),
),
last: now,
diff --git a/examples/qr_code/src/main.rs b/examples/qr_code/src/main.rs
index f1b654e0..2c892e3f 100644
--- a/examples/qr_code/src/main.rs
+++ b/examples/qr_code/src/main.rs
@@ -1,6 +1,10 @@
-use iced::widget::{center, column, pick_list, qr_code, row, text, text_input};
+use iced::widget::{
+ center, column, pick_list, qr_code, row, slider, text, text_input, toggler,
+};
use iced::{Center, Element, Theme};
+use std::ops::RangeInclusive;
+
pub fn main() -> iced::Result {
iced::application(
"QR Code Generator - Iced",
@@ -15,16 +19,21 @@ pub fn main() -> iced::Result {
struct QRGenerator {
data: String,
qr_code: Option<qr_code::Data>,
+ total_size: Option<f32>,
theme: Theme,
}
#[derive(Debug, Clone)]
enum Message {
DataChanged(String),
+ ToggleTotalSize(bool),
+ TotalSizeChanged(f32),
ThemeChanged(Theme),
}
impl QRGenerator {
+ const SIZE_RANGE: RangeInclusive<f32> = 200.0..=400.0;
+
fn update(&mut self, message: Message) {
match message {
Message::DataChanged(mut data) => {
@@ -38,6 +47,16 @@ impl QRGenerator {
self.data = data;
}
+ Message::ToggleTotalSize(enabled) => {
+ self.total_size = enabled.then_some(
+ Self::SIZE_RANGE.start()
+ + (Self::SIZE_RANGE.end() - Self::SIZE_RANGE.start())
+ / 2.0,
+ );
+ }
+ Message::TotalSizeChanged(total_size) => {
+ self.total_size = Some(total_size);
+ }
Message::ThemeChanged(theme) => {
self.theme = theme;
}
@@ -53,6 +72,10 @@ impl QRGenerator {
.size(30)
.padding(15);
+ let toggle_total_size = toggler(self.total_size.is_some())
+ .on_toggle(Message::ToggleTotalSize)
+ .label("Limit Total Size");
+
let choose_theme = row![
text("Theme:"),
pick_list(Theme::ALL, Some(&self.theme), Message::ThemeChanged,)
@@ -60,15 +83,26 @@ impl QRGenerator {
.spacing(10)
.align_y(Center);
- let content = column![title, input, choose_theme]
- .push_maybe(
- self.qr_code
- .as_ref()
- .map(|data| qr_code(data).cell_size(10)),
- )
- .width(700)
- .spacing(20)
- .align_x(Center);
+ let content = column![
+ title,
+ input,
+ row![toggle_total_size, choose_theme]
+ .spacing(20)
+ .align_y(Center)
+ ]
+ .push_maybe(self.total_size.map(|total_size| {
+ slider(Self::SIZE_RANGE, total_size, Message::TotalSizeChanged)
+ }))
+ .push_maybe(self.qr_code.as_ref().map(|data| {
+ if let Some(total_size) = self.total_size {
+ qr_code(data).total_size(total_size)
+ } else {
+ qr_code(data).cell_size(10.0)
+ }
+ }))
+ .width(700)
+ .spacing(20)
+ .align_x(Center);
center(content).padding(20).into()
}
diff --git a/graphics/src/compositor.rs b/graphics/src/compositor.rs
index 47521eb0..3026bead 100644
--- a/graphics/src/compositor.rs
+++ b/graphics/src/compositor.rs
@@ -155,7 +155,7 @@ impl Compositor for () {
async fn with_backend<W: Window + Clone>(
_settings: Settings,
_compatible_window: W,
- _preffered_backend: Option<&str>,
+ _preferred_backend: Option<&str>,
) -> Result<Self, Error> {
Ok(())
}
diff --git a/runtime/src/system.rs b/runtime/src/system.rs
index b6fb4fdf..8b0ec2d8 100644
--- a/runtime/src/system.rs
+++ b/runtime/src/system.rs
@@ -8,7 +8,7 @@ pub enum Action {
QueryInformation(oneshot::Sender<Information>),
}
-/// Contains informations about the system (e.g. system name, processor, memory, graphics adapter).
+/// Contains information about the system (e.g. system name, processor, memory, graphics adapter).
#[derive(Clone, Debug)]
pub struct Information {
/// The operating system name
diff --git a/runtime/src/window.rs b/runtime/src/window.rs
index 27035d7d..382f4518 100644
--- a/runtime/src/window.rs
+++ b/runtime/src/window.rs
@@ -220,7 +220,7 @@ pub fn resize_events() -> Subscription<(Id, Size)> {
})
}
-/// Subscribes to all [`Event::CloseRequested`] occurences in the running application.
+/// Subscribes to all [`Event::CloseRequested`] occurrences in the running application.
pub fn close_requests() -> Subscription<Id> {
event::listen_with(|event, _status, id| {
if let crate::core::Event::Window(Event::CloseRequested) = event {
diff --git a/wgpu/src/geometry.rs b/wgpu/src/geometry.rs
index a27cef07..d2ffda53 100644
--- a/wgpu/src/geometry.rs
+++ b/wgpu/src/geometry.rs
@@ -31,7 +31,7 @@ pub enum Geometry {
Cached(Cache),
}
-#[derive(Debug, Clone)]
+#[derive(Debug, Clone, Default)]
pub struct Cache {
pub meshes: Option<triangle::Cache>,
pub images: Option<Arc<[Image]>>,
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
diff --git a/winit/src/conversion.rs b/winit/src/conversion.rs
index 43e1848b..5d0f8348 100644
--- a/winit/src/conversion.rs
+++ b/winit/src/conversion.rs
@@ -262,6 +262,8 @@ pub fn window_event(
winit::event::ElementState::Released => {
keyboard::Event::KeyReleased {
key,
+ modified_key,
+ physical_key,
modifiers,
location,
}