Cocoa SampleApp files
http://codereview.appspot.com/4843041/ http://codereview.appspot.com/4832044/ http://codereview.appspot.com/4826061/ git-svn-id: http://skia.googlecode.com/svn/trunk@2012 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
dea2f8d863
commit
12d177d1f3
32
experimental/CocoaSampleApp/SampleApp-Info.plist
Normal file
32
experimental/CocoaSampleApp/SampleApp-Info.plist
Normal file
@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string></string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.yourcompany.${PRODUCT_NAME:rfc1034identifier}</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
|
||||
<key>NSMainNibFile</key>
|
||||
<string>SampleApp</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
</dict>
|
||||
</plist>
|
3936
experimental/CocoaSampleApp/SampleApp.xib
Normal file
3936
experimental/CocoaSampleApp/SampleApp.xib
Normal file
File diff suppressed because it is too large
Load Diff
16
experimental/CocoaSampleApp/SampleAppDelegate.h
Normal file
16
experimental/CocoaSampleApp/SampleAppDelegate.h
Normal file
@ -0,0 +1,16 @@
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "SkNSView.h"
|
||||
#import "SkOptionsTableView.h"
|
||||
@interface SampleAppDelegate : NSObject <NSApplicationDelegate> {
|
||||
NSWindow* fWindow;
|
||||
SkNSView* fView;
|
||||
SkOptionsTableView* fOptions;
|
||||
}
|
||||
|
||||
@property (assign) IBOutlet NSWindow* fWindow;
|
||||
@property (assign) IBOutlet SkNSView* fView;
|
||||
@property (assign) IBOutlet SkOptionsTableView* fOptions;
|
||||
|
||||
- (IBAction)decreaseWindowSize:(id)sender;
|
||||
- (IBAction)increaseWindowSize:(id)sender;
|
||||
@end
|
31
experimental/CocoaSampleApp/SampleAppDelegate.mm
Normal file
31
experimental/CocoaSampleApp/SampleAppDelegate.mm
Normal file
@ -0,0 +1,31 @@
|
||||
#import "SampleAppDelegate.h"
|
||||
@implementation SampleAppDelegate
|
||||
@synthesize fWindow, fView, fOptions;
|
||||
|
||||
-(void) applicationDidFinishLaunching:(NSNotification *)aNotification {
|
||||
//Load specified skia views after launching
|
||||
fView.fOptionsDelegate = fOptions;
|
||||
[fOptions registerMenus:fView.fWind->getMenus()];
|
||||
}
|
||||
|
||||
static float deltaw = 120;
|
||||
static float deltah = 80;
|
||||
|
||||
- (IBAction)decreaseWindowSize:(id)sender {
|
||||
NSRect frame = [fWindow frame];
|
||||
frame.origin.y += deltah;
|
||||
frame.size.width -=deltaw;
|
||||
frame.size.height -= deltah;
|
||||
|
||||
[fWindow setFrame:frame display:YES animate:YES];
|
||||
}
|
||||
|
||||
- (IBAction)increaseWindowSize:(id)sender {
|
||||
NSRect frame = [fWindow frame];
|
||||
frame.origin.y -= deltah;
|
||||
frame.size.width += deltaw;
|
||||
frame.size.height += deltah;
|
||||
|
||||
[fWindow setFrame:frame display:YES animate:YES];
|
||||
}
|
||||
@end
|
42
experimental/CocoaSampleApp/SkNSView.h
Normal file
42
experimental/CocoaSampleApp/SkNSView.h
Normal file
@ -0,0 +1,42 @@
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#include "SampleApp.h"
|
||||
|
||||
class SkOSWindow;
|
||||
class SkEvent;
|
||||
@class SkNSView;
|
||||
|
||||
@protocol SkNSViewOptionsDelegate <NSObject>
|
||||
@optional
|
||||
// Called when the view needs to handle adding an SkOSMenu
|
||||
- (void) view:(SkNSView*)view didAddMenu:(const SkOSMenu*)menu;
|
||||
- (void) view:(SkNSView*)view didUpdateMenu:(const SkOSMenu*)menu;
|
||||
@end
|
||||
|
||||
@interface SkNSView : NSView {
|
||||
BOOL fRedrawRequestPending;
|
||||
|
||||
NSString* fTitle;
|
||||
SkOSWindow* fWind;
|
||||
|
||||
NSOpenGLContext* fGLContext;
|
||||
id<SkNSViewOptionsDelegate> fOptionsDelegate;
|
||||
}
|
||||
|
||||
@property (nonatomic, readonly) SkOSWindow *fWind;
|
||||
@property (nonatomic, retain) NSString* fTitle;
|
||||
@property (nonatomic, retain) NSOpenGLContext* fGLContext;
|
||||
@property (nonatomic, assign) id<SkNSViewOptionsDelegate> fOptionsDelegate;
|
||||
|
||||
- (id)initWithMyDefaults;
|
||||
|
||||
- (void)setSkTitle:(const char*)title;
|
||||
- (void)onAddMenu:(const SkOSMenu*)menu;
|
||||
- (void)onUpdateMenu:(const SkOSMenu*)menu;
|
||||
- (void)postInvalWithRect:(const SkIRect*)rectOrNil;
|
||||
- (BOOL)onHandleEvent:(const SkEvent&)event;
|
||||
|
||||
- (void)attachGL;
|
||||
- (void)detachGL;
|
||||
- (void)presentGL;
|
||||
@end
|
278
experimental/CocoaSampleApp/SkNSView.mm
Normal file
278
experimental/CocoaSampleApp/SkNSView.mm
Normal file
@ -0,0 +1,278 @@
|
||||
#import "SkNSView.h"
|
||||
#include "SkApplication.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "GrContext.h"
|
||||
#include "SkCGUtils.h"
|
||||
#include "SkEvent.h"
|
||||
#include "GrGLInterface.h"
|
||||
#include "SkGpuDevice.h"
|
||||
|
||||
//#define FORCE_REDRAW
|
||||
@implementation SkNSView
|
||||
@synthesize fWind, fTitle, fOptionsDelegate, fGLContext;
|
||||
|
||||
- (id)initWithCoder:(NSCoder*)coder {
|
||||
if ((self = [super initWithCoder:coder])) {
|
||||
self = [self initWithMyDefaults];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(NSRect)frameRect {
|
||||
if (self = [super initWithFrame:frameRect]) {
|
||||
self = [self initWithMyDefaults];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)initWithMyDefaults {
|
||||
fRedrawRequestPending = false;
|
||||
fWind = new SampleWindow(self, NULL, NULL, NULL);
|
||||
application_init();
|
||||
fWind->resize(self.frame.size.width, self.frame.size.height,
|
||||
SkBitmap::kARGB_8888_Config);
|
||||
return self;
|
||||
}
|
||||
|
||||
-(BOOL) isFlipped {
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)acceptsFirstResponder {
|
||||
return YES;
|
||||
}
|
||||
|
||||
-(BOOL) inLiveResize {
|
||||
if (fWind != NULL) {
|
||||
NSSize s = [self frame].size;
|
||||
fWind->resize(s.width, s.height);
|
||||
[fGLContext update];
|
||||
}
|
||||
return [super inLiveResize];
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
delete fWind;
|
||||
self.fGLContext = nil;
|
||||
self.fTitle = nil;
|
||||
application_term();
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void)layoutSubviews {
|
||||
NSSize rect = self.bounds.size;
|
||||
fWind->resize(rect.width, rect.height);
|
||||
fWind->inval(NULL);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
- (void)drawWithCanvas:(SkCanvas*)canvas {
|
||||
fRedrawRequestPending = false;
|
||||
fWind->draw(canvas);
|
||||
#ifdef FORCE_REDRAW
|
||||
fWind->inval(NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)drawRect:(NSRect)dirtyRect {
|
||||
SkCanvas canvas(fWind->getBitmap());
|
||||
[self drawWithCanvas:&canvas];
|
||||
CGContextRef ctx = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
|
||||
SkCGDrawBitmap(ctx, fWind->getBitmap(), 0, 0);
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "SkKey.h"
|
||||
enum {
|
||||
SK_MacReturnKey = 36,
|
||||
SK_MacDeleteKey = 51,
|
||||
SK_MacEndKey = 119,
|
||||
SK_MacLeftKey = 123,
|
||||
SK_MacRightKey = 124,
|
||||
SK_MacDownKey = 125,
|
||||
SK_MacUpKey = 126,
|
||||
SK_Mac0Key = 0x52,
|
||||
SK_Mac1Key = 0x53,
|
||||
SK_Mac2Key = 0x54,
|
||||
SK_Mac3Key = 0x55,
|
||||
SK_Mac4Key = 0x56,
|
||||
SK_Mac5Key = 0x57,
|
||||
SK_Mac6Key = 0x58,
|
||||
SK_Mac7Key = 0x59,
|
||||
SK_Mac8Key = 0x5b,
|
||||
SK_Mac9Key = 0x5c
|
||||
};
|
||||
|
||||
static SkKey raw2key(UInt32 raw)
|
||||
{
|
||||
static const struct {
|
||||
UInt32 fRaw;
|
||||
SkKey fKey;
|
||||
} gKeys[] = {
|
||||
{ SK_MacUpKey, kUp_SkKey },
|
||||
{ SK_MacDownKey, kDown_SkKey },
|
||||
{ SK_MacLeftKey, kLeft_SkKey },
|
||||
{ SK_MacRightKey, kRight_SkKey },
|
||||
{ SK_MacReturnKey, kOK_SkKey },
|
||||
{ SK_MacDeleteKey, kBack_SkKey },
|
||||
{ SK_MacEndKey, kEnd_SkKey },
|
||||
{ SK_Mac0Key, k0_SkKey },
|
||||
{ SK_Mac1Key, k1_SkKey },
|
||||
{ SK_Mac2Key, k2_SkKey },
|
||||
{ SK_Mac3Key, k3_SkKey },
|
||||
{ SK_Mac4Key, k4_SkKey },
|
||||
{ SK_Mac5Key, k5_SkKey },
|
||||
{ SK_Mac6Key, k6_SkKey },
|
||||
{ SK_Mac7Key, k7_SkKey },
|
||||
{ SK_Mac8Key, k8_SkKey },
|
||||
{ SK_Mac9Key, k9_SkKey }
|
||||
};
|
||||
|
||||
for (unsigned i = 0; i < SK_ARRAY_COUNT(gKeys); i++)
|
||||
if (gKeys[i].fRaw == raw)
|
||||
return gKeys[i].fKey;
|
||||
return kNONE_SkKey;
|
||||
}
|
||||
|
||||
- (void)keyDown:(NSEvent *)event {
|
||||
SkKey key = raw2key([event keyCode]);
|
||||
if (kNONE_SkKey != key)
|
||||
fWind->handleKey(key);
|
||||
else{
|
||||
unichar c = [[event characters] characterAtIndex:0];
|
||||
fWind->handleChar((SkUnichar)c);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)keyUp:(NSEvent *)event {
|
||||
SkKey key = raw2key([event keyCode]);
|
||||
if (kNONE_SkKey != key)
|
||||
fWind->handleKeyUp(key);
|
||||
else{
|
||||
unichar c = [[event characters] characterAtIndex:0];
|
||||
//fWind->handleChar((SkUnichar)c);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)mouseDown:(NSEvent *)event {
|
||||
NSPoint p = [event locationInWindow];
|
||||
if ([self mouse:p inRect:[self bounds]]) { //unecessary for a window with a single view
|
||||
NSPoint loc = [self convertPoint:p fromView:nil];
|
||||
fWind->handleClick(loc.x, loc.y, SkView::Click::kDown_State, self);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)mouseDragged:(NSEvent *)event {
|
||||
NSPoint p = [event locationInWindow];
|
||||
if ([self mouse:p inRect:[self bounds]]) {
|
||||
NSPoint loc = [self convertPoint:p fromView:nil];
|
||||
fWind->handleClick(loc.x, loc.y, SkView::Click::kMoved_State, self);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)mouseUp:(NSEvent *)event {
|
||||
NSPoint p = [event locationInWindow];
|
||||
if ([self mouse:p inRect:[self bounds]]) {
|
||||
NSPoint loc = [self convertPoint:p fromView:nil];
|
||||
fWind->handleClick(loc.x, loc.y, SkView::Click::kUp_State, self);
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
- (void)setSkTitle:(const char *)title {
|
||||
NSString* text = [NSString stringWithUTF8String:title];
|
||||
if ([text length] > 0)
|
||||
self.fTitle = text;
|
||||
[[self window] setTitle:fTitle];
|
||||
}
|
||||
|
||||
- (BOOL)onHandleEvent:(const SkEvent&)evt {
|
||||
return false;
|
||||
}
|
||||
|
||||
#include "SkOSMenu.h"
|
||||
- (void)onAddMenu:(const SkOSMenu*)menu {
|
||||
[self.fOptionsDelegate view:self didAddMenu:menu];
|
||||
}
|
||||
|
||||
- (void)onUpdateMenu:(const SkOSMenu*)menu {
|
||||
[self.fOptionsDelegate view:self didUpdateMenu:menu];
|
||||
}
|
||||
|
||||
- (void)postInvalWithRect:(const SkIRect*)r {
|
||||
if (!fRedrawRequestPending) {
|
||||
fRedrawRequestPending = true;
|
||||
[self performSelector:@selector(display) withObject:nil afterDelay:0];
|
||||
}
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#include <OpenGL/OpenGL.h>
|
||||
|
||||
CGLContextObj createGLContext() {
|
||||
GLint major, minor;
|
||||
CGLContextObj ctx;
|
||||
|
||||
CGLGetVersion(&major, &minor);
|
||||
SkDebugf("---- cgl version %d %d\n", major, minor);
|
||||
|
||||
const CGLPixelFormatAttribute attributes[] = {
|
||||
kCGLPFAStencilSize, (CGLPixelFormatAttribute)8,
|
||||
#if USE_MSAA
|
||||
kCGLPFASampleBuffers, 1,
|
||||
kCGLPFAMultisample,
|
||||
kCGLPFASamples, 8,
|
||||
#endif
|
||||
kCGLPFAAccelerated,
|
||||
kCGLPFADoubleBuffer,
|
||||
(CGLPixelFormatAttribute)0
|
||||
};
|
||||
|
||||
CGLPixelFormatObj format;
|
||||
GLint npix;
|
||||
CGLChoosePixelFormat(attributes, &format, &npix);
|
||||
SkDebugf("----- cgl format %p\n", format);
|
||||
|
||||
CGLCreateContext(format, NULL, &ctx);
|
||||
|
||||
SkDebugf("----- cgl context %p\n", ctx);
|
||||
CGLDestroyPixelFormat(format);
|
||||
|
||||
static const GLint interval = 1;
|
||||
CGLSetParameter(ctx, kCGLCPSwapInterval, &interval);
|
||||
CGLSetCurrentContext(ctx);
|
||||
return ctx;
|
||||
}
|
||||
|
||||
- (void)viewDidMoveToWindow {
|
||||
[super viewDidMoveToWindow];
|
||||
|
||||
//Attaching view to fGLContext requires that the view to be part of a window,
|
||||
//and that the NSWindow instance must have a CoreGraphics counterpart (or
|
||||
//it must NOT be deferred or should have been on screen at least once)
|
||||
if ([fGLContext view] != self && nil != self.window) {
|
||||
[fGLContext setView:self];
|
||||
glClear(GL_STENCIL_BUFFER_BIT);
|
||||
}
|
||||
}
|
||||
- (void)attachGL {
|
||||
if (nil == fGLContext)
|
||||
fGLContext = [[NSOpenGLContext alloc] initWithCGLContextObj:createGLContext()];
|
||||
|
||||
[fGLContext makeCurrentContext];
|
||||
|
||||
glViewport(0, 0, self.bounds.size.width, self.bounds.size.width);
|
||||
glClearColor(0, 0, 0, 0);
|
||||
glClearStencil(0);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
}
|
||||
|
||||
- (void)detachGL {
|
||||
[fGLContext clearDrawable];
|
||||
}
|
||||
|
||||
- (void)presentGL {
|
||||
[fGLContext flushBuffer];
|
||||
}
|
||||
@end
|
36
experimental/CocoaSampleApp/SkOSWindow_Mac.h
Normal file
36
experimental/CocoaSampleApp/SkOSWindow_Mac.h
Normal file
@ -0,0 +1,36 @@
|
||||
#ifndef SkOSWindow_MacCocoa_DEFINED
|
||||
#define SkOSWindow_MacCocoa_DEFINED
|
||||
|
||||
#include "SkWindow.h"
|
||||
|
||||
class SkOSWindow : public SkWindow {
|
||||
public:
|
||||
SkOSWindow(void* hwnd);
|
||||
~SkOSWindow();
|
||||
void* getHWND() const { return fHWND; }
|
||||
|
||||
virtual bool onDispatchClick(int x, int y, Click::State state,
|
||||
void* owner);
|
||||
void detachGL();
|
||||
bool attachGL();
|
||||
void presentGL();
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
virtual bool onEvent(const SkEvent& evt);
|
||||
// overrides from SkWindow
|
||||
virtual void onHandleInval(const SkIRect&);
|
||||
// overrides from SkView
|
||||
virtual void onAddMenu(const SkOSMenu*);
|
||||
virtual void onUpdateMenu(const SkOSMenu*);
|
||||
virtual void onSetTitle(const char[]);
|
||||
|
||||
private:
|
||||
void* fHWND;
|
||||
bool fInvalEventIsPending;
|
||||
void* fNotifier;
|
||||
void* fGLContext;
|
||||
typedef SkWindow INHERITED;
|
||||
};
|
||||
|
||||
#endif
|
66
experimental/CocoaSampleApp/SkOSWindow_Mac.mm
Normal file
66
experimental/CocoaSampleApp/SkOSWindow_Mac.mm
Normal file
@ -0,0 +1,66 @@
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#include "SkOSWindow_Mac.h"
|
||||
#include "SkOSMenu.h"
|
||||
#include "SkTypes.h"
|
||||
#include "SkWindow.h"
|
||||
#import "SkNSView.h"
|
||||
#import "SkEventNotifier.h"
|
||||
#define kINVAL_NSVIEW_EventType "inval-nsview"
|
||||
|
||||
SkOSWindow::SkOSWindow(void* hWnd) : fHWND(hWnd) {
|
||||
fInvalEventIsPending = false;
|
||||
fGLContext = NULL;
|
||||
fNotifier = [[SkEventNotifier alloc] init];
|
||||
}
|
||||
SkOSWindow::~SkOSWindow() {
|
||||
[(SkEventNotifier*)fNotifier release];
|
||||
}
|
||||
|
||||
void SkOSWindow::onHandleInval(const SkIRect& r) {
|
||||
if (!fInvalEventIsPending) {
|
||||
fInvalEventIsPending = true;
|
||||
(new SkEvent(kINVAL_NSVIEW_EventType))->post(this->getSinkID());
|
||||
}
|
||||
}
|
||||
|
||||
bool SkOSWindow::onEvent(const SkEvent& evt) {
|
||||
if (evt.isType(kINVAL_NSVIEW_EventType)) {
|
||||
fInvalEventIsPending = false;
|
||||
const SkIRect& r = this->getDirtyBounds();
|
||||
[(SkNSView*)fHWND postInvalWithRect:&r];
|
||||
[(NSOpenGLContext*)fGLContext update];
|
||||
return true;
|
||||
}
|
||||
if ([(SkNSView*)fHWND onHandleEvent:evt]) {
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onEvent(evt);
|
||||
}
|
||||
|
||||
bool SkOSWindow::onDispatchClick(int x, int y, Click::State state, void* owner) {
|
||||
return this->INHERITED::onDispatchClick(x, y, state, owner);
|
||||
}
|
||||
|
||||
void SkOSWindow::onSetTitle(const char title[]) {
|
||||
[(SkNSView*)fHWND setSkTitle:title];
|
||||
}
|
||||
|
||||
void SkOSWindow::onAddMenu(const SkOSMenu* menu) {
|
||||
[(SkNSView*)fHWND onAddMenu:menu];
|
||||
}
|
||||
|
||||
void SkOSWindow::onUpdateMenu(const SkOSMenu* menu) {
|
||||
[(SkNSView*)fHWND onUpdateMenu:menu];
|
||||
}
|
||||
|
||||
bool SkOSWindow::attachGL() {
|
||||
[(SkNSView*)fHWND attachGL];
|
||||
}
|
||||
|
||||
void SkOSWindow::detachGL() {
|
||||
[(SkNSView*)fHWND detachGL];
|
||||
}
|
||||
|
||||
void SkOSWindow::presentGL() {
|
||||
[(SkNSView*)fHWND presentGL];
|
||||
}
|
31
experimental/CocoaSampleApp/SkOptionsTableView.h
Normal file
31
experimental/CocoaSampleApp/SkOptionsTableView.h
Normal file
@ -0,0 +1,31 @@
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "SkNSView.h"
|
||||
#import "SkOSMenu.h"
|
||||
#import "SkEvent.h"
|
||||
@interface SkOptionItem : NSObject {
|
||||
NSCell* fCell;
|
||||
const SkOSMenu::Item* fItem;
|
||||
}
|
||||
@property (nonatomic, assign) const SkOSMenu::Item* fItem;
|
||||
@property (nonatomic, retain) NSCell* fCell;
|
||||
@end
|
||||
|
||||
@interface SkOptionsTableView : NSTableView <SkNSViewOptionsDelegate, NSTableViewDelegate, NSTableViewDataSource> {
|
||||
NSMutableArray* fItems;
|
||||
const SkTDArray<SkOSMenu*>* fMenus;
|
||||
}
|
||||
@property (nonatomic, retain) NSMutableArray* fItems;
|
||||
|
||||
- (void)registerMenus:(const SkTDArray<SkOSMenu*>*)menus;
|
||||
- (void)updateMenu:(const SkOSMenu*)menu;
|
||||
- (void)loadMenu:(const SkOSMenu*)menu;
|
||||
|
||||
- (NSCell*)createAction;
|
||||
- (NSCell*)createList:(NSArray*)items current:(int)index;
|
||||
- (NSCell*)createSegmented:(NSArray*)items current:(int)index;
|
||||
- (NSCell*)createSlider:(float)value min:(float)min max:(float)max;
|
||||
- (NSCell*)createSwitch:(BOOL)state;
|
||||
- (NSCell*)createTextField:(NSString*)placeHolder;
|
||||
- (NSCell*)createTriState:(NSCellStateValue)state;
|
||||
|
||||
@end
|
279
experimental/CocoaSampleApp/SkOptionsTableView.mm
Normal file
279
experimental/CocoaSampleApp/SkOptionsTableView.mm
Normal file
@ -0,0 +1,279 @@
|
||||
#import "SkOptionsTableView.h"
|
||||
#import "SkTextFieldCell.h"
|
||||
@implementation SkOptionItem
|
||||
@synthesize fCell, fItem;
|
||||
- (void)dealloc {
|
||||
[fCell release];
|
||||
[super dealloc];
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation SkOptionsTableView
|
||||
@synthesize fItems;
|
||||
|
||||
- (id)initWithCoder:(NSCoder*)coder {
|
||||
if ((self = [super initWithCoder:coder])) {
|
||||
self.dataSource = self;
|
||||
self.delegate = self;
|
||||
[self setSelectionHighlightStyle:NSTableViewSelectionHighlightStyleNone];
|
||||
self.fItems = [NSMutableArray array];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
self.fItems = nil;
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) view:(SkNSView*)view didAddMenu:(const SkOSMenu*)menu {}
|
||||
- (void) view:(SkNSView*)view didUpdateMenu:(const SkOSMenu*)menu {
|
||||
[self updateMenu:menu];
|
||||
}
|
||||
|
||||
- (void)registerMenus:(const SkTDArray<SkOSMenu*>*)menus {
|
||||
fMenus = menus;
|
||||
for (NSUInteger i = 0; i < fMenus->count(); ++i) {
|
||||
[self loadMenu:(*fMenus)[i]];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)updateMenu:(SkOSMenu*)menu {
|
||||
// the first menu is always assumed to be the static, the second is
|
||||
// repopulated every time over and over again
|
||||
int menuIndex = fMenus->find(menu);
|
||||
if (menuIndex >= 0 && menuIndex < fMenus->count()) {
|
||||
NSUInteger first = 0;
|
||||
for (NSInteger i = 0; i < menuIndex; ++i) {
|
||||
first += (*fMenus)[i]->countItems();
|
||||
}
|
||||
[fItems removeObjectsInRange:NSMakeRange(first, [fItems count] - first)];
|
||||
[self loadMenu:menu];
|
||||
}
|
||||
[self reloadData];
|
||||
}
|
||||
|
||||
- (NSCellStateValue)triStateToNSState:(SkOSMenu::TriState)state {
|
||||
if (SkOSMenu::kOnState == state)
|
||||
return NSOnState;
|
||||
else if (SkOSMenu::kOffState == state)
|
||||
return NSOffState;
|
||||
else
|
||||
return NSMixedState;
|
||||
}
|
||||
|
||||
- (void)loadMenu:(const SkOSMenu*)menu {
|
||||
for (int i = 0; i < menu->countItems(); ++i) {
|
||||
const SkOSMenu::Item* item = menu->getItem(i);
|
||||
NSString* str;
|
||||
int index = 0;
|
||||
NSArray* optionstrs = nil;
|
||||
|
||||
SkOptionItem* option = [[SkOptionItem alloc] init];
|
||||
option.fItem = item;
|
||||
bool state = false;
|
||||
SkOSMenu::TriState tristate;
|
||||
switch (item->getType()) {
|
||||
case SkOSMenu::kAction_Type:
|
||||
option.fCell = [self createAction];
|
||||
break;
|
||||
case SkOSMenu::kList_Type:
|
||||
optionstrs = [[NSString stringWithUTF8String:item->getEvent()->findString(SkOSMenu::List_Items_Str)]
|
||||
componentsSeparatedByString:[NSString stringWithUTF8String:SkOSMenu::Delimiter]];
|
||||
item->getEvent()->findS32(item->getSlotName(), &index);
|
||||
option.fCell = [self createList:optionstrs current:index];
|
||||
break;
|
||||
case SkOSMenu::kSlider_Type:
|
||||
SkScalar min, max, value;
|
||||
item->getEvent()->findScalar(SkOSMenu::Slider_Min_Scalar, &min);
|
||||
item->getEvent()->findScalar(SkOSMenu::Slider_Max_Scalar, &max);
|
||||
item->getEvent()->findScalar(item->getSlotName(), &value);
|
||||
option.fCell = [self createSlider:value
|
||||
min:min
|
||||
max:max];
|
||||
break;
|
||||
case SkOSMenu::kSwitch_Type:
|
||||
item->getEvent()->findBool(item->getSlotName(), &state);
|
||||
option.fCell = [self createSwitch:(BOOL)state];
|
||||
break;
|
||||
case SkOSMenu::kTriState_Type:
|
||||
item->getEvent()->findS32(item->getSlotName(), (int*)&tristate);
|
||||
option.fCell = [self createTriState:[self triStateToNSState:tristate]];
|
||||
break;
|
||||
case SkOSMenu::kTextField_Type:
|
||||
str = [NSString stringWithUTF8String:item->getEvent()->findString(item->getSlotName())];
|
||||
option.fCell = [self createTextField:str];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
[fItems addObject:option];
|
||||
[option release];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView {
|
||||
return [self.fItems count];
|
||||
}
|
||||
|
||||
- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
|
||||
int columnIndex = [tableView columnWithIdentifier:[tableColumn identifier]];
|
||||
if (columnIndex == 0)
|
||||
return [NSString stringWithUTF8String:((SkOptionItem*)[fItems objectAtIndex:row]).fItem->getLabel()];
|
||||
else
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSCell *)tableView:(NSTableView *)tableView dataCellForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
|
||||
if (tableColumn) {
|
||||
int columnIndex = [tableView columnWithIdentifier:[tableColumn identifier]];
|
||||
if (columnIndex == 1)
|
||||
return [((SkOptionItem*)[fItems objectAtIndex:row]).fCell copy];
|
||||
else
|
||||
return [[[SkTextFieldCell alloc] init] autorelease];
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void)tableView:(NSTableView *)tableView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
|
||||
int columnIndex = [tableView columnWithIdentifier:[tableColumn identifier]];
|
||||
if (columnIndex == 1) {
|
||||
SkOptionItem* option = (SkOptionItem*)[self.fItems objectAtIndex:row];
|
||||
NSCell* storedCell = option.fCell;
|
||||
const SkOSMenu::Item* item = option.fItem;
|
||||
switch (item->getType()) {
|
||||
case SkOSMenu::kAction_Type:
|
||||
break;
|
||||
case SkOSMenu::kList_Type:
|
||||
[cell selectItemAtIndex:[(NSPopUpButtonCell*)storedCell indexOfSelectedItem]];
|
||||
break;
|
||||
case SkOSMenu::kSlider_Type:
|
||||
[cell setFloatValue:[storedCell floatValue]];
|
||||
break;
|
||||
case SkOSMenu::kSwitch_Type:
|
||||
[cell setTitle:storedCell.title];
|
||||
[cell setState:[(NSButtonCell*)storedCell state]];
|
||||
break;
|
||||
case SkOSMenu::kTextField_Type:
|
||||
if ([[storedCell stringValue] length] > 0)
|
||||
[cell setStringValue:[storedCell stringValue]];
|
||||
break;
|
||||
case SkOSMenu::kTriState_Type:
|
||||
[cell setTitle:storedCell.title];
|
||||
[cell setState:[(NSButtonCell*)storedCell state]];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
[(SkTextFieldCell*)cell setEditable:NO];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)tableView:(NSTableView *)tableView setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
|
||||
int columnIndex = [tableView columnWithIdentifier:[tableColumn identifier]];
|
||||
if (columnIndex == 1) {
|
||||
SkOptionItem* option = (SkOptionItem*)[self.fItems objectAtIndex:row];
|
||||
NSCell* cell = option.fCell;
|
||||
const SkOSMenu::Item* item = option.fItem;
|
||||
switch (item->getType()) {
|
||||
case SkOSMenu::kAction_Type:
|
||||
item->postEvent();
|
||||
break;
|
||||
case SkOSMenu::kList_Type:
|
||||
[(NSPopUpButtonCell*)cell selectItemAtIndex:[anObject intValue]];
|
||||
item->postEventWithInt([anObject intValue]);
|
||||
break;
|
||||
case SkOSMenu::kSlider_Type:
|
||||
[cell setFloatValue:[anObject floatValue]];
|
||||
item->postEventWithScalar([anObject floatValue]);
|
||||
break;
|
||||
case SkOSMenu::kSwitch_Type:
|
||||
[cell setState:[anObject boolValue]];
|
||||
item->postEventWithBool([anObject boolValue]);
|
||||
break;
|
||||
case SkOSMenu::kTextField_Type:
|
||||
if ([anObject length] > 0) {
|
||||
[cell setStringValue:anObject];
|
||||
item->postEventWithString([anObject UTF8String]);
|
||||
}
|
||||
break;
|
||||
case SkOSMenu::kTriState_Type:
|
||||
[cell setState:[anObject intValue]];
|
||||
item->postEventWithInt([anObject intValue]);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (NSCell*)createAction{
|
||||
NSButtonCell* cell = [[[NSButtonCell alloc] init] autorelease];
|
||||
[cell setTitle:@""];
|
||||
[cell setButtonType:NSMomentaryPushInButton];
|
||||
[cell setBezelStyle:NSSmallSquareBezelStyle];
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (NSCell*)createList:(NSArray*)items current:(int)index {
|
||||
NSPopUpButtonCell* cell = [[[NSPopUpButtonCell alloc] init] autorelease];
|
||||
[cell addItemsWithTitles:items];
|
||||
[cell selectItemAtIndex:index];
|
||||
[cell setArrowPosition:NSPopUpArrowAtBottom];
|
||||
[cell setBezelStyle:NSSmallSquareBezelStyle];
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (NSCell*)createSegmented:(NSArray*)items current:(int)index {
|
||||
NSSegmentedCell* cell = [[[NSSegmentedCell alloc] init] autorelease];
|
||||
[cell setSegmentStyle:NSSegmentStyleSmallSquare];
|
||||
[cell setSegmentCount:[items count]];
|
||||
NSUInteger i = 0;
|
||||
for (NSString* label in items) {
|
||||
[cell setLabel:label forSegment:i];
|
||||
++i;
|
||||
}
|
||||
[cell setSelectedSegment:index];
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (NSCell*)createSlider:(float)value min:(float)min max:(float)max {
|
||||
NSSliderCell* cell = [[[NSSliderCell alloc] init] autorelease];
|
||||
[cell setFloatValue:value];
|
||||
[cell setMinValue:min];
|
||||
[cell setMaxValue:max];
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (NSCell*)createSwitch:(BOOL)state {
|
||||
NSButtonCell* cell = [[[NSButtonCell alloc] init] autorelease];
|
||||
[cell setTitle:(state) ? @"On" : @"Off"];
|
||||
[cell setState:state];
|
||||
[cell setButtonType:NSSwitchButton];
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (NSCell*)createTextField:(NSString*)placeHolder; {
|
||||
SkTextFieldCell* cell = [[[SkTextFieldCell alloc] init] autorelease];
|
||||
[cell setEditable:YES];
|
||||
[cell setStringValue:@""];
|
||||
[cell setPlaceholderString:placeHolder];
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (NSCell*)createTriState:(NSCellStateValue)state {
|
||||
NSButtonCell* cell = [[[NSButtonCell alloc] init] autorelease];
|
||||
if (NSOnState == state)
|
||||
[cell setTitle:@"On"];
|
||||
else if (NSOffState == state)
|
||||
[cell setTitle:@"Off"];
|
||||
else
|
||||
[cell setTitle:@"Mixed"];
|
||||
[cell setAllowsMixedState:TRUE];
|
||||
[cell setState:(NSInteger)state];
|
||||
[cell setButtonType:NSSwitchButton];
|
||||
return cell;
|
||||
}
|
||||
@end
|
6
experimental/CocoaSampleApp/SkTextFieldCell.h
Normal file
6
experimental/CocoaSampleApp/SkTextFieldCell.h
Normal file
@ -0,0 +1,6 @@
|
||||
#import <Cocoa/Cocoa.h>
|
||||
//A text field cell that has vertically centered text
|
||||
@interface SkTextFieldCell : NSTextFieldCell {
|
||||
BOOL selectingOrEditing;
|
||||
}
|
||||
@end
|
48
experimental/CocoaSampleApp/SkTextFieldCell.m
Normal file
48
experimental/CocoaSampleApp/SkTextFieldCell.m
Normal file
@ -0,0 +1,48 @@
|
||||
#import "SkTextFieldCell.h"
|
||||
@implementation SkTextFieldCell
|
||||
- (NSRect)drawingRectForBounds:(NSRect)theRect {
|
||||
NSRect newRect = [super drawingRectForBounds:theRect];
|
||||
if (selectingOrEditing == NO) {
|
||||
NSSize textSize = [self cellSizeForBounds:theRect];
|
||||
float heightDelta = newRect.size.height - textSize.height;
|
||||
if (heightDelta > 0) {
|
||||
newRect.size.height -= heightDelta;
|
||||
newRect.origin.y += (heightDelta / 2);
|
||||
}
|
||||
}
|
||||
return newRect;
|
||||
}
|
||||
|
||||
- (void)selectWithFrame:(NSRect)aRect
|
||||
inView:(NSView *)controlView
|
||||
editor:(NSText *)textObj
|
||||
delegate:(id)anObject
|
||||
start:(int)selStart
|
||||
length:(int)selLength {
|
||||
aRect = [self drawingRectForBounds:aRect];
|
||||
selectingOrEditing = YES;
|
||||
[super selectWithFrame:aRect
|
||||
inView:controlView
|
||||
editor:textObj
|
||||
delegate:anObject
|
||||
start:selStart
|
||||
length:selLength];
|
||||
selectingOrEditing = NO;
|
||||
}
|
||||
|
||||
- (void)editWithFrame:(NSRect)aRect
|
||||
inView:(NSView *)controlView
|
||||
editor:(NSText *)textObj
|
||||
delegate:(id)anObject
|
||||
event:(NSEvent *)theEvent {
|
||||
aRect = [self drawingRectForBounds:aRect];
|
||||
selectingOrEditing = YES;
|
||||
[super editWithFrame:aRect
|
||||
inView:controlView
|
||||
editor:textObj
|
||||
delegate:anObject
|
||||
event:theEvent];
|
||||
selectingOrEditing = NO;
|
||||
}
|
||||
|
||||
@end
|
9
experimental/CocoaSampleApp/main.m
Normal file
9
experimental/CocoaSampleApp/main.m
Normal file
@ -0,0 +1,9 @@
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
|
||||
int retVal = NSApplicationMain(argc, (const char **)argv);
|
||||
[pool release];
|
||||
return retVal;
|
||||
}
|
13
experimental/SkEventNotifier.h
Normal file
13
experimental/SkEventNotifier.h
Normal file
@ -0,0 +1,13 @@
|
||||
/*
|
||||
* Copyright 2011 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface SkEventNotifier : NSObject
|
||||
- (void)receiveSkEvent:(NSNotification*)notification;
|
||||
+ (void)postTimedSkEvent:(NSTimeInterval)ti;
|
||||
+ (void)timerFireMethod:(NSTimer*)theTimer;
|
||||
@end
|
58
experimental/SkEventNotifier.mm
Normal file
58
experimental/SkEventNotifier.mm
Normal file
@ -0,0 +1,58 @@
|
||||
#import "SkEventNotifier.h"
|
||||
#include "SkEvent.h"
|
||||
#define SkEventClass @"SkEvenClass"
|
||||
@implementation SkEventNotifier
|
||||
//Overwritten from NSObject
|
||||
- (id)init {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
//Register as an observer for SkEventClass events and call
|
||||
//receiveSkEvent: upon receiving the event
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(receiveSkEvent:)
|
||||
name:SkEventClass
|
||||
object:nil];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
-(BOOL) acceptsFirstResponder {
|
||||
return YES;
|
||||
}
|
||||
|
||||
//SkEvent Handers
|
||||
- (void)receiveSkEvent:(NSNotification *)notification {
|
||||
if(SkEvent::ProcessEvent())
|
||||
SkEvent::SignalNonEmptyQueue();
|
||||
}
|
||||
|
||||
+ (void)postTimedSkEvent:(NSTimeInterval)timeInterval {
|
||||
[NSTimer scheduledTimerWithTimeInterval:timeInterval target:self
|
||||
selector:@selector(timerFireMethod:)
|
||||
userInfo:nil repeats:NO];
|
||||
}
|
||||
|
||||
+ (void)timerFireMethod:(NSTimer*)theTimer {
|
||||
SkEvent::ServiceQueueTimer();
|
||||
}
|
||||
|
||||
@end
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void SkEvent::SignalNonEmptyQueue() {
|
||||
//post a SkEventClass event to the default notification center
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:SkEventClass
|
||||
object:nil];
|
||||
}
|
||||
|
||||
void SkEvent::SignalQueueTimer(SkMSec delay) {
|
||||
if (delay) {
|
||||
//Convert to seconds
|
||||
NSTimeInterval ti = delay/(float)SK_MSec1;
|
||||
[SkEventNotifier postTimedSkEvent:ti];
|
||||
}
|
||||
}
|
251
gyp/CocoaSampleApp.gyp
Normal file
251
gyp/CocoaSampleApp.gyp
Normal file
@ -0,0 +1,251 @@
|
||||
|
||||
{
|
||||
'includes': [
|
||||
'common.gypi',
|
||||
],
|
||||
'targets': [
|
||||
{
|
||||
'target_name': 'CocoaSampleApp',
|
||||
'type': 'executable',
|
||||
'mac_bundle' : 1,
|
||||
'include_dirs' : [
|
||||
'../src/core', # needed to get SkConcaveToTriangle, maybe this should be moved to include dir?
|
||||
'../gm', # SampleGM.cpp pulls gm.h
|
||||
'../include/pipe', # To pull in SkGPipe.h for pipe reader/writer
|
||||
],
|
||||
'sources': [
|
||||
# gm files needed for SampleGM.cpp
|
||||
'../gm/bitmapfilters.cpp',
|
||||
'../gm/blurs.cpp',
|
||||
'../gm/complexclip.cpp',
|
||||
'../gm/filltypes.cpp',
|
||||
'../gm/gm.h',
|
||||
'../gm/gradients.cpp',
|
||||
'../gm/nocolorbleed.cpp',
|
||||
'../gm/points.cpp',
|
||||
'../gm/poly2poly.cpp',
|
||||
'../gm/shadertext.cpp',
|
||||
'../gm/shadows.cpp',
|
||||
'../gm/shapes.cpp',
|
||||
'../gm/tilemodes.cpp',
|
||||
'../gm/xfermodes.cpp',
|
||||
|
||||
'../samplecode/ClockFaceView.cpp',
|
||||
'../samplecode/OverView.cpp',
|
||||
'../samplecode/Sample2PtRadial.cpp',
|
||||
'../samplecode/SampleAll.cpp',
|
||||
'../samplecode/SampleAnimator.cpp',
|
||||
'../samplecode/SampleApp.cpp',
|
||||
'../samplecode/SampleArc.cpp',
|
||||
'../samplecode/SampleAvoid.cpp',
|
||||
'../samplecode/SampleBigBlur.cpp',
|
||||
'../samplecode/SampleBigGradient.cpp',
|
||||
'../samplecode/SampleBitmapRect.cpp',
|
||||
'../samplecode/SampleBlur.cpp',
|
||||
'../samplecode/SampleCamera.cpp',
|
||||
'../samplecode/SampleCircle.cpp',
|
||||
'../samplecode/SampleCode.h',
|
||||
'../samplecode/SampleColorFilter.cpp',
|
||||
'../samplecode/SampleComplexClip.cpp',
|
||||
'../samplecode/SampleConcavePaths.cpp',
|
||||
'../samplecode/SampleCull.cpp',
|
||||
'../samplecode/SampleDecode.cpp',
|
||||
'../samplecode/SampleDegenerateTwoPtRadials.cpp',
|
||||
'../samplecode/SampleDither.cpp',
|
||||
'../samplecode/SampleDitherBitmap.cpp',
|
||||
'../samplecode/SampleDrawLooper.cpp',
|
||||
'../samplecode/SampleEffects.cpp',
|
||||
'../samplecode/SampleEmboss.cpp',
|
||||
'../samplecode/SampleEncode.cpp',
|
||||
'../samplecode/SampleExtractAlpha.cpp',
|
||||
'../samplecode/SampleFillType.cpp',
|
||||
'../samplecode/SampleFilter.cpp',
|
||||
'../samplecode/SampleFilter2.cpp',
|
||||
'../samplecode/SampleFontCache.cpp',
|
||||
'../samplecode/SampleFontScalerTest.cpp',
|
||||
'../samplecode/SampleFuzz.cpp',
|
||||
'../samplecode/SampleGM.cpp',
|
||||
'../samplecode/SampleGradients.cpp',
|
||||
'../samplecode/SampleHairline.cpp',
|
||||
'../samplecode/SampleImage.cpp',
|
||||
'../samplecode/SampleImageDir.cpp',
|
||||
'../samplecode/SampleLayerMask.cpp',
|
||||
'../samplecode/SampleLayers.cpp',
|
||||
'../samplecode/SampleLCD.cpp',
|
||||
'../samplecode/SampleLineClipper.cpp',
|
||||
'../samplecode/SampleLines.cpp',
|
||||
'../samplecode/SampleMeasure.cpp',
|
||||
'../samplecode/SampleMipMap.cpp',
|
||||
'../samplecode/SampleMovie.cpp',
|
||||
'../samplecode/SampleNinePatch.cpp',
|
||||
'../samplecode/SampleOvalTest.cpp',
|
||||
'../samplecode/SampleOverflow.cpp',
|
||||
'../samplecode/SamplePageFlip.cpp',
|
||||
'../samplecode/SamplePatch.cpp',
|
||||
'../samplecode/SamplePath.cpp',
|
||||
'../samplecode/SamplePathClip.cpp',
|
||||
'../samplecode/SamplePathEffects.cpp',
|
||||
'../samplecode/SamplePicture.cpp',
|
||||
'../samplecode/SamplePoints.cpp',
|
||||
'../samplecode/SamplePolyToPoly.cpp',
|
||||
'../samplecode/SampleAARects.cpp',
|
||||
'../samplecode/SampleRegion.cpp',
|
||||
'../samplecode/SampleRepeatTile.cpp',
|
||||
'../samplecode/SampleShaders.cpp',
|
||||
'../samplecode/SampleShaderText.cpp',
|
||||
'../samplecode/SampleShapes.cpp',
|
||||
'../samplecode/SampleSkLayer.cpp',
|
||||
'../samplecode/SampleSlides.cpp',
|
||||
'../samplecode/SampleStrokePath.cpp',
|
||||
'../samplecode/SampleStrokeText.cpp',
|
||||
'../samplecode/SampleTests.cpp',
|
||||
'../samplecode/SampleText.cpp',
|
||||
'../samplecode/SampleTextAlpha.cpp',
|
||||
'../samplecode/SampleTextBox.cpp',
|
||||
'../samplecode/SampleTextEffects.cpp',
|
||||
'../samplecode/SampleTextOnPath.cpp',
|
||||
'../samplecode/SampleTextureDomain.cpp',
|
||||
'../samplecode/SampleTiling.cpp',
|
||||
'../samplecode/SampleTinyBitmap.cpp',
|
||||
'../samplecode/SampleTriangles.cpp',
|
||||
'../samplecode/SampleTypeface.cpp',
|
||||
'../samplecode/SampleUnitMapper.cpp',
|
||||
'../samplecode/SampleVertices.cpp',
|
||||
'../samplecode/SampleXfermodes.cpp',
|
||||
'../samplecode/SampleXfermodesBlur.cpp',
|
||||
|
||||
# Dependencies for the pipe code in SampleApp
|
||||
'../src/pipe/SkGPipeRead.cpp',
|
||||
'../src/pipe/SkGPipeWrite.cpp',
|
||||
],
|
||||
'sources!': [
|
||||
'../samplecode/SampleSkLayer.cpp', #relies on SkMatrix44 which doesn't compile
|
||||
'../samplecode/SampleTests.cpp', #includes unknown file SkShaderExtras.h
|
||||
'../samplecode/SampleWarp.cpp',
|
||||
'../samplecode/SampleFontCache.cpp',
|
||||
],
|
||||
'dependencies': [
|
||||
'core.gyp:core',
|
||||
'effects.gyp:effects',
|
||||
'images.gyp:images',
|
||||
'views.gyp:views',
|
||||
'utils.gyp:utils',
|
||||
'animator.gyp:animator',
|
||||
'xml.gyp:xml',
|
||||
'svg.gyp:svg',
|
||||
'experimental.gyp:experimental',
|
||||
'gpu.gyp:gr',
|
||||
'gpu.gyp:skgr',
|
||||
'pdf.gyp:pdf',
|
||||
],
|
||||
'conditions' : [
|
||||
[ 'skia_os in ["linux", "freebsd", "openbsd", "solaris"]', {
|
||||
'sources!': [
|
||||
'../samplecode/SampleDecode.cpp',
|
||||
],
|
||||
}],
|
||||
[ 'skia_os == "win"', {
|
||||
'sources!': [
|
||||
# require UNIX functions
|
||||
'../samplecode/SampleEncode.cpp',
|
||||
'../samplecode/SamplePageFlip.cpp',
|
||||
],
|
||||
}],
|
||||
[ 'skia_os == "mac"', {
|
||||
'sources!': [
|
||||
'../samplecode/SampleDecode.cpp',
|
||||
],
|
||||
'sources': [
|
||||
'../experimental/CocoaSampleApp/main.m',
|
||||
'../experimental/CocoaSampleApp/SampleApp-Info.plist',
|
||||
'../experimental/CocoaSampleApp/SampleApp.xib',
|
||||
'../experimental/CocoaSampleApp/SampleAppDelegate.h',
|
||||
'../experimental/CocoaSampleApp/SampleAppDelegate.mm',
|
||||
'../experimental/CocoaSampleApp/SkNSView.h',
|
||||
'../experimental/CocoaSampleApp/SkNSView.mm',
|
||||
'../experimental/CocoaSampleApp/SkOSWindow_Mac.h',
|
||||
'../experimental/CocoaSampleApp/SkOSWindow_Mac.mm',
|
||||
'../experimental/CocoaSampleApp/SkOptionsTableView.h',
|
||||
'../experimental/CocoaSampleApp/SkOptionsTableView.mm',
|
||||
'../experimental/CocoaSampleApp/SkTextFieldCell.h',
|
||||
'../experimental/CocoaSampleApp/SkTextFieldCell.m',
|
||||
'../experimental/SkSockets.h',
|
||||
'../experimental/SkSockets.cpp',
|
||||
'../experimental/SkEventNotifier.h',
|
||||
'../experimental/SkEventNotifier.mm',
|
||||
],
|
||||
'link_settings': {
|
||||
'libraries': [
|
||||
'$(SDKROOT)/System/Library/Frameworks/Cocoa.framework',
|
||||
'$(SDKROOT)/System/Library/Frameworks/Foundation.framework',
|
||||
'$(SDKROOT)/System/Library/Frameworks/QuartzCore.framework',
|
||||
'$(SDKROOT)/System/Library/Frameworks/OpenGL.framework',
|
||||
],
|
||||
},
|
||||
'xcode_settings' : {
|
||||
'INFOPLIST_FILE' : '../experimental/CocoaSampleApp/SampleApp-Info.plist',
|
||||
},
|
||||
'mac_bundle_resources' : [
|
||||
'../experimental/CocoaSampleApp/SampleApp.xib',
|
||||
],
|
||||
}],
|
||||
[ 'skia_os == "ios"', {
|
||||
# TODO: This doesn't build properly yet, but it's getting there.
|
||||
'sources!': [
|
||||
'../samplecode/SampleDecode.cpp',
|
||||
],
|
||||
'sources': [
|
||||
'../experimental/iOSSampleApp/SkIOSNotifier.mm',
|
||||
'../experimental/iOSSampleApp/SkTime_iOS.mm',
|
||||
'../experimental/iOSSampleApp/SkUIDetailViewController.mm',
|
||||
'../experimental/iOSSampleApp/SkUIRootViewController.mm',
|
||||
'../experimental/iOSSampleApp/SkUIView_shell.mm',
|
||||
|
||||
'../experimental/iOSSampleApp/iOSSampleApp_Prefix.pch',
|
||||
'../experimental/iOSSampleApp/Shared/main.m',
|
||||
'../experimental/iOSSampleApp/iPad/AppDelegate_iPad.mm',
|
||||
'../experimental/iOSSampleApp/iPad/SkUISplitViewController.mm',
|
||||
'../experimental/iOSSampleApp/iPhone/AppDelegate_iPhone.mm',
|
||||
'../experimental/iOSSampleApp/iPhone/SkUINavigationController.mm',
|
||||
|
||||
'../src/utils/ios/SkOSWindow_iOS.mm',
|
||||
'../src/utils/ios/SkImageDecoder_iOS.mm',
|
||||
'../src/utils/ios/SkStream_NSData.mm',
|
||||
'../src/utils/ios/SkOSFile_iOS.mm',
|
||||
|
||||
'../src/utils/mac/SkCreateCGImageRef.cpp',
|
||||
'../experimental/iOSSampleApp/SkiOSSampleApp-Debug.xcconfig',
|
||||
'../experimental/iOSSampleApp/SkiOSSampleApp-Release.xcconfig',
|
||||
],
|
||||
'include_dirs' : [
|
||||
'../experimental/iOSSampleApp',
|
||||
'../experimental/iOSSampleApp/iPad',
|
||||
'../experimental/iOSSampleApp/iPhone',
|
||||
'../include/utils/ios',
|
||||
'../../gpu/include',
|
||||
],
|
||||
'xcode_config_file': '../experimental/iOSSampleApp/SkiOSSampleApp-Base.xcconfig',
|
||||
'mac_bundle_resources' : [
|
||||
'../experimental/iOSSampleApp/iPad/MainWindow_iPad.xib',
|
||||
'../experimental/iOSSampleApp/iPhone/MainWindow_iPhone.xib',
|
||||
],
|
||||
}],
|
||||
|
||||
],
|
||||
'msvs_settings': {
|
||||
'VCLinkerTool': {
|
||||
'SubSystem': '2',
|
||||
'AdditionalDependencies': [
|
||||
'd3d9.lib',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
# Local Variables:
|
||||
# tab-width:2
|
||||
# indent-tabs-mode:nil
|
||||
# End:
|
||||
# vim: set expandtab tabstop=2 shiftwidth=2:
|
Loading…
Reference in New Issue
Block a user