diff options
author | 2024-10-02 17:12:12 +0200 | |
---|---|---|
committer | 2024-10-02 17:14:03 +0200 | |
commit | b02ec8b6b2f2bea68256a91e2a8a8c17198d4ce2 (patch) | |
tree | d6a882262081b32ab2780cd67b294cf538896e47 /widget | |
parent | a1e2bd22ec91cce608adc26d6347baf6c054131c (diff) | |
download | iced-b02ec8b6b2f2bea68256a91e2a8a8c17198d4ce2.tar.gz iced-b02ec8b6b2f2bea68256a91e2a8a8c17198d4ce2.tar.bz2 iced-b02ec8b6b2f2bea68256a91e2a8a8c17198d4ce2.zip |
Make `cell_size` and `total_size` generic over `Pixels` in `qr_code`
Diffstat (limited to 'widget')
-rw-r--r-- | widget/src/qr_code.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/widget/src/qr_code.rs b/widget/src/qr_code.rs index 6a8f5ed7..d1834465 100644 --- a/widget/src/qr_code.rs +++ b/widget/src/qr_code.rs @@ -26,8 +26,8 @@ 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; @@ -84,14 +84,16 @@ where } /// Sets the size of the squares of the grid cell of the [`QRCode`]. - pub fn cell_size(mut self, cell_size: f32) -> 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: f32) -> Self { - self.cell_size = total_size / (self.data.width + 2 * QUIET_ZONE) as f32; + 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 } |