Lower text::Renderer's Font bound from Copy to Clone
This commit is contained in:
parent
a7bcd65bb8
commit
d06e6bfb51
8 changed files with 25 additions and 24 deletions
|
|
@ -454,7 +454,7 @@ where
|
||||||
..bounds
|
..bounds
|
||||||
},
|
},
|
||||||
size: f32::from(text_size),
|
size: f32::from(text_size),
|
||||||
font: self.font,
|
font: self.font.clone(),
|
||||||
color: if is_selected {
|
color: if is_selected {
|
||||||
self.style.selected_text_color
|
self.style.selected_text_color
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ impl Hit {
|
||||||
/// A renderer capable of measuring and drawing [`Text`].
|
/// A renderer capable of measuring and drawing [`Text`].
|
||||||
pub trait Renderer: crate::Renderer {
|
pub trait Renderer: crate::Renderer {
|
||||||
/// The font type used.
|
/// The font type used.
|
||||||
type Font: Default + Copy;
|
type Font: Default + Clone;
|
||||||
|
|
||||||
/// The icon font of the backend.
|
/// The icon font of the backend.
|
||||||
const ICON_FONT: Self::Font;
|
const ICON_FONT: Self::Font;
|
||||||
|
|
|
||||||
|
|
@ -157,7 +157,7 @@ where
|
||||||
)
|
)
|
||||||
.push(
|
.push(
|
||||||
Text::new(&self.label)
|
Text::new(&self.label)
|
||||||
.font(self.font)
|
.font(self.font.clone())
|
||||||
.width(self.width)
|
.width(self.width)
|
||||||
.size(self.text_size.unwrap_or(renderer.default_size())),
|
.size(self.text_size.unwrap_or(renderer.default_size())),
|
||||||
)
|
)
|
||||||
|
|
@ -261,7 +261,7 @@ where
|
||||||
style,
|
style,
|
||||||
label_layout,
|
label_layout,
|
||||||
&self.label,
|
&self.label,
|
||||||
self.font,
|
self.font.clone(),
|
||||||
self.text_size,
|
self.text_size,
|
||||||
self.text_color.or(Some(custom_style.text_color)),
|
self.text_color.or(Some(custom_style.text_color)),
|
||||||
alignment::Horizontal::Left,
|
alignment::Horizontal::Left,
|
||||||
|
|
|
||||||
|
|
@ -174,7 +174,7 @@ where
|
||||||
.pad(self.padding);
|
.pad(self.padding);
|
||||||
|
|
||||||
let text_size = self.text_size.unwrap_or(renderer.default_size());
|
let text_size = self.text_size.unwrap_or(renderer.default_size());
|
||||||
let font = self.font;
|
let font = self.font.clone();
|
||||||
|
|
||||||
let max_width = match self.width {
|
let max_width = match self.width {
|
||||||
Length::Shrink => {
|
Length::Shrink => {
|
||||||
|
|
@ -182,7 +182,7 @@ where
|
||||||
let (width, _) = renderer.measure(
|
let (width, _) = renderer.measure(
|
||||||
label,
|
label,
|
||||||
text_size,
|
text_size,
|
||||||
font,
|
font.clone(),
|
||||||
Size::new(f32::INFINITY, f32::INFINITY),
|
Size::new(f32::INFINITY, f32::INFINITY),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -397,7 +397,7 @@ where
|
||||||
size: f32::from(
|
size: f32::from(
|
||||||
self.text_size.unwrap_or(renderer.default_size()),
|
self.text_size.unwrap_or(renderer.default_size()),
|
||||||
),
|
),
|
||||||
font: self.font,
|
font: self.font.clone(),
|
||||||
color: is_selected
|
color: is_selected
|
||||||
.then(|| style.text_color)
|
.then(|| style.text_color)
|
||||||
.unwrap_or(style.placeholder_color),
|
.unwrap_or(style.placeholder_color),
|
||||||
|
|
@ -427,7 +427,7 @@ where
|
||||||
)
|
)
|
||||||
.width(bounds.width.round() as u16)
|
.width(bounds.width.round() as u16)
|
||||||
.padding(self.padding)
|
.padding(self.padding)
|
||||||
.font(self.font)
|
.font(self.font.clone())
|
||||||
.style(self.style_sheet.menu());
|
.style(self.style_sheet.menu());
|
||||||
|
|
||||||
if let Some(text_size) = self.text_size {
|
if let Some(text_size) = self.text_size {
|
||||||
|
|
|
||||||
|
|
@ -279,7 +279,7 @@ where
|
||||||
style,
|
style,
|
||||||
label_layout,
|
label_layout,
|
||||||
&self.label,
|
&self.label,
|
||||||
self.font,
|
self.font.clone(),
|
||||||
self.text_size,
|
self.text_size,
|
||||||
self.text_color,
|
self.text_color,
|
||||||
alignment::Horizontal::Left,
|
alignment::Horizontal::Left,
|
||||||
|
|
|
||||||
|
|
@ -124,7 +124,7 @@ where
|
||||||
let bounds = limits.max();
|
let bounds = limits.max();
|
||||||
|
|
||||||
let (width, height) =
|
let (width, height) =
|
||||||
renderer.measure(&self.content, size, self.font, bounds);
|
renderer.measure(&self.content, size, self.font.clone(), bounds);
|
||||||
|
|
||||||
let size = limits.resolve(Size::new(width, height));
|
let size = limits.resolve(Size::new(width, height));
|
||||||
|
|
||||||
|
|
@ -144,7 +144,7 @@ where
|
||||||
style,
|
style,
|
||||||
layout,
|
layout,
|
||||||
&self.content,
|
&self.content,
|
||||||
self.font,
|
self.font.clone(),
|
||||||
self.size,
|
self.size,
|
||||||
self.color,
|
self.color,
|
||||||
self.horizontal_alignment,
|
self.horizontal_alignment,
|
||||||
|
|
@ -227,7 +227,7 @@ impl<Renderer: text::Renderer> Clone for Text<Renderer> {
|
||||||
content: self.content.clone(),
|
content: self.content.clone(),
|
||||||
size: self.size,
|
size: self.size,
|
||||||
color: self.color,
|
color: self.color,
|
||||||
font: self.font,
|
font: self.font.clone(),
|
||||||
width: self.width,
|
width: self.width,
|
||||||
height: self.height,
|
height: self.height,
|
||||||
horizontal_alignment: self.horizontal_alignment,
|
horizontal_alignment: self.horizontal_alignment,
|
||||||
|
|
|
||||||
|
|
@ -219,7 +219,7 @@ where
|
||||||
&value,
|
&value,
|
||||||
size,
|
size,
|
||||||
position,
|
position,
|
||||||
self.font,
|
self.font.clone(),
|
||||||
);
|
);
|
||||||
|
|
||||||
(
|
(
|
||||||
|
|
@ -251,7 +251,7 @@ where
|
||||||
&value,
|
&value,
|
||||||
size,
|
size,
|
||||||
left,
|
left,
|
||||||
self.font,
|
self.font.clone(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let (right_position, right_offset) =
|
let (right_position, right_offset) =
|
||||||
|
|
@ -261,7 +261,7 @@ where
|
||||||
&value,
|
&value,
|
||||||
size,
|
size,
|
||||||
right,
|
right,
|
||||||
self.font,
|
self.font.clone(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let width = right_position - left_position;
|
let width = right_position - left_position;
|
||||||
|
|
@ -300,7 +300,7 @@ where
|
||||||
&text
|
&text
|
||||||
},
|
},
|
||||||
size,
|
size,
|
||||||
self.font,
|
self.font.clone(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let render = |renderer: &mut Renderer| {
|
let render = |renderer: &mut Renderer| {
|
||||||
|
|
@ -319,7 +319,7 @@ where
|
||||||
} else {
|
} else {
|
||||||
self.style_sheet.value_color()
|
self.style_sheet.value_color()
|
||||||
},
|
},
|
||||||
font: self.font,
|
font: self.font.clone(),
|
||||||
bounds: Rectangle {
|
bounds: Rectangle {
|
||||||
y: text_bounds.center_y(),
|
y: text_bounds.center_y(),
|
||||||
width: f32::INFINITY,
|
width: f32::INFINITY,
|
||||||
|
|
@ -414,7 +414,7 @@ where
|
||||||
find_cursor_position(
|
find_cursor_position(
|
||||||
renderer,
|
renderer,
|
||||||
text_layout.bounds(),
|
text_layout.bounds(),
|
||||||
self.font,
|
self.font.clone(),
|
||||||
self.size,
|
self.size,
|
||||||
&value,
|
&value,
|
||||||
&self.state,
|
&self.state,
|
||||||
|
|
@ -434,7 +434,7 @@ where
|
||||||
let position = find_cursor_position(
|
let position = find_cursor_position(
|
||||||
renderer,
|
renderer,
|
||||||
text_layout.bounds(),
|
text_layout.bounds(),
|
||||||
self.font,
|
self.font.clone(),
|
||||||
self.size,
|
self.size,
|
||||||
&self.value,
|
&self.value,
|
||||||
&self.state,
|
&self.state,
|
||||||
|
|
@ -481,7 +481,7 @@ where
|
||||||
let position = find_cursor_position(
|
let position = find_cursor_position(
|
||||||
renderer,
|
renderer,
|
||||||
text_layout.bounds(),
|
text_layout.bounds(),
|
||||||
self.font,
|
self.font.clone(),
|
||||||
self.size,
|
self.size,
|
||||||
&value,
|
&value,
|
||||||
&self.state,
|
&self.state,
|
||||||
|
|
@ -962,13 +962,14 @@ where
|
||||||
{
|
{
|
||||||
let size = size.unwrap_or(renderer.default_size());
|
let size = size.unwrap_or(renderer.default_size());
|
||||||
|
|
||||||
let offset = offset(renderer, text_bounds, font, size, &value, &state);
|
let offset =
|
||||||
|
offset(renderer, text_bounds, font.clone(), size, &value, &state);
|
||||||
|
|
||||||
renderer
|
renderer
|
||||||
.hit_test(
|
.hit_test(
|
||||||
&value.to_string(),
|
&value.to_string(),
|
||||||
size.into(),
|
size.into(),
|
||||||
font,
|
font.clone(),
|
||||||
Size::INFINITY,
|
Size::INFINITY,
|
||||||
Point::new(x + offset, text_bounds.height / 2.0),
|
Point::new(x + offset, text_bounds.height / 2.0),
|
||||||
true,
|
true,
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,7 @@ where
|
||||||
row = row.push(
|
row = row.push(
|
||||||
Text::new(label)
|
Text::new(label)
|
||||||
.horizontal_alignment(self.text_alignment)
|
.horizontal_alignment(self.text_alignment)
|
||||||
.font(self.font)
|
.font(self.font.clone())
|
||||||
.width(self.width)
|
.width(self.width)
|
||||||
.size(self.text_size.unwrap_or(renderer.default_size())),
|
.size(self.text_size.unwrap_or(renderer.default_size())),
|
||||||
);
|
);
|
||||||
|
|
@ -229,7 +229,7 @@ where
|
||||||
style,
|
style,
|
||||||
label_layout,
|
label_layout,
|
||||||
&label,
|
&label,
|
||||||
self.font,
|
self.font.clone(),
|
||||||
self.text_size,
|
self.text_size,
|
||||||
None,
|
None,
|
||||||
self.text_alignment,
|
self.text_alignment,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue