1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-08-08 14:25:05 +00:00

Fully wired in drag-and-drop for media insertion.

This commit is contained in:
Thomas Harte
2017-08-17 11:00:08 -04:00
parent f68565a33f
commit 378f231499
5 changed files with 40 additions and 3 deletions

View File

@@ -165,7 +165,10 @@ class MachineDocument:
} }
final func openGLView(_ view: CSOpenGLView, didReceiveFileAt URL: URL) { 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 // MARK: NSDocument overrides

View File

@@ -12,6 +12,7 @@
@interface CSMachine(Target) @interface CSMachine(Target)
- (void)applyTarget:(StaticAnalyser::Target)target; - (void)applyTarget:(const StaticAnalyser::Target &)target;
- (void)applyMedia:(const StaticAnalyser::Media &)media;
@end @end

View File

@@ -139,7 +139,7 @@ struct MachineDelegate: CRTMachine::Machine::Delegate {
typeRecipient->set_typer_for_string([paste UTF8String]); typeRecipient->set_typer_for_string([paste UTF8String]);
} }
- (void)applyTarget:(StaticAnalyser::Target)target { - (void)applyTarget:(const StaticAnalyser::Target &)target {
@synchronized(self) { @synchronized(self) {
ConfigurationTarget::Machine *const configurationTarget = ConfigurationTarget::Machine *const configurationTarget =
dynamic_cast<ConfigurationTarget::Machine *>(self.machine); 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 @end

View File

@@ -22,3 +22,10 @@
- (void)applyToMachine:(CSMachine *)machine; - (void)applyToMachine:(CSMachine *)machine;
@end @end
@interface CSMediaSet : NSObject
- (instancetype)initWithFileAtURL:(NSURL *)url;
- (void)applyToMachine:(CSMachine *)machine;
@end

View File

@@ -69,3 +69,21 @@
} }
@end @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