Skip to content

Commit

Permalink
documents progress and add contacts and many design changes
Browse files Browse the repository at this point in the history
  • Loading branch information
overtake committed Oct 18, 2014
1 parent 43e58e0 commit 3274c8d
Show file tree
Hide file tree
Showing 166 changed files with 10,367 additions and 1,413 deletions.
Binary file modified .DS_Store
Binary file not shown.
24 changes: 24 additions & 0 deletions GLView.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// GLView.h
// Telegram
//
// Created by keepcoder on 16.10.14.
// Copyright (c) 2014 keepcoder. All rights reserved.
//

#import <Cocoa/Cocoa.h>

// for display link
#import <QuartzCore/QuartzCore.h>

@interface GLView : NSOpenGLView
{
CVDisplayLinkRef displayLink;

double deltaTime;
double outputTime;
float viewWidth;
float viewHeight;
}

@end
136 changes: 136 additions & 0 deletions GLView.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
#import "GLView.h"

@interface GLView (InternalMethods)

- (CVReturn)getFrameForTime:(const CVTimeStamp *)outputTime;
- (void)drawFrame;

@end

@implementation GLView

#pragma mark -
#pragma mark Display Link

static CVReturn MyDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeStamp *now,
const CVTimeStamp *outputTime, CVOptionFlags flagsIn,
CVOptionFlags *flagsOut, void *displayLinkContext)
{
// go back to Obj-C for easy access to instance variables
CVReturn result = [(__bridge GLView *)displayLinkContext getFrameForTime:outputTime];
return result;
}

- (CVReturn)getFrameForTime:(const CVTimeStamp *)outputTime
{
// deltaTime is unused in this bare bones demo, but here's how to calculate it using display link info
deltaTime = 1.0 / (outputTime->rateScalar * (double)outputTime->videoTimeScale / (double)outputTime->videoRefreshPeriod);

[self drawFrame];

return kCVReturnSuccess;
}

- (void)dealloc
{
CVDisplayLinkRelease(displayLink);

}

- (id)initWithFrame:(NSRect)frameRect
{
// context setup
NSOpenGLPixelFormat *windowedPixelFormat;
NSOpenGLPixelFormatAttribute attribs[] = {
NSOpenGLPFAWindow,
NSOpenGLPFAColorSize, 32,
NSOpenGLPFAAccelerated,
NSOpenGLPFADoubleBuffer,
NSOpenGLPFASingleRenderer,
0 };

windowedPixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attribs];
if (windowedPixelFormat == nil)
{
NSLog(@"Unable to create windowed pixel format.");
exit(0);
}
self = [super initWithFrame:frameRect pixelFormat:windowedPixelFormat];
if (self == nil)
{
NSLog(@"Unable to create a windowed OpenGL context.");
exit(0);
}

// set synch to VBL to eliminate tearing
GLint vblSynch = 1;
[[self openGLContext] setValues:&vblSynch forParameter:NSOpenGLCPSwapInterval];

// set up the display link
CVDisplayLinkCreateWithActiveCGDisplays(&displayLink);
CVDisplayLinkSetOutputCallback(displayLink, MyDisplayLinkCallback, (__bridge void *)(self));
CGLContextObj cglContext = (CGLContextObj)[[self openGLContext] CGLContextObj];
CGLPixelFormatObj cglPixelFormat = (CGLPixelFormatObj)[[self pixelFormat] CGLPixelFormatObj];
CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext(displayLink, cglContext, cglPixelFormat);

return self;
}

- (void)awakeFromNib
{
NSSize viewBounds = [self bounds].size;
viewWidth = viewBounds.width;
viewHeight = viewBounds.height;

// activate the display link
CVDisplayLinkStart(displayLink);
}

- (void)reshape
{
NSSize viewBounds = [self bounds].size;
viewWidth = viewBounds.width;
viewHeight = viewBounds.height;

NSOpenGLContext *currentContext = [self openGLContext];
[currentContext makeCurrentContext];

// remember to lock the context before we touch it since display link is threaded
CGLLockContext((CGLContextObj)[currentContext CGLContextObj]);

// let the context know we've changed size
[[self openGLContext] update];

CGLUnlockContext((CGLContextObj)[currentContext CGLContextObj]);
}

- (void)drawRect:(NSRect)rect
{
[self drawFrame];
}

- (void)drawFrame
{
NSOpenGLContext *currentContext = [self openGLContext];
[currentContext makeCurrentContext];

// must lock GL context because display link is threaded
CGLLockContext((CGLContextObj)[currentContext CGLContextObj]);

glViewport(0, 0, viewWidth, viewHeight);

// Draw something that changes over time to prove to yourself that it's really updating in a tight loop
glClearColor(
sin(CFAbsoluteTimeGetCurrent()),
sin(7.0*CFAbsoluteTimeGetCurrent()),
sin(CFAbsoluteTimeGetCurrent()/3.0),0);
glClear(GL_COLOR_BUFFER_BIT);

// draw here

[currentContext flushBuffer];

CGLUnlockContext((CGLContextObj)[currentContext CGLContextObj]);
}

@end
28 changes: 28 additions & 0 deletions POP.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
Copyright (c) 2014-present, Facebook, Inc.
All rights reserved.
This source code is licensed under the BSD-style license found in the
LICENSE file in the root directory of this source tree. An additional grant
of patent rights can be found in the PATENTS file in the same directory.
*/

#ifndef POP_POP_H
#define POP_POP_H

#import "POPAnimatableProperty.h"
#import "POPAnimation.h"
#import "POPAnimationEvent.h"
#import "POPAnimationExtras.h"
#import "POPAnimationTracer.h"
#import "POPAnimator.h"
#import "POPBasicAnimation.h"
#import "POPCustomAnimation.h"
#import "POPDecayAnimation.h"
#import "POPDefines.h"
#import "POPGeometry.h"
#import "POPPropertyAnimation.h"
#import "POPSpringAnimation.h"


#endif /* POP_POP_H */
66 changes: 66 additions & 0 deletions POPAction.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/**
Copyright (c) 2014-present, Facebook, Inc.
All rights reserved.
This source code is licensed under the BSD-style license found in the
LICENSE file in the root directory of this source tree. An additional grant
of patent rights can be found in the PATENTS file in the same directory.
*/

#ifndef POPACTION_H
#define POPACTION_H

#import <QuartzCore/CATransaction.h>
#import "POPDefines.h"

#ifdef __cplusplus

namespace POP {

/**
@abstract Disables Core Animation actions using RAII.
@discussion The disablement of actions is scoped to the current transaction.
*/
class ActionDisabler
{
BOOL state;

public:
ActionDisabler() POP_NOTHROW
{
state = [CATransaction disableActions];
[CATransaction setDisableActions:YES];
}

~ActionDisabler()
{
[CATransaction setDisableActions:state];
}
};

/**
@abstract Enables Core Animation actions using RAII.
@discussion The enablement of actions is scoped to the current transaction.
*/
class ActionEnabler
{
BOOL state;

public:
ActionEnabler() POP_NOTHROW
{
state = [CATransaction disableActions];
[CATransaction setDisableActions:NO];
}

~ActionEnabler()
{
[CATransaction setDisableActions:state];
}
};

}

#endif /* __cplusplus */

#endif /* POPACTION_H */
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@
extern NSString * const kPOPLayerBackgroundColor;
extern NSString * const kPOPLayerBounds;
extern NSString * const kPOPLayerCornerRadius;
extern NSString * const kPOPLayerBorderWidth;
extern NSString * const kPOPLayerBorderColor;
extern NSString * const kPOPLayerOpacity;
extern NSString * const kPOPLayerPosition;
extern NSString * const kPOPLayerPositionX;
Expand Down Expand Up @@ -122,6 +124,7 @@ extern NSString * const kPOPLayerShadowRadius;
extern NSString * const kPOPShapeLayerStrokeStart;
extern NSString * const kPOPShapeLayerStrokeEnd;
extern NSString * const kPOPShapeLayerStrokeColor;
extern NSString * const kPOPShapeLayerFillColor;

/**
Common NSLayoutConstraint property names.
Expand All @@ -143,21 +146,28 @@ extern NSString * const kPOPViewScaleX;
extern NSString * const kPOPViewScaleXY;
extern NSString * const kPOPViewScaleY;
extern NSString * const kPOPViewSize;

extern NSString * const kPOPViewTintColor;

/**
Common UIScrollView property names.
*/
extern NSString * const kPOPScrollViewContentOffset;
extern NSString * const kPOPScrollViewContentSize;
extern NSString * const kPOPScrollViewZoomScale;
extern NSString * const kPOPScrollViewContentInset;

/**
Common UITableView property names.
*/
extern NSString * const kPOPTableViewContentOffset;
extern NSString * const kPOPTableViewContentSize;

/**
Common UICollectionView property names.
*/
extern NSString * const kPOPCollectionViewContentOffset;
extern NSString * const kPOPCollectionViewContentSize;

/**
Common UINavigationBar property names.
*/
Expand Down
Loading

0 comments on commit 3274c8d

Please sign in to comment.