Cinder  0.8.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CinderView.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2012, The Cinder Project, All rights reserved.
3 
4  This code is intended for use with the Cinder C++ library: http://libcinder.org
5 
6  Redistribution and use in source and binary forms, with or without modification, are permitted provided that
7  the following conditions are met:
8 
9  * Redistributions of source code must retain the above copyright notice, this list of conditions and
10  the following disclaimer.
11  * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
12  the following disclaimer in the documentation and/or other materials provided with the distribution.
13 
14  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
15  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
16  PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
17  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
18  TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
19  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
20  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
21  POSSIBILITY OF SUCH DAMAGE.
22 */
23 
24 #pragma once
25 
26 #include "cinder/Cinder.h"
27 #include "cinder/app/App.h"
28 
29 #import <AppKit/NSView.h>
30 #import <Foundation/Foundation.h>
31 #import <AppKit/NSTouch.h>
32 #include "cinder/app/TouchEvent.h"
33 
34 #include <map>
35 
37 @required
38 - (void)resize;
39 - (void)draw;
40 - (void)mouseDown:(cinder::app::MouseEvent*)event;
41 - (void)mouseDrag:(cinder::app::MouseEvent*)event;
42 - (void)mouseUp:(cinder::app::MouseEvent*)event;
43 - (void)mouseMove:(cinder::app::MouseEvent*)event;
44 - (void)mouseWheel:(cinder::app::MouseEvent*)event;
45 - (void)keyDown:(cinder::app::KeyEvent*)event;
46 - (void)keyUp:(cinder::app::KeyEvent*)event;
47 - (void)touchesBegan:(cinder::app::TouchEvent*)event;
48 - (void)touchesMoved:(cinder::app::TouchEvent*)event;
49 - (void)touchesEnded:(cinder::app::TouchEvent*)event;
50 - (void)fileDrop:(cinder::app::FileDropEvent*)event;
51 - (cinder::app::WindowRef)getWindowRef;
52 @end
53 
54 @interface CinderView : NSView {
55  @private
56  cinder::app::App *mApp;
57  BOOL mFullScreen;
58  BOOL mFullScreenModeKiosk;
59  BOOL mReadyToDraw; // don't allow draw until setup() and resize() have been called
60  BOOL mReceivesEvents;
61  cinder::app::RendererRef mRenderer;
62 
63  float mContentScaleFactor;
64 
65  NSMutableDictionary *mTouchIdMap;
66  std::map<uint32_t,cinder::Vec2f> mTouchPrevPointMap;
67  std::vector<cinder::app::TouchEvent::Touch> mActiveTouches;
68  id<CinderViewDelegate> mDelegate;
69 }
70 
71 @property (readwrite) BOOL readyToDraw;
72 @property (readwrite) BOOL receivesEvents;
73 
74 - (id)initWithFrame:(NSRect)frame app:(cinder::app::App*)aApp renderer:(cinder::app::RendererRef)aRenderer sharedRenderer:(cinder::app::RendererRef)sharedRenderer;
75 - (void)setupRendererWithFrame:(NSRect)frame renderer:(cinder::app::RendererRef)renderer sharedRenderer:(cinder::app::RendererRef)sharedRenderer;
76 - (void)setDelegate:(id<CinderViewDelegate>)delegate;
77 
78 - (BOOL)isFullScreen;
79 - (void)setFullScreen:(BOOL)fullScreen options:(const cinder::app::FullScreenOptions *)options;
80 
81 - (void)draw;
82 - (void)makeCurrentContext;
83 
84 //- (void)setup:(cinder::app::App *)aApp;
85 - (void)setApp:(cinder::app::App *)aApp;
86 
87 - (void)applicationWillResignActive:(NSNotification *)aNotification;
88 
89 - (cinder::app::RendererRef)getRenderer;
90 
91 - (uint32_t)addTouchToMap:(NSTouch *)touch withPoint:(cinder::Vec2f)point;
92 - (void)removeTouchFromMap:(NSTouch *)touch;
93 - (std::pair<uint32_t,cinder::Vec2f>)updateTouch:(NSTouch *)touch withPoint:(cinder::Vec2f)point;
94 - (void)updateActiveTouches:(NSEvent *)event;
95 - (const std::vector<cinder::app::TouchEvent::Touch>&)getActiveTouches;
96 
97 - (float)contentScaleFactor;
98 
99 
100 @end
Vec2< float > Vec2f
Definition: Vector.h:1314
typedef void(APIENTRYP GLEEPFNGLBLENDCOLORPROC)(GLclampf red
BOOL isFullScreen()
Definition: AppCocoaTouch.mm:969
Definition: App.h:127
void resize()
Definition: AppCocoaTouch.mm:1075
std::shared_ptr< class Renderer > RendererRef
Definition: Renderer.h:85
GLXDrawable draw
Definition: GLee.h:16766
GLuint id
Definition: GLee.h:2035
Definition: CinderView.h:36
Definition: CinderView.h:54
void setFullScreen(bool fullScreen=true)
Sets whether the active App is in full-screen mode based on fullScreen.
Definition: App.h:607