mirror of
https://github.com/zakk4223/CocoaSplit.git
synced 2026-05-25 22:00:30 -06:00
Properly setup single-view mode when it is restored on startup
This commit is contained in:
parent
df889a6149
commit
c5610ad1e8
7 changed files with 71 additions and 17 deletions
|
|
@ -17,6 +17,7 @@
|
|||
@property (assign) int canvas_height;
|
||||
@property (assign) bool isActive;
|
||||
@property (strong) NSArray *sourceList;
|
||||
@property (strong) NSString *uuid;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
|||
|
|
@ -75,18 +75,30 @@
|
|||
+(NSObject<CSCaptureSourceProtocol> *)createSourceFromPasteboardItem:(NSPasteboardItem *)item
|
||||
{
|
||||
NSData *indexData = [item dataForType:@"cocoasplit.layout"];
|
||||
NSIndexSet *indexes = [NSKeyedUnarchiver unarchiveObjectWithData:indexData];
|
||||
|
||||
NSString *draggedUUID = [NSKeyedUnarchiver unarchiveObjectWithData:indexData];
|
||||
// NSIndexSet *indexes = [NSKeyedUnarchiver unarchiveObjectWithData:indexData];
|
||||
/*
|
||||
if (!indexes)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
NSInteger draggedItemIdx = [indexes firstIndex];
|
||||
*/
|
||||
NSObject *controller = [[CSPluginServices sharedPluginServices] captureController];
|
||||
NSArray *layouts = [controller valueForKey:@"sourceLayouts"];
|
||||
|
||||
NSObject *useLayout = [layouts objectAtIndex:draggedItemIdx];
|
||||
SourceLayoutHack *useLayout = nil;
|
||||
for (SourceLayoutHack *tmp in layouts)
|
||||
{
|
||||
if ([tmp.uuid isEqualToString:draggedUUID])
|
||||
{
|
||||
useLayout = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
//SourceLayoutHack *useLayout = [layouts objectAtIndex:draggedItemIdx];
|
||||
|
||||
if (useLayout)
|
||||
{
|
||||
NSString *layoutName = [useLayout valueForKey:@"name"];
|
||||
|
|
|
|||
|
|
@ -187,6 +187,22 @@ var advanceBeginTime = function(duration) {
|
|||
}
|
||||
|
||||
|
||||
var removeInputFromLayout = function(input, layout) {
|
||||
var useLayout = layout;
|
||||
if (!useLayout)
|
||||
{
|
||||
useLayout = getCurrentLayout();
|
||||
}
|
||||
|
||||
var animInput = new CSAnimationInput(input);
|
||||
animInput.hidden(false, 0.0).completion_handler = function(anim) { useLayout.deleteSource(input);};
|
||||
}
|
||||
var addInputToLayout = function(input, layout) {
|
||||
layout.addSourceForAnimation(input);
|
||||
var animInput = new CSAnimationInput(input);
|
||||
animInput.hidden(false, 0.0).completion_handler = function(anim) { layout.addSource(input);};
|
||||
}
|
||||
|
||||
var addDummyAnimation = function(duration, kwargs) {
|
||||
var keyname = "__DUMMY_ANIMATION__" + generateUUID();
|
||||
|
||||
|
|
|
|||
|
|
@ -2316,15 +2316,6 @@
|
|||
*/
|
||||
}
|
||||
|
||||
if ([saveRoot objectForKey:@"stagingHidden"])
|
||||
{
|
||||
BOOL stagingHidden = [[saveRoot valueForKeyPath:@"stagingHidden"] boolValue];
|
||||
self.stagingHidden = stagingHidden;
|
||||
}
|
||||
if (self.stagingHidden)
|
||||
{
|
||||
[self hideStagingView];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -2364,6 +2355,15 @@
|
|||
// [self.stagingLayout mergeSourceLayout:tmpLayout withLayer:nil];
|
||||
}
|
||||
|
||||
if ([saveRoot objectForKey:@"stagingHidden"])
|
||||
{
|
||||
BOOL stagingHidden = [[saveRoot valueForKeyPath:@"stagingHidden"] boolValue];
|
||||
self.stagingHidden = stagingHidden;
|
||||
}
|
||||
if (self.stagingHidden)
|
||||
{
|
||||
[self hideStagingView];
|
||||
}
|
||||
|
||||
|
||||
self.inputLibrary = [saveRoot valueForKey:@"inputLibrary"];
|
||||
|
|
@ -3631,6 +3631,8 @@
|
|||
-(NSDragOperation)collectionView:(NSCollectionView *)collectionView validateDrop:(id<NSDraggingInfo>)draggingInfo proposedIndex:(NSInteger *)proposedDropIndex dropOperation:(NSCollectionViewDropOperation *)proposedDropOperation
|
||||
{
|
||||
|
||||
return NSDragOperationMove;
|
||||
|
||||
NSPasteboard *pBoard = [draggingInfo draggingPasteboard];
|
||||
NSData *indexSave = [pBoard dataForType:@"cocoasplit.layout"];
|
||||
NSIndexSet *indexes = [NSKeyedUnarchiver unarchiveObjectWithData:indexSave];
|
||||
|
|
@ -3662,9 +3664,11 @@
|
|||
|
||||
-(BOOL)collectionView:(NSCollectionView *)collectionView writeItemsAtIndexes:(NSIndexSet *)indexes toPasteboard:(NSPasteboard *)pasteboard
|
||||
{
|
||||
NSData *indexSave = [NSKeyedArchiver archivedDataWithRootObject:indexes];
|
||||
NSArray *layouts = [self.sourceLayouts objectsAtIndexes:indexes];
|
||||
SourceLayout *useLayout = layouts.firstObject;
|
||||
NSData *uuidSave = [NSKeyedArchiver archivedDataWithRootObject:useLayout.uuid];
|
||||
[pasteboard declareTypes:@[@"cocoasplit.layout"] owner:nil];
|
||||
[pasteboard setData:indexSave forType:@"cocoasplit.layout"];
|
||||
[pasteboard setData:uuidSave forType:@"cocoasplit.layout"];
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1489,7 +1489,14 @@ JS_EXPORT void JSSynchronousGarbageCollectForDebugging(JSContextRef ctx);
|
|||
|
||||
[self addSourceToPresentation:toAdd];
|
||||
toAdd.layer.hidden = YES;
|
||||
toAdd.autoPlaceOnFrameUpdate = YES;
|
||||
[CATransaction begin];
|
||||
[CATransaction setCompletionBlock:^{
|
||||
[toAdd buildLayerConstraints];
|
||||
}];
|
||||
|
||||
[self.rootLayer addSublayer:toAdd.layer];
|
||||
[CATransaction commit];
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -2286,7 +2293,8 @@ JS_EXPORT void JSSynchronousGarbageCollectForDebugging(JSContextRef ctx);
|
|||
{
|
||||
return;
|
||||
}
|
||||
|
||||
NSLog(@"ADD SRC %@ %@", addSource, addSource.uuid);
|
||||
|
||||
_uuidMapPresentation[addSource.uuid] = addSource;
|
||||
@synchronized(self)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@
|
|||
@property (strong) SourceLayout *layout;
|
||||
@property (assign) float holdDuration;
|
||||
@property (assign) bool doMerge;
|
||||
@property (strong) InputSource *layoutSource;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
|
@ -25,6 +27,7 @@
|
|||
@property (strong) SourceLayout *layout;
|
||||
@property (assign) float holdDuration;
|
||||
@property (assign) bool doMerge;
|
||||
@property (strong) InputSource *layoutSource;
|
||||
@end
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -63,16 +63,26 @@
|
|||
|
||||
_savedTransition = CaptureController.sharedCaptureController.activeTransition;
|
||||
CaptureController.sharedCaptureController.activeTransition = nil;
|
||||
NSPasteboardItem *layoutItem = [[NSPasteboardItem alloc] init];
|
||||
NSData *uuidData = [NSKeyedArchiver archivedDataWithRootObject:self.layout.uuid];
|
||||
[layoutItem setData:uuidData forType:@"cocoasplit.layout"];
|
||||
|
||||
self.layoutSource = [CaptureController.sharedCaptureController inputSourceForPasteboardItem:layoutItem];
|
||||
self.layoutSource.persistent = YES;
|
||||
//-(NSObject<CSInputSourceProtocol>*)inputSourceForPasteboardItem:(NSPasteboardItem *)item;
|
||||
|
||||
NSLog(@"LAYOUT SRC %@", self.layoutSource.uuid);
|
||||
//[[CaptureController sharedCaptureController] switchToLayout:targetLayout];
|
||||
|
||||
return @"switchToLayout(self.layout);waitAnimation(5);";
|
||||
return @"addInputToLayout(self.layoutSource, getCurrentLayout());waitAnimation(5);";
|
||||
//return @"console.log('blah');beginAnimation();target_layout.replaceWithSourceLayoutUsingScripts(captureController.activeTransition.layout, useScripts);;waitAnimation(5);commitAnimation();console.log('done')";
|
||||
}
|
||||
|
||||
-(NSString *)postChangeAction:(SourceLayout *)targetLayout
|
||||
{
|
||||
NSString *ret = @"waitAnimation(5);removeInputFromLayout(self.layoutSource)";
|
||||
CaptureController.sharedCaptureController.activeTransition = _savedTransition;
|
||||
return nil;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue