mirror of
https://github.com/TomHarte/CLK.git
synced 2024-12-25 18:30:21 +00:00
Fully wired in drag-and-drop for media insertion.
This commit is contained in:
parent
f68565a33f
commit
378f231499
@ -165,7 +165,10 @@ class MachineDocument:
|
||||
}
|
||||
|
||||
final func openGLView(_ view: CSOpenGLView, didReceiveFileAt URL: URL) {
|
||||
// TODO: pass to machine.
|
||||
let mediaSet = CSMediaSet(fileAt: URL)
|
||||
if let mediaSet = mediaSet {
|
||||
mediaSet.apply(to: self.machine)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: NSDocument overrides
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
@interface CSMachine(Target)
|
||||
|
||||
- (void)applyTarget:(StaticAnalyser::Target)target;
|
||||
- (void)applyTarget:(const StaticAnalyser::Target &)target;
|
||||
- (void)applyMedia:(const StaticAnalyser::Media &)media;
|
||||
|
||||
@end
|
||||
|
@ -139,7 +139,7 @@ struct MachineDelegate: CRTMachine::Machine::Delegate {
|
||||
typeRecipient->set_typer_for_string([paste UTF8String]);
|
||||
}
|
||||
|
||||
- (void)applyTarget:(StaticAnalyser::Target)target {
|
||||
- (void)applyTarget:(const StaticAnalyser::Target &)target {
|
||||
@synchronized(self) {
|
||||
ConfigurationTarget::Machine *const configurationTarget =
|
||||
dynamic_cast<ConfigurationTarget::Machine *>(self.machine);
|
||||
@ -147,4 +147,12 @@ struct MachineDelegate: CRTMachine::Machine::Delegate {
|
||||
}
|
||||
}
|
||||
|
||||
- (void)applyMedia:(const StaticAnalyser::Media &)media {
|
||||
@synchronized(self) {
|
||||
ConfigurationTarget::Machine *const configurationTarget =
|
||||
dynamic_cast<ConfigurationTarget::Machine *>(self.machine);
|
||||
if(configurationTarget) configurationTarget->insert_media(media);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -22,3 +22,10 @@
|
||||
- (void)applyToMachine:(CSMachine *)machine;
|
||||
|
||||
@end
|
||||
|
||||
@interface CSMediaSet : NSObject
|
||||
|
||||
- (instancetype)initWithFileAtURL:(NSURL *)url;
|
||||
- (void)applyToMachine:(CSMachine *)machine;
|
||||
|
||||
@end
|
||||
|
@ -69,3 +69,21 @@
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation CSMediaSet {
|
||||
StaticAnalyser::Media _media;
|
||||
}
|
||||
|
||||
- (instancetype)initWithFileAtURL:(NSURL *)url {
|
||||
self = [super init];
|
||||
if(self) {
|
||||
_media = StaticAnalyser::GetMedia([url fileSystemRepresentation]);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)applyToMachine:(CSMachine *)machine {
|
||||
[machine applyMedia:_media];
|
||||
}
|
||||
|
||||
@end
|
||||
|
Loading…
Reference in New Issue
Block a user