2020-03-05 13:33:11 +11:00
|
|
|
//! This module contains various bits and pieces for drag and drop operations. They're shared
|
|
|
|
//! across the codebase, hence why they're here - they're not currently exhaustive, so feel free to
|
|
|
|
//! tinker and pull request.
|
|
|
|
|
|
|
|
use cocoa::foundation::NSUInteger;
|
|
|
|
|
2020-03-07 14:35:18 +11:00
|
|
|
use objc::runtime::Object;
|
|
|
|
use objc_id::Id;
|
|
|
|
|
2020-03-05 13:33:11 +11:00
|
|
|
/// Represents operations that can happen for a given drag/drop scenario.
|
|
|
|
pub enum DragOperation {
|
|
|
|
/// No drag operations are allowed.
|
|
|
|
None,
|
|
|
|
|
|
|
|
/// The data represented by the image can be copied.
|
|
|
|
Copy,
|
|
|
|
|
|
|
|
/// The data can be shared.
|
|
|
|
Link,
|
|
|
|
|
|
|
|
/// The operation can be defined by the destination.
|
|
|
|
Generic,
|
|
|
|
|
|
|
|
/// The operation is negotiated privately between the source and the destination.
|
|
|
|
Private,
|
|
|
|
|
|
|
|
/// The data can be moved.
|
|
|
|
Move,
|
|
|
|
|
|
|
|
/// The data can be deleted.
|
|
|
|
Delete,
|
|
|
|
|
|
|
|
// All of the above.
|
|
|
|
// @TODO: NSUIntegerMax, a tricky beast
|
|
|
|
// Every
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<DragOperation> for NSUInteger {
|
|
|
|
fn from(op: DragOperation) -> Self {
|
|
|
|
match op {
|
|
|
|
DragOperation::None => 0,
|
|
|
|
DragOperation::Copy => 1,
|
|
|
|
DragOperation::Link => 2,
|
|
|
|
DragOperation::Generic => 4,
|
|
|
|
DragOperation::Private => 8,
|
|
|
|
DragOperation::Move => 16,
|
|
|
|
DragOperation::Delete => 32
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-03-07 14:35:18 +11:00
|
|
|
|
|
|
|
/// A wrapper for `NSDraggingInfo`. As this is a protocol/type you should never create yourself,
|
|
|
|
/// this only provides getters - merely a Rust-y way to grab what you need.
|
|
|
|
pub struct DragInfo {
|
|
|
|
pub info: Id<Object>
|
|
|
|
}
|
|
|
|
|
|
|
|
impl DragInfo {
|
|
|
|
|
|
|
|
}
|