Merge pull request #242 from kaimast/master

Some more code cleanups.
This commit is contained in:
Héctor Ramón 2020-03-29 15:42:17 +02:00 committed by GitHub
commit 5b2c71a708
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 15 additions and 19 deletions

View File

@ -54,8 +54,7 @@ impl<'a> Editor<'a> {
if start > 0 {
self.cursor.move_left(self.value);
let _ = self.value.remove(start - 1);
self.value.remove(start - 1);
}
}
}
@ -70,7 +69,7 @@ impl<'a> Editor<'a> {
let end = self.cursor.end(self.value);
if end < self.value.len() {
let _ = self.value.remove(end);
self.value.remove(end);
}
}
}

View File

@ -103,8 +103,8 @@ impl Renderer {
layers.push(Layer::new(Rectangle {
x: 0,
y: 0,
width: u32::from(width),
height: u32::from(height),
width,
height,
}));
self.draw_primitive(Vector::new(0.0, 0.0), primitive, &mut layers);
@ -356,7 +356,7 @@ impl Renderer {
) {
let bounds = layer.bounds * scale_factor;
if layer.meshes.len() > 0 {
if !layer.meshes.is_empty() {
let scaled = transformation
* Transformation::scale(scale_factor, scale_factor);
@ -372,7 +372,7 @@ impl Renderer {
);
}
if layer.quads.len() > 0 {
if !layer.quads.is_empty() {
self.quad_pipeline.draw(
device,
encoder,
@ -386,7 +386,7 @@ impl Renderer {
#[cfg(any(feature = "image", feature = "svg"))]
{
if layer.images.len() > 0 {
if !layer.images.is_empty() {
let scaled = transformation
* Transformation::scale(scale_factor, scale_factor);
@ -402,7 +402,7 @@ impl Renderer {
}
}
if layer.text.len() > 0 {
if !layer.text.is_empty() {
for text in layer.text.iter() {
// Target physical coordinates directly to avoid blurry text
let text = wgpu_glyph::Section {

View File

@ -10,7 +10,7 @@ impl iced_native::button::Renderer for Renderer {
fn draw<Message>(
&mut self,
defaults: &Defaults,
_defaults: &Defaults,
bounds: Rectangle,
cursor_position: Point,
is_disabled: bool,
@ -39,7 +39,6 @@ impl iced_native::button::Renderer for Renderer {
text: defaults::Text {
color: styling.text_color,
},
..*defaults
},
content_layout,
cursor_position,

View File

@ -38,7 +38,7 @@ impl checkbox::Renderer for Renderer {
content: crate::text::CHECKMARK_ICON.to_string(),
font: crate::text::BUILTIN_ICONS,
size: bounds.height * 0.7,
bounds: bounds,
bounds,
color: style.checkmark_color,
horizontal_alignment: HorizontalAlignment::Center,
vertical_alignment: VerticalAlignment::Center,

View File

@ -19,7 +19,6 @@ impl iced_native::container::Renderer for Renderer {
text: defaults::Text {
color: style.text_color.unwrap_or(defaults.text.color),
},
..*defaults
};
let (content, mouse_cursor) =

View File

@ -106,8 +106,7 @@ impl text_input::Renderer for Renderer {
style_sheet.placeholder_color()
} else {
style_sheet.value_color()
}
.into(),
},
font,
bounds: Rectangle {
width: f32::INFINITY,

View File

@ -45,7 +45,7 @@ pub enum Antialiasing {
}
impl Antialiasing {
pub(crate) fn sample_count(&self) -> u32 {
pub(crate) fn sample_count(self) -> u32 {
match self {
Antialiasing::MSAAx2 => 2,
Antialiasing::MSAAx4 => 4,

View File

@ -49,6 +49,6 @@ impl AsRef<[f32; 16]> for Transformation {
impl From<Transformation> for [f32; 16] {
fn from(t: Transformation) -> [f32; 16] {
t.as_ref().clone()
*t.as_ref()
}
}

View File

@ -120,7 +120,7 @@ impl Blit {
format,
pipeline,
constants: constant_bind_group,
texture_layout: texture_layout,
texture_layout,
sample_count: antialiasing.sample_count(),
targets: None,
}

View File

@ -123,7 +123,7 @@ pub trait Application: Sized {
Runtime::new(executor, Proxy::new(event_loop.create_proxy()))
};
let (mut application, init_command) = runtime.enter(|| Self::new());
let (mut application, init_command) = runtime.enter(Self::new);
runtime.spawn(init_command);
let subscription = application.subscription();