use core::{fmt::Debug, num::NonZeroUsize};
use bincode::{Decode, Encode};
use crate::size::PercentLength;
#[derive(Debug, Encode, Decode, Clone)]
pub enum Request {
SetPosition(SetPosition),
SetAnchor(SetAnchor),
SetMargin(SetMargin),
GetSize(GetSize),
UpdateSharedHandle(UpdateSharedHandle),
}
#[derive(Debug, Default, Encode, Decode, Clone, PartialEq)]
pub struct SetPosition {
pub x: PercentLength,
pub y: PercentLength,
}
#[derive(Debug, Default, Encode, Decode, Clone, PartialEq)]
pub struct SetAnchor {
pub x: PercentLength,
pub y: PercentLength,
}
#[derive(Debug, Default, Encode, Decode, Clone, PartialEq)]
pub struct SetMargin {
pub top: PercentLength,
pub right: PercentLength,
pub bottom: PercentLength,
pub left: PercentLength,
}
impl SetMargin {
pub const fn xy(x: PercentLength, y: PercentLength) -> Self {
Self {
top: y,
right: x,
bottom: y,
left: x,
}
}
}
#[derive(Debug, Default, Encode, Decode, Clone, PartialEq)]
pub struct GetSize {
pub hwnd: u32,
}
#[derive(Debug, Encode, Decode, Clone, PartialEq)]
pub struct UpdateSharedHandle {
pub handle: Option<NonZeroUsize>,
}