Skip to content

Commit 374e30f

Browse files
committed
Make cell_size and total_size generic over Pixels in qr_code
1 parent 1536c80 commit 374e30f

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

widget/src/qr_code.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ use crate::core::mouse;
2626
use crate::core::renderer::{self, Renderer as _};
2727
use crate::core::widget::tree::{self, Tree};
2828
use crate::core::{
29-
Color, Element, Layout, Length, Point, Rectangle, Size, Theme, Vector,
30-
Widget,
29+
Color, Element, Layout, Length, Pixels, Point, Rectangle, Size, Theme,
30+
Vector, Widget,
3131
};
3232
use crate::Renderer;
3333

@@ -84,14 +84,16 @@ where
8484
}
8585

8686
/// Sets the size of the squares of the grid cell of the [`QRCode`].
87-
pub fn cell_size(mut self, cell_size: f32) -> Self {
88-
self.cell_size = cell_size;
87+
pub fn cell_size(mut self, cell_size: impl Into<Pixels>) -> Self {
88+
self.cell_size = cell_size.into().0;
8989
self
9090
}
9191

9292
/// Sets the size of the entire [`QRCode`].
93-
pub fn total_size(mut self, total_size: f32) -> Self {
94-
self.cell_size = total_size / (self.data.width + 2 * QUIET_ZONE) as f32;
93+
pub fn total_size(mut self, total_size: impl Into<Pixels>) -> Self {
94+
self.cell_size =
95+
total_size.into().0 / (self.data.width + 2 * QUIET_ZONE) as f32;
96+
9597
self
9698
}
9799

0 commit comments

Comments
 (0)