Guest User

Untitled

a guest
Jan 23rd, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 KB | None | 0 0
  1. /*
  2. * AppController.j
  3. * animationTest
  4. *
  5. * Created by Matthusby on June 23, 2011.
  6. */
  7.  
  8. @import <Foundation/CPObject.j>
  9. @import <AppKit/AppKit.j>
  10. @import "MyView.j"
  11.  
  12. @implementation AppController : CPObject
  13. {
  14. MyView myView;
  15. MyView2 myView2;
  16. }
  17.  
  18. - (void)applicationDidFinishLaunching:(CPNotification)aNotification
  19. {
  20. var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask],
  21. contentView = [theWindow contentView];
  22.  
  23. var label = [[CPTextField alloc] initWithFrame:CGRectMakeZero()];
  24.  
  25. [label setStringValue:@"Hello World!"];
  26. [label setFont:[CPFont boldSystemFontOfSize:24.0]];
  27.  
  28. [label sizeToFit];
  29.  
  30. [label setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin | CPViewMinYMargin | CPViewMaxYMargin];
  31. [label setCenter:[contentView center]];
  32.  
  33. var button = [[CPButton alloc] initWithFrame:CGRectMake(
  34. CGRectGetWidth([contentView bounds])/2.0 - 40,
  35. CGRectGetMaxY([label frame]) + 10,
  36. 80, 24)];
  37.  
  38. [button setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin | CPViewMinYMargin | CPViewMaxYMargin];
  39. [button setTitle:"swap"];
  40. [button setTarget:self];
  41. [button setAction:@selector(swap:)];
  42.  
  43. var button2 = [[CPButton alloc] initWithFrame:CGRectMake(
  44. CGRectGetWidth([contentView bounds])/2.0 - 40,
  45. CGRectGetMaxY([label frame]) + 50,
  46. 80, 24)];
  47.  
  48. [button2 setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin | CPViewMinYMargin | CPViewMaxYMargin];
  49. [button2 setTitle:"swap"];
  50. [button2 setTarget:self];
  51. [button2 setAction:@selector(swap2:)];
  52.  
  53. var myView = [[MyView alloc] initWithFrame:CGRectMake(100,100,200,200)];
  54. var myView2 = [[MyView2 alloc] initWithFrame:CGRectMake(200,200,200,200)];
  55.  
  56. [contentView addSubview:myView];
  57. [contentView addSubview:myView2];
  58. [contentView addSubview:label];
  59. [contentView addSubview:button];
  60. [contentView addSubview:button2];
  61.  
  62. [theWindow orderFront:self];
  63.  
  64. // Uncomment the following line to turn on the standard menu bar.
  65. //[CPMenu setMenuBarVisible:YES];
  66. }
  67.  
  68. - (void)swap:(id)sender
  69. {
  70. console.log('swapping!');
  71. [[myView layer] setBackgroundColor:[CPColor greenColor]];
  72. [[myView layer] setBounds:CGRectMake(400,400,400,400)];
  73. }
  74.  
  75. -(void)swap2:(id)sender{
  76. var aStartFrame = [myView2 frame];
  77. var anEndFrame = CGRectMake(100,100,200,200);
  78. var whatthe = 1;
  79. var animation = [CPDictionary dictionaryWithObjects:[myView2, aStartFrame, anEndFrame, CPViewAnimationEffectKey]
  80. forKeys:[CPViewAnimationTargetKey, CPViewAnimationStartFrameKey, CPViewAnimationEndFrameKey, CPViewAnimationEffectKey]];
  81. console.log(animation);
  82. var cpViewAnimation = [[CPViewAnimation alloc] initWithViewAnimations:[animation]];
  83. [cpViewAnimation startAnimation];
  84. }
  85.  
  86. @end
Add Comment
Please, Sign In to add comment