summaryrefslogtreecommitdiffstats
path: root/native/src/widget/text.rs
diff options
context:
space:
mode:
Diffstat (limited to 'native/src/widget/text.rs')
-rw-r--r--native/src/widget/text.rs13
1 files changed, 8 insertions, 5 deletions
diff --git a/native/src/widget/text.rs b/native/src/widget/text.rs
index cf9c9565..7d8cad6e 100644
--- a/native/src/widget/text.rs
+++ b/native/src/widget/text.rs
@@ -41,7 +41,7 @@ impl Text {
size: None,
color: None,
font: Font::Default,
- width: Length::Fill,
+ width: Length::Shrink,
height: Length::Shrink,
horizontal_alignment: HorizontalAlignment::Left,
vertical_alignment: VerticalAlignment::Top,
@@ -131,7 +131,7 @@ where
) -> layout::Node {
let limits = limits.width(self.width).height(self.height);
- let size = self.size.unwrap_or(renderer.default_size());
+ let size = self.size.unwrap_or(Renderer::DEFAULT_SIZE);
let bounds = limits.max();
@@ -146,13 +146,15 @@ where
fn draw(
&self,
renderer: &mut Renderer,
+ defaults: &Renderer::Defaults,
layout: Layout<'_>,
_cursor_position: Point,
) -> Renderer::Output {
renderer.draw(
+ defaults,
layout.bounds(),
&self.content,
- self.size.unwrap_or(renderer.default_size()),
+ self.size.unwrap_or(Renderer::DEFAULT_SIZE),
self.font,
self.color,
self.horizontal_alignment,
@@ -177,10 +179,10 @@ where
/// [renderer]: ../../renderer/index.html
/// [`UserInterface`]: ../../struct.UserInterface.html
pub trait Renderer: crate::Renderer {
- /// Returns the default size of the [`Text`].
+ /// The default size of [`Text`].
///
/// [`Text`]: struct.Text.html
- fn default_size(&self) -> u16;
+ const DEFAULT_SIZE: u16;
/// Measures the [`Text`] in the given bounds and returns the minimum
/// boundaries that can fit the contents.
@@ -209,6 +211,7 @@ pub trait Renderer: crate::Renderer {
/// [`VerticalAlignment`]: enum.VerticalAlignment.html
fn draw(
&mut self,
+ defaults: &Self::Defaults,
bounds: Rectangle,
content: &str,
size: u16,