Created
August 24, 2011 20:58
-
-
Save matthusby/1169211 to your computer and use it in GitHub Desktop.
AppController.j
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* AppController.j | |
* animationTest | |
* | |
* Created by Matthusby on June 23, 2011. | |
*/ | |
@import <Foundation/CPObject.j> | |
@import <AppKit/AppKit.j> | |
@import "MyView.j" | |
@implementation AppController : CPObject | |
{ | |
MyView myView; | |
MyView2 myView2; | |
} | |
- (void)applicationDidFinishLaunching:(CPNotification)aNotification | |
{ | |
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask], | |
contentView = [theWindow contentView]; | |
var label = [[CPTextField alloc] initWithFrame:CGRectMakeZero()]; | |
[label setStringValue:@"Hello World!"]; | |
[label setFont:[CPFont boldSystemFontOfSize:24.0]]; | |
[label sizeToFit]; | |
[label setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin | CPViewMinYMargin | CPViewMaxYMargin]; | |
[label setCenter:[contentView center]]; | |
var button = [[CPButton alloc] initWithFrame:CGRectMake( | |
CGRectGetWidth([contentView bounds])/2.0 - 40, | |
CGRectGetMaxY([label frame]) + 10, | |
80, 24)]; | |
[button setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin | CPViewMinYMargin | CPViewMaxYMargin]; | |
[button setTitle:"swap"]; | |
[button setTarget:self]; | |
[button setAction:@selector(swap:)]; | |
var button2 = [[CPButton alloc] initWithFrame:CGRectMake( | |
CGRectGetWidth([contentView bounds])/2.0 - 40, | |
CGRectGetMaxY([label frame]) + 50, | |
80, 24)]; | |
[button2 setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin | CPViewMinYMargin | CPViewMaxYMargin]; | |
[button2 setTitle:"swap"]; | |
[button2 setTarget:self]; | |
[button2 setAction:@selector(swap2:)]; | |
var myView = [[MyView alloc] initWithFrame:CGRectMake(100,100,200,200)]; | |
var myView2 = [[MyView2 alloc] initWithFrame:CGRectMake(200,200,200,200)]; | |
[contentView addSubview:myView]; | |
[contentView addSubview:myView2]; | |
[contentView addSubview:label]; | |
[contentView addSubview:button]; | |
[contentView addSubview:button2]; | |
[theWindow orderFront:self]; | |
// Uncomment the following line to turn on the standard menu bar. | |
//[CPMenu setMenuBarVisible:YES]; | |
} | |
- (void)swap:(id)sender | |
{ | |
console.log('swapping!'); | |
[[myView layer] setBackgroundColor:[CPColor greenColor]]; | |
[[myView layer] setBounds:CGRectMake(400,400,400,400)]; | |
} | |
-(void)swap2:(id)sender{ | |
var aStartFrame = [myView2 frame]; | |
var anEndFrame = CGRectMake(100,100,200,200); | |
var whatthe = 1; | |
var animation = [CPDictionary dictionaryWithObjects:[myView2, aStartFrame, anEndFrame, CPViewAnimationEffectKey] | |
forKeys:[CPViewAnimationTargetKey, CPViewAnimationStartFrameKey, CPViewAnimationEndFrameKey, CPViewAnimationEffectKey]]; | |
console.log(animation); | |
var cpViewAnimation = [[CPViewAnimation alloc] initWithViewAnimations:[animation]]; | |
[cpViewAnimation startAnimation]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment