WIP
This commit is contained in:
+13
-5
@@ -9,11 +9,11 @@ use refineable::Refineable;
|
||||
use smallvec::SmallVec;
|
||||
|
||||
use crate::{
|
||||
current_platform, image_cache::ImageCache, Action, AppMetadata, AssetSource, Context,
|
||||
DispatchPhase, DisplayId, Executor, FocusEvent, FocusHandle, FocusId, KeyBinding, Keymap,
|
||||
LayoutId, MainThread, MainThreadOnly, Platform, SharedString, SubscriberSet, Subscription,
|
||||
SvgRenderer, Task, TextStyle, TextStyleRefinement, TextSystem, View, Window, WindowContext,
|
||||
WindowHandle, WindowId,
|
||||
current_platform, image_cache::ImageCache, Action, AppMetadata, AssetSource, ClipboardItem,
|
||||
Context, DispatchPhase, DisplayId, Executor, FocusEvent, FocusHandle, FocusId, KeyBinding,
|
||||
Keymap, LayoutId, MainThread, MainThreadOnly, Platform, SharedString, SubscriberSet,
|
||||
Subscription, SvgRenderer, Task, TextStyle, TextStyleRefinement, TextSystem, View, Window,
|
||||
WindowContext, WindowHandle, WindowId,
|
||||
};
|
||||
use anyhow::{anyhow, Result};
|
||||
use collections::{HashMap, HashSet, VecDeque};
|
||||
@@ -697,6 +697,14 @@ impl MainThread<AppContext> {
|
||||
self.platform().activate(ignoring_other_apps);
|
||||
}
|
||||
|
||||
pub fn write_to_clipboard(&self, item: ClipboardItem) {
|
||||
self.platform().write_to_clipboard(item)
|
||||
}
|
||||
|
||||
pub fn read_from_clipboard(&self) -> Option<ClipboardItem> {
|
||||
self.platform().read_from_clipboard()
|
||||
}
|
||||
|
||||
pub fn write_credentials(&self, url: &str, username: &str, password: &[u8]) -> Result<()> {
|
||||
self.platform().write_credentials(url, username, password)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use core::fmt::Debug;
|
||||
use derive_more::{Add, AddAssign, Div, Mul, Neg, Sub, SubAssign};
|
||||
use refineable::Refineable;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use std::{
|
||||
cmp::{self, PartialOrd},
|
||||
fmt,
|
||||
@@ -647,7 +648,21 @@ where
|
||||
|
||||
impl<T> Copy for Corners<T> where T: Copy + Clone + Default + Debug {}
|
||||
|
||||
#[derive(Clone, Copy, Default, Add, AddAssign, Sub, SubAssign, Div, Neg, PartialEq, PartialOrd)]
|
||||
#[derive(
|
||||
Clone,
|
||||
Copy,
|
||||
Default,
|
||||
Add,
|
||||
AddAssign,
|
||||
Sub,
|
||||
SubAssign,
|
||||
Div,
|
||||
Neg,
|
||||
PartialEq,
|
||||
PartialOrd,
|
||||
Serialize,
|
||||
Deserialize,
|
||||
)]
|
||||
#[repr(transparent)]
|
||||
pub struct Pixels(pub(crate) f32);
|
||||
|
||||
@@ -684,6 +699,10 @@ impl MulAssign<f32> for Pixels {
|
||||
impl Pixels {
|
||||
pub const MAX: Pixels = Pixels(f32::MAX);
|
||||
|
||||
pub fn floor(&self) -> Self {
|
||||
Self(self.0.floor())
|
||||
}
|
||||
|
||||
pub fn round(&self) -> Self {
|
||||
Self(self.0.round())
|
||||
}
|
||||
@@ -1008,7 +1027,7 @@ pub fn rems(rems: f32) -> Rems {
|
||||
Rems(rems)
|
||||
}
|
||||
|
||||
pub fn px(pixels: f32) -> Pixels {
|
||||
pub const fn px(pixels: f32) -> Pixels {
|
||||
Pixels(pixels)
|
||||
}
|
||||
|
||||
|
||||
@@ -1653,6 +1653,12 @@ impl<'a, 'w, S: 'static> std::ops::DerefMut for ViewContext<'a, 'w, S> {
|
||||
// #[derive(Clone, Copy, Eq, PartialEq, Hash)]
|
||||
slotmap::new_key_type! { pub struct WindowId; }
|
||||
|
||||
impl WindowId {
|
||||
pub fn as_u64(&self) -> u64 {
|
||||
self.0.as_ffi()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq)]
|
||||
pub struct WindowHandle<S> {
|
||||
id: WindowId,
|
||||
@@ -1694,6 +1700,12 @@ pub struct AnyWindowHandle {
|
||||
state_type: TypeId,
|
||||
}
|
||||
|
||||
impl AnyWindowHandle {
|
||||
pub fn window_id(&self) -> WindowId {
|
||||
self.id
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(test, feature = "test"))]
|
||||
impl From<SmallVec<[u32; 16]>> for StackingOrder {
|
||||
fn from(small_vec: SmallVec<[u32; 16]>) -> Self {
|
||||
|
||||
Reference in New Issue
Block a user