[][src]Trait iced_native::widget::text_input::Renderer

pub trait Renderer: Renderer + Sized {
    type Style: Default;
    fn measure_value(&self, value: &str, size: u16, font: Self::Font) -> f32;
fn offset(
        &self,
        text_bounds: Rectangle,
        font: Self::Font,
        size: u16,
        value: &Value,
        state: &State
    ) -> f32;
fn draw(
        &mut self,
        bounds: Rectangle,
        text_bounds: Rectangle,
        cursor_position: Point,
        font: Self::Font,
        size: u16,
        placeholder: &str,
        value: &Value,
        state: &State,
        style: &Self::Style
    ) -> Self::Output; fn find_cursor_position(
        &self,
        text_bounds: Rectangle,
        font: Self::Font,
        size: Option<u16>,
        value: &Value,
        state: &State,
        x: f32
    ) -> usize { ... } }

The renderer of a TextInput.

Your renderer will need to implement this trait before being able to use a TextInput in your user interface.

Associated Types

type Style: Default

The style supported by this renderer.

Loading content...

Required methods

fn measure_value(&self, value: &str, size: u16, font: Self::Font) -> f32

Returns the width of the value of the TextInput.

fn offset(
    &self,
    text_bounds: Rectangle,
    font: Self::Font,
    size: u16,
    value: &Value,
    state: &State
) -> f32

Returns the current horizontal offset of the value of the TextInput.

This is the amount of horizontal scrolling applied when the Value does not fit the TextInput.

fn draw(
    &mut self,
    bounds: Rectangle,
    text_bounds: Rectangle,
    cursor_position: Point,
    font: Self::Font,
    size: u16,
    placeholder: &str,
    value: &Value,
    state: &State,
    style: &Self::Style
) -> Self::Output

Draws a TextInput.

It receives:

  • the bounds of the TextInput
  • the bounds of the text (i.e. the current value)
  • the cursor position
  • the placeholder to show when the value is empty
  • the current Value
  • the current State
Loading content...

Provided methods

fn find_cursor_position(
    &self,
    text_bounds: Rectangle,
    font: Self::Font,
    size: Option<u16>,
    value: &Value,
    state: &State,
    x: f32
) -> usize

Computes the position of the text cursor at the given X coordinate of a TextInput.

Loading content...

Implementors

impl Renderer for Null[src]

type Style = ()

Loading content...