Restore a bunch of random workspace stuff
This commit is contained in:
@@ -182,6 +182,10 @@ pub struct AsyncWindowContext {
|
||||
}
|
||||
|
||||
impl AsyncWindowContext {
|
||||
pub fn window_handle(&self) -> AnyWindowHandle {
|
||||
self.window
|
||||
}
|
||||
|
||||
pub(crate) fn new(app: AsyncAppContext, window: AnyWindowHandle) -> Self {
|
||||
Self { app, window }
|
||||
}
|
||||
|
||||
@@ -343,7 +343,7 @@ where
|
||||
|
||||
impl<T> Bounds<T>
|
||||
where
|
||||
T: Clone + Debug + PartialOrd + Add<T, Output = T> + Sub<Output = T> + Default,
|
||||
T: Clone + Debug + PartialOrd + Add<T, Output = T> + Sub<Output = T> + Default + Half,
|
||||
{
|
||||
pub fn intersects(&self, other: &Bounds<T>) -> bool {
|
||||
let my_lower_right = self.lower_right();
|
||||
@@ -362,6 +362,13 @@ where
|
||||
self.size.width = self.size.width.clone() + double_amount.clone();
|
||||
self.size.height = self.size.height.clone() + double_amount;
|
||||
}
|
||||
|
||||
pub fn center(&self) -> Point<T> {
|
||||
Point {
|
||||
x: self.origin.x.clone() + self.size.width.clone().half(),
|
||||
y: self.origin.y.clone() + self.size.height.clone().half(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Clone + Default + Debug + PartialOrd + Add<T, Output = T> + Sub<Output = T>> Bounds<T> {
|
||||
@@ -1211,6 +1218,46 @@ impl From<()> for Length {
|
||||
}
|
||||
}
|
||||
|
||||
pub trait Half {
|
||||
fn half(&self) -> Self;
|
||||
}
|
||||
|
||||
impl Half for f32 {
|
||||
fn half(&self) -> Self {
|
||||
self / 2.
|
||||
}
|
||||
}
|
||||
|
||||
impl Half for DevicePixels {
|
||||
fn half(&self) -> Self {
|
||||
Self(self.0 / 2)
|
||||
}
|
||||
}
|
||||
|
||||
impl Half for ScaledPixels {
|
||||
fn half(&self) -> Self {
|
||||
Self(self.0 / 2.)
|
||||
}
|
||||
}
|
||||
|
||||
impl Half for Pixels {
|
||||
fn half(&self) -> Self {
|
||||
Self(self.0 / 2.)
|
||||
}
|
||||
}
|
||||
|
||||
impl Half for Rems {
|
||||
fn half(&self) -> Self {
|
||||
Self(self.0 / 2.)
|
||||
}
|
||||
}
|
||||
|
||||
impl Half for GlobalPixels {
|
||||
fn half(&self) -> Self {
|
||||
Self(self.0 / 2.)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait IsZero {
|
||||
fn is_zero(&self) -> bool;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user