Use default_font_size
for TextInput
widget
This commit is contained in:
parent
946bbd2683
commit
dfeb3db003
@ -27,14 +27,8 @@ impl<B> text_input::Renderer for Renderer<B>
|
|||||||
where
|
where
|
||||||
B: Backend + backend::Text,
|
B: Backend + backend::Text,
|
||||||
{
|
{
|
||||||
type Font = Font;
|
|
||||||
type Style = Box<dyn StyleSheet>;
|
type Style = Box<dyn StyleSheet>;
|
||||||
|
|
||||||
fn default_size(&self) -> u16 {
|
|
||||||
// TODO: Make this configurable
|
|
||||||
20
|
|
||||||
}
|
|
||||||
|
|
||||||
fn measure_value(&self, value: &str, size: u16, font: Font) -> f32 {
|
fn measure_value(&self, value: &str, size: u16, font: Font) -> f32 {
|
||||||
let backend = self.backend();
|
let backend = self.backend();
|
||||||
|
|
||||||
|
@ -105,13 +105,8 @@ impl scrollable::Renderer for Null {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl text_input::Renderer for Null {
|
impl text_input::Renderer for Null {
|
||||||
type Font = Font;
|
|
||||||
type Style = ();
|
type Style = ();
|
||||||
|
|
||||||
fn default_size(&self) -> u16 {
|
|
||||||
20
|
|
||||||
}
|
|
||||||
|
|
||||||
fn measure_value(&self, _value: &str, _size: u16, _font: Font) -> f32 {
|
fn measure_value(&self, _value: &str, _size: u16, _font: Font) -> f32 {
|
||||||
0.0
|
0.0
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,8 @@ use editor::Editor;
|
|||||||
use crate::{
|
use crate::{
|
||||||
keyboard, layout,
|
keyboard, layout,
|
||||||
mouse::{self, click},
|
mouse::{self, click},
|
||||||
Clipboard, Element, Event, Hasher, Layout, Length, Point, Rectangle, Size,
|
text, Clipboard, Element, Event, Hasher, Layout, Length, Point, Rectangle,
|
||||||
Widget,
|
Size, Widget,
|
||||||
};
|
};
|
||||||
|
|
||||||
use std::u32;
|
use std::u32;
|
||||||
@ -486,7 +486,8 @@ where
|
|||||||
let text_bounds = layout.children().next().unwrap().bounds();
|
let text_bounds = layout.children().next().unwrap().bounds();
|
||||||
|
|
||||||
if self.is_secure {
|
if self.is_secure {
|
||||||
renderer.draw(
|
self::Renderer::draw(
|
||||||
|
renderer,
|
||||||
bounds,
|
bounds,
|
||||||
text_bounds,
|
text_bounds,
|
||||||
cursor_position,
|
cursor_position,
|
||||||
@ -498,7 +499,8 @@ where
|
|||||||
&self.style,
|
&self.style,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
renderer.draw(
|
self::Renderer::draw(
|
||||||
|
renderer,
|
||||||
bounds,
|
bounds,
|
||||||
text_bounds,
|
text_bounds,
|
||||||
cursor_position,
|
cursor_position,
|
||||||
@ -531,20 +533,10 @@ where
|
|||||||
///
|
///
|
||||||
/// [`TextInput`]: struct.TextInput.html
|
/// [`TextInput`]: struct.TextInput.html
|
||||||
/// [renderer]: ../../renderer/index.html
|
/// [renderer]: ../../renderer/index.html
|
||||||
pub trait Renderer: crate::Renderer + Sized {
|
pub trait Renderer: text::Renderer + Sized {
|
||||||
/// The font type used for [`TextInput`].
|
|
||||||
///
|
|
||||||
/// [`TextInput`]: struct.TextInput.html
|
|
||||||
type Font: Default + Copy;
|
|
||||||
|
|
||||||
/// The style supported by this renderer.
|
/// The style supported by this renderer.
|
||||||
type Style: Default;
|
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`].
|
/// Returns the width of the value of the [`TextInput`].
|
||||||
///
|
///
|
||||||
/// [`TextInput`]: struct.TextInput.html
|
/// [`TextInput`]: struct.TextInput.html
|
||||||
|
Loading…
Reference in New Issue
Block a user