From dfeb3db003d724a1c980329dab9cbfae55b7f589 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Mon, 6 Jul 2020 23:58:15 +0200 Subject: [PATCH] Use `default_font_size` for `TextInput` widget --- graphics/src/widget/text_input.rs | 6 ------ native/src/renderer/null.rs | 5 ----- native/src/widget/text_input.rs | 22 +++++++--------------- 3 files changed, 7 insertions(+), 26 deletions(-) diff --git a/graphics/src/widget/text_input.rs b/graphics/src/widget/text_input.rs index f13f6606..575d67f5 100644 --- a/graphics/src/widget/text_input.rs +++ b/graphics/src/widget/text_input.rs @@ -27,14 +27,8 @@ impl text_input::Renderer for Renderer where B: Backend + backend::Text, { - type Font = Font; type Style = Box; - fn default_size(&self) -> u16 { - // TODO: Make this configurable - 20 - } - fn measure_value(&self, value: &str, size: u16, font: Font) -> f32 { let backend = self.backend(); diff --git a/native/src/renderer/null.rs b/native/src/renderer/null.rs index b8b0b996..5fd3627b 100644 --- a/native/src/renderer/null.rs +++ b/native/src/renderer/null.rs @@ -105,13 +105,8 @@ impl scrollable::Renderer for Null { } impl text_input::Renderer for Null { - type Font = Font; type Style = (); - fn default_size(&self) -> u16 { - 20 - } - fn measure_value(&self, _value: &str, _size: u16, _font: Font) -> f32 { 0.0 } diff --git a/native/src/widget/text_input.rs b/native/src/widget/text_input.rs index 24085606..3f415101 100644 --- a/native/src/widget/text_input.rs +++ b/native/src/widget/text_input.rs @@ -17,8 +17,8 @@ use editor::Editor; use crate::{ keyboard, layout, mouse::{self, click}, - Clipboard, Element, Event, Hasher, Layout, Length, Point, Rectangle, Size, - Widget, + text, Clipboard, Element, Event, Hasher, Layout, Length, Point, Rectangle, + Size, Widget, }; use std::u32; @@ -486,7 +486,8 @@ where let text_bounds = layout.children().next().unwrap().bounds(); if self.is_secure { - renderer.draw( + self::Renderer::draw( + renderer, bounds, text_bounds, cursor_position, @@ -498,7 +499,8 @@ where &self.style, ) } else { - renderer.draw( + self::Renderer::draw( + renderer, bounds, text_bounds, cursor_position, @@ -531,20 +533,10 @@ where /// /// [`TextInput`]: struct.TextInput.html /// [renderer]: ../../renderer/index.html -pub trait Renderer: crate::Renderer + Sized { - /// The font type used for [`TextInput`]. - /// - /// [`TextInput`]: struct.TextInput.html - type Font: Default + Copy; - +pub trait Renderer: text::Renderer + Sized { /// The style supported by this renderer. type Style: Default; - /// Returns the default size of the text of the [`TextInput`]. - /// - /// [`TextInput`]: struct.TextInput.html - fn default_size(&self) -> u16; - /// Returns the width of the value of the [`TextInput`]. /// /// [`TextInput`]: struct.TextInput.html