Make size/position types generic over pixel type (#1277)

* Begin implementing DPI generics

* Fix multithreaded example

* Format

* Fix serde test

* hopefully fix most of the errors

* Fix dpi module errors

* More error fixings

* Format

* fix macos errors

* Another error pass

* Replace bad type signatures

* more fixins
This commit is contained in:
Osspial 2020-01-04 01:33:07 -05:00
parent b16042a047
commit 3a1e694c2f
40 changed files with 388 additions and 336 deletions

View file

@ -729,7 +729,7 @@ impl<T> EventLoop<T> {
if let Some(dpi) = window.new_dpi {
let dpi = dpi as f64;
let logical_size = LogicalSize::from(*window.size);
let logical_size = LogicalSize::<f64>::from(*window.size);
let mut new_inner_size = Some(logical_size.to_physical(dpi));
callback(Event::WindowEvent {
@ -741,7 +741,7 @@ impl<T> EventLoop<T> {
});
if let Some(new_size) = new_inner_size {
let (w, h) = new_size.to_logical(dpi).into();
let (w, h) = new_size.to_logical::<u32>(dpi).into();
frame.resize(w, h);
*window.size = (w, h);
}
@ -947,7 +947,7 @@ pub struct VideoMode {
impl VideoMode {
#[inline]
pub fn size(&self) -> PhysicalSize {
pub fn size(&self) -> PhysicalSize<u32> {
self.size.into()
}
@ -1007,8 +1007,8 @@ impl fmt::Debug for MonitorHandle {
struct MonitorHandle {
name: Option<String>,
native_identifier: u32,
size: PhysicalSize,
position: PhysicalPosition,
size: PhysicalSize<u32>,
position: PhysicalPosition<i32>,
hidpi_factor: i32,
}
@ -1036,7 +1036,7 @@ impl MonitorHandle {
self.mgr.with_info(&self.proxy, |id, _| id).unwrap_or(0)
}
pub fn size(&self) -> PhysicalSize {
pub fn size(&self) -> PhysicalSize<u32> {
match self.mgr.with_info(&self.proxy, |_, info| {
info.modes
.iter()
@ -1049,7 +1049,7 @@ impl MonitorHandle {
.into()
}
pub fn position(&self) -> PhysicalPosition {
pub fn position(&self) -> PhysicalPosition<i32> {
self.mgr
.with_info(&self.proxy, |_, info| info.location)
.unwrap_or((0, 0))