Handle some TextInput events

This commit is contained in:
Héctor Ramón Jiménez 2019-10-30 05:00:12 +01:00
parent 63cd0fd8eb
commit fedcab6f4f
7 changed files with 93 additions and 29 deletions

View file

@ -10,6 +10,7 @@ const SIZE: f32 = 28.0;
impl checkbox::Renderer for Renderer {
fn node<Message>(&self, checkbox: &Checkbox<Message>) -> Node {
Row::<(), Self>::new()
.width(Length::Fill)
.spacing(15)
.align_items(Align::Center)
.push(

View file

@ -5,7 +5,7 @@ use iced_native::{
};
const SCROLLBAR_WIDTH: u16 = 10;
const SCROLLBAR_MARGIN: u16 = 10;
const SCROLLBAR_MARGIN: u16 = 5;
fn scrollbar_bounds(bounds: Rectangle) -> Rectangle {
Rectangle {

View file

@ -47,7 +47,7 @@ impl text::Renderer for Renderer {
let (width, height) = if let Some(bounds) =
glyph_brush.borrow_mut().glyph_bounds(&text)
{
(bounds.width(), bounds.height())
(bounds.width().round(), bounds.height().round())
} else {
(0.0, 0.0)
};

View file

@ -23,21 +23,23 @@ impl text_input::Renderer for Renderer {
let border = Primitive::Quad {
bounds,
background: Background::Color(if is_mouse_over {
Color {
r: 0.5,
g: 0.5,
b: 0.5,
a: 1.0,
}
} else {
Color {
r: 0.7,
g: 0.7,
b: 0.7,
a: 1.0,
}
}),
background: Background::Color(
if is_mouse_over || text_input.state.is_focused {
Color {
r: 0.5,
g: 0.5,
b: 0.5,
a: 1.0,
}
} else {
Color {
r: 0.7,
g: 0.7,
b: 0.7,
a: 1.0,
}
},
),
border_radius: 5,
};
@ -70,9 +72,9 @@ impl text_input::Renderer for Renderer {
}
} else {
Color {
r: 0.9,
g: 0.9,
b: 0.9,
r: 0.3,
g: 0.3,
b: 0.3,
a: 1.0,
}
},