Janitor: Replace float comparison dance with approx_eq from euclid

Sixtyfps uses euclid already, so let's use euclid for float comparisons
as well.

I changed the code to decide whether a number is a positive integer to
make do without a comparison along the way.
This commit is contained in:
Tobias Hunger 2021-07-22 20:01:23 +02:00
parent e45635656d
commit 02bdcbf6ff
6 changed files with 11 additions and 11 deletions

View file

@ -9,6 +9,7 @@
LICENSE END */
use cpp::*;
use euclid::approxeq::ApproxEq;
use items::{ImageFit, TextHorizontalAlignment, TextVerticalAlignment};
use sixtyfps_corelib::graphics::{Brush, FontRequest, Image, Point, Rect, RenderingCache, Size};
use sixtyfps_corelib::input::{InternalKeyCode, KeyEvent, KeyEventType, MouseEvent};
@ -889,8 +890,8 @@ impl QtItemRenderer<'_> {
rect.is_valid()
&& (rect.x != 0.
|| rect.y != 0.
|| (rect.width - target_width).abs() > 100. * f64::EPSILON
|| (rect.height - target_height).abs() > 100. * f64::EPSILON)
|| rect.width.approx_eq(&target_width)
|| rect.height.approx_eq(&target_height))
});
let source_size = if !has_source_clipping {
Some(qttypes::QSize { width: target_width as u32, height: target_height as u32 })