1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-23 18:31:53 +00:00

Switches brace style, to bring this into line with other source files.

This commit is contained in:
Thomas Harte 2019-03-06 21:54:21 -05:00
parent 0ace189e38
commit 42997dcb80

View File

@ -21,8 +21,7 @@
NSTimer *_mouseHideTimer; NSTimer *_mouseHideTimer;
} }
- (void)prepareOpenGL - (void)prepareOpenGL {
{
// Synchronize buffer swaps with vertical refresh rate // Synchronize buffer swaps with vertical refresh rate
GLint swapInt = 1; GLint swapInt = 1;
[[self openGLContext] setValues:&swapInt forParameter:NSOpenGLCPSwapInterval]; [[self openGLContext] setValues:&swapInt forParameter:NSOpenGLCPSwapInterval];
@ -46,51 +45,43 @@
CVDisplayLinkStart(_displayLink); CVDisplayLinkStart(_displayLink);
} }
static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeStamp *now, const CVTimeStamp *outputTime, CVOptionFlags flagsIn, CVOptionFlags *flagsOut, void *displayLinkContext) static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeStamp *now, const CVTimeStamp *outputTime, CVOptionFlags flagsIn, CVOptionFlags *flagsOut, void *displayLinkContext) {
{
CSOpenGLView *const view = (__bridge CSOpenGLView *)displayLinkContext; CSOpenGLView *const view = (__bridge CSOpenGLView *)displayLinkContext;
[view drawAtTime:now frequency:CVDisplayLinkGetActualOutputVideoRefreshPeriod(displayLink)]; [view drawAtTime:now frequency:CVDisplayLinkGetActualOutputVideoRefreshPeriod(displayLink)];
return kCVReturnSuccess; return kCVReturnSuccess;
} }
- (void)drawAtTime:(const CVTimeStamp *)now frequency:(double)frequency - (void)drawAtTime:(const CVTimeStamp *)now frequency:(double)frequency {
{
[self redrawWithEvent:CSOpenGLViewRedrawEventTimer]; [self redrawWithEvent:CSOpenGLViewRedrawEventTimer];
} }
- (void)drawRect:(NSRect)dirtyRect - (void)drawRect:(NSRect)dirtyRect {
{
[self redrawWithEvent:CSOpenGLViewRedrawEventAppKit]; [self redrawWithEvent:CSOpenGLViewRedrawEventAppKit];
} }
- (void)redrawWithEvent:(CSOpenGLViewRedrawEvent)event - (void)redrawWithEvent:(CSOpenGLViewRedrawEvent)event {
{
[self performWithGLContext:^{ [self performWithGLContext:^{
[self.delegate openGLViewRedraw:self event:event]; [self.delegate openGLViewRedraw:self event:event];
CGLFlushDrawable([[self openGLContext] CGLContextObj]); CGLFlushDrawable([[self openGLContext] CGLContextObj]);
}]; }];
} }
- (void)invalidate - (void)invalidate {
{
CVDisplayLinkStop(_displayLink); CVDisplayLinkStop(_displayLink);
} }
- (void)dealloc - (void)dealloc {
{
// Release the display link // Release the display link
CVDisplayLinkRelease(_displayLink); CVDisplayLinkRelease(_displayLink);
} }
- (CGSize)backingSize - (CGSize)backingSize {
{
@synchronized(self) { @synchronized(self) {
return _backingSize; return _backingSize;
} }
} }
- (void)reshape - (void)reshape {
{
[super reshape]; [super reshape];
@synchronized(self) { @synchronized(self) {
_backingSize = [self convertSizeToBacking:self.bounds.size]; _backingSize = [self convertSizeToBacking:self.bounds.size];
@ -102,10 +93,8 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
}]; }];
} }
- (void)awakeFromNib - (void)awakeFromNib {
{ NSOpenGLPixelFormatAttribute attributes[] = {
NSOpenGLPixelFormatAttribute attributes[] =
{
NSOpenGLPFADoubleBuffer, NSOpenGLPFADoubleBuffer,
NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core, NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core,
// NSOpenGLPFAMultisample, // NSOpenGLPFAMultisample,
@ -134,8 +123,7 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
[self registerForDraggedTypes:@[(__bridge NSString *)kUTTypeFileURL]]; [self registerForDraggedTypes:@[(__bridge NSString *)kUTTypeFileURL]];
} }
- (void)performWithGLContext:(dispatch_block_t)action - (void)performWithGLContext:(dispatch_block_t)action {
{
CGLLockContext([[self openGLContext] CGLContextObj]); CGLLockContext([[self openGLContext] CGLContextObj]);
[self.openGLContext makeCurrentContext]; [self.openGLContext makeCurrentContext];
action(); action();
@ -144,46 +132,37 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
#pragma mark - NSResponder #pragma mark - NSResponder
- (BOOL)acceptsFirstResponder - (BOOL)acceptsFirstResponder {
{
return YES; return YES;
} }
- (void)keyDown:(NSEvent *)theEvent - (void)keyDown:(NSEvent *)theEvent {
{
[self.responderDelegate keyDown:theEvent]; [self.responderDelegate keyDown:theEvent];
} }
- (void)keyUp:(NSEvent *)theEvent - (void)keyUp:(NSEvent *)theEvent {
{
[self.responderDelegate keyUp:theEvent]; [self.responderDelegate keyUp:theEvent];
} }
- (void)flagsChanged:(NSEvent *)theEvent - (void)flagsChanged:(NSEvent *)theEvent {
{
[self.responderDelegate flagsChanged:theEvent]; [self.responderDelegate flagsChanged:theEvent];
} }
- (void)paste:(id)sender - (void)paste:(id)sender {
{
[self.responderDelegate paste:sender]; [self.responderDelegate paste:sender];
} }
#pragma mark - NSDraggingDestination #pragma mark - NSDraggingDestination
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender {
{ for(NSPasteboardItem *item in [[sender draggingPasteboard] pasteboardItems]) {
for(NSPasteboardItem *item in [[sender draggingPasteboard] pasteboardItems])
{
NSURL *URL = [NSURL URLWithString:[item stringForType:(__bridge NSString *)kUTTypeFileURL]]; NSURL *URL = [NSURL URLWithString:[item stringForType:(__bridge NSString *)kUTTypeFileURL]];
[self.delegate openGLView:self didReceiveFileAtURL:URL]; [self.delegate openGLView:self didReceiveFileAtURL:URL];
} }
return YES; return YES;
} }
- (NSDragOperation)draggingEntered:(id < NSDraggingInfo >)sender - (NSDragOperation)draggingEntered:(id < NSDraggingInfo >)sender {
{
// we'll drag and drop, yeah?
return NSDragOperationLink; return NSDragOperationLink;
} }