Vuo  2.3.2
VuoAppSplashView.m
Go to the documentation of this file.
1 
10 #include "VuoMacOSSDKWorkaround.h"
11 #import <AppKit/AppKit.h>
12 
13 #import "VuoAppSplashView.h"
14 #import "VuoAppSplashWindow.h"
15 #import "module.h"
16 
17 #import "vuo-wordmark-teal-cropped.h"
18 
20 NSString *windowURL = @"https://vuo.org/";
22 NSString *windowURLCE = @"https://vuo.org/community-edition";
24 NSString *windowURLLabel = @"vuo.org";
26 NSString *windowURLCELabel = @"vuo.org/community-edition";
27 
28 @implementation VuoAppSplashView
29 
30 - (instancetype)init
31 {
32  if (self = [super init])
33  {
34  _borderVisible = YES;
35  }
36  return self;
37 }
38 
39 - (void)drawRect:(NSRect)rect
40 {
41  double windowWidth = self.bounds.size.width;
42  double windowHeight = self.bounds.size.height;
43  bool large = windowWidth > 320;
44 
45  if (large)
46  [NSColor.controlBackgroundColor setFill];
47  else
48  [NSColor.clearColor setFill];
49  [NSColor.windowBackgroundColor setStroke];
50  NSBezierPath *path = [NSBezierPath bezierPathWithRect:rect];
51  path.lineWidth = 2;
52  [path fill];
53  if (_borderVisible)
54  [path stroke];
55 
56 
57  NSData *logoData = [NSData dataWithBytesNoCopy:vuo_wordmark_teal_cropped_pdf
58  length:vuo_wordmark_teal_cropped_pdf_len
59  freeWhenDone:NO];
60  NSImage *logoImage = [[NSImage alloc] initWithData:logoData];
61 
62  NSMutableParagraphStyle *textStyle = NSMutableParagraphStyle.defaultParagraphStyle.mutableCopy;
63  textStyle.alignment = NSTextAlignmentCenter;
64  NSMutableDictionary *textAttributes = [NSMutableDictionary dictionaryWithObjectsAndKeys:
65  [NSFont fontWithName:@"Helvetica Neue Light" size:(large ? 18 : 13)], NSFontAttributeName,
66  NSColor.secondaryLabelColor, NSForegroundColorAttributeName,
67  textStyle, NSParagraphStyleAttributeName,
68  @2.5, NSKernAttributeName,
69  nil
70  ];
71 
72  [@"Powered by" drawInRect:NSMakeRect(0, windowHeight*5/8, windowWidth, windowHeight/4)
73  withAttributes:textAttributes];
74 
75  // Draw the logo centered in the window.
76  {
77  double imageAspect = logoImage.size.width / logoImage.size.height;
78  double imageScale = .5;
79  [logoImage drawInRect:NSMakeRect(windowWidth/2 - windowWidth*imageScale/2,
80  windowHeight/2 - windowWidth*imageScale/imageAspect/2,
81  windowWidth*imageScale,
82  windowWidth*imageScale/imageAspect)];
83  }
84 
86  textAttributes[NSKernAttributeName] = @0;
87  textAttributes[NSUnderlineStyleAttributeName] = @(NSUnderlineStyleSingle);
88  textAttributes[NSUnderlineColorAttributeName] = NSColor.tertiaryLabelColor;
89  [urlLabel drawInRect:NSMakeRect(0, windowHeight*-1/16, windowWidth, windowHeight/4)
90  withAttributes:textAttributes];
91 
92  [logoImage release];
93  [textStyle release];
94 }
95 
96 - (void)mouseDown:(NSEvent *)event
97 {
98  [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:(VuoShouldShowSplashWindow() ? windowURLCE : windowURL)]];
99 }
100 
101 - (void)resetCursorRects
102 {
103  [self addCursorRect:self.visibleRect cursor:NSCursor.pointingHandCursor];
104 }
105 
106 @end