Use f32 instead of i32 for lengths

This allows users to use logical coordinates instead of physical ones.
This commit is contained in:
Héctor Ramón Jiménez 2023-02-04 11:13:53 +01:00
parent f08bea22ed
commit 4320ae6329
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
15 changed files with 203 additions and 155 deletions

View file

@ -18,11 +18,11 @@ fn main() {
let display_scale = match orbclient::get_display_size() {
Ok((w, h)) => {
log::info!("Display size: {}, {}", w, h);
(h as i32 / 1600) + 1
(h as f32 / 1600.0) + 1.0
}
Err(err) => {
log::warn!("Failed to get display size: {}", err);
1
1.0
}
};
@ -38,12 +38,12 @@ fn main() {
let mut editor = Editor::new(Buffer::new(
&font_system,
Metrics::new(32, 44).scale(display_scale),
Metrics::new(32.0, 44.0).scale(display_scale),
));
editor
.buffer_mut()
.set_size(window.width() as i32, window.height() as i32);
.set_size(window.width() as f32, window.height() as f32);
let attrs = Attrs::new();
let serif_attrs = attrs.family(Family::Serif);
@ -211,7 +211,7 @@ fn main() {
EventOption::Resize(resize) => {
editor
.buffer_mut()
.set_size(resize.width as i32, resize.height as i32);
.set_size(resize.width as f32, resize.height as f32);
}
EventOption::Quit(_) => process::exit(0),
_ => (),