use std::convert::TryFrom;
use crate::{Origin, NCurseswWinError};
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub struct OriginResult {
origin: Origin,
to_screen: bool,
result: bool
}
impl OriginResult {
pub(in crate::mouse) fn new(y: u16, x: u16, to_screen: bool, result: bool) -> Self {
Self { origin: Origin { y, x }, to_screen, result }
}
pub fn origin(self) -> Origin {
self.origin
}
pub fn to_screen(self) -> bool {
self.to_screen
}
pub fn result(self) -> bool {
self.result
}
}
impl TryFrom<ncursesw::mouse::OriginResult> for OriginResult {
type Error = NCurseswWinError;
fn try_from(origin_result: ncursesw::mouse::OriginResult) -> Result<Self, Self::Error> {
let origin = Origin::try_from(origin_result.origin())?;
Ok(Self::new(origin.y, origin.x, origin_result.to_screen(), origin_result.result()))
}
}