59 lines
1.4 KiB
Rust
Executable File
59 lines
1.4 KiB
Rust
Executable File
/*
|
|
* Copyright (C) 2022 Umut İnan Erdoğan <umutinanerdogan@pm.me>
|
|
*
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
#[cfg(windows)]
|
|
use windows::Win32::{
|
|
Foundation::RECT,
|
|
Graphics::Direct2D::Common::{D2D_RECT_F, D2D_RECT_U},
|
|
};
|
|
|
|
// fixme: consider splitting this into two types (f32 and u32) or make this generic
|
|
#[derive(Copy, Clone, Debug)]
|
|
pub struct Rect {
|
|
pub left: f32,
|
|
pub right: f32,
|
|
pub top: f32,
|
|
pub bottom: f32,
|
|
}
|
|
|
|
#[cfg(windows)]
|
|
impl From<Rect> for RECT {
|
|
fn from(rect: Rect) -> Self {
|
|
Self {
|
|
left: rect.left as i32,
|
|
right: rect.right as i32,
|
|
top: rect.top as i32,
|
|
bottom: rect.bottom as i32,
|
|
}
|
|
}
|
|
}
|
|
|
|
#[cfg(windows)]
|
|
impl From<Rect> for D2D_RECT_U {
|
|
fn from(rect: Rect) -> Self {
|
|
Self {
|
|
left: rect.left as u32,
|
|
right: rect.right as u32,
|
|
top: rect.top as u32,
|
|
bottom: rect.bottom as u32,
|
|
}
|
|
}
|
|
}
|
|
|
|
#[cfg(windows)]
|
|
impl From<Rect> for D2D_RECT_F {
|
|
fn from(rect: Rect) -> Self {
|
|
Self {
|
|
left: rect.left,
|
|
right: rect.right,
|
|
top: rect.top,
|
|
bottom: rect.bottom,
|
|
}
|
|
}
|
|
}
|