Cinder  0.8.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Window.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2012, The Cinder Project, All rights reserved.
3  Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
4 
5  This code is intended for use with the Cinder C++ library: http://libcinder.org
6 
7  Redistribution and use in source and binary forms, with or without modification, are permitted provided that
8  the following conditions are met:
9 
10  * Redistributions of source code must retain the above copyright notice, this list of conditions and
11  the following disclaimer.
12  * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
13  the following disclaimer in the documentation and/or other materials provided with the distribution.
14 
15  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
16  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
17  PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
18  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
19  TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
22  POSSIBILITY OF SUCH DAMAGE.
23 */
24 
25 #pragma once
26 
27 #include "cinder/Cinder.h"
28 #include "cinder/Display.h"
29 #include "cinder/app/Renderer.h"
30 #include "cinder/Vector.h"
31 #include "cinder/Function.h"
32 #include "cinder/Rect.h"
33 #include "cinder/app/MouseEvent.h"
34 #include "cinder/app/TouchEvent.h"
35 #include "cinder/app/KeyEvent.h"
37 #include "cinder/Exception.h"
38 
39 
40 namespace cinder { namespace app {
41 
42 class Window;
43 struct FullScreenOptions;
44 typedef std::shared_ptr<Window> WindowRef;
45 
46 } } // namespace cinder::app
47 
48 #if defined( CINDER_COCOA ) && defined( __OBJC__ )
49  #import <Foundation/Foundation.h>
50  #if defined( CINDER_COCOA_TOUCH )
51  @class UIViewController;
52  #endif
53 
54  @protocol WindowImplCocoa
55  @required
56  - (BOOL)isFullScreen;
57  - (void)setFullScreen:(BOOL)fullScreen options:(const cinder::app::FullScreenOptions *)options;
58  - (cinder::Vec2i)getSize;
59  - (void)setSize:(cinder::Vec2i)size;
60  - (cinder::Vec2i)getPos;
61  - (void)setPos:(cinder::Vec2i)pos;
62  - (float)getContentScale;
63  - (void)close;
64  - (NSString *)getTitle;
65  - (void)setTitle:(NSString *)title;
66  - (BOOL)isBorderless;
67  - (void)setBorderless:(BOOL)borderless;
68  - (BOOL)isAlwaysOnTop;
69  - (void)setAlwaysOnTop:(BOOL)alwaysOnTop;
70  - (void)hide;
71  - (void)show;
72  - (BOOL)isHidden;
73  - (cinder::DisplayRef)getDisplay;
74  - (cinder::app::RendererRef)getRenderer;
75  - (const std::vector<cinder::app::TouchEvent::Touch>&)getActiveTouches;
76  - (void*)getNative;
77  #if defined( CINDER_COCOA_TOUCH )
78  - (UIViewController *)getNativeViewController;
79  #endif
80  @end
81 #elif defined( CINDER_COCOA )
82  class WindowImplCocoa;
83  #if defined( CINDER_COCOA_TOUCH )
84  class UIViewController;
85  #endif
86 #elif defined( CINDER_WINRT )
87  namespace cinder { namespace app {
88  class WindowImplWinRT;
89  } } // namespace cinder::app
90 #elif defined( CINDER_MSW )
91  namespace cinder { namespace app {
92  class WindowImplMsw;
93  } } // namespace cinder::app
94 #endif
95 
96 namespace cinder { namespace app {
97 
98 typedef signals::signal<void(MouseEvent&),EventCombiner<MouseEvent> > EventSignalMouse;
99 typedef signals::signal<void(TouchEvent&),EventCombiner<TouchEvent> > EventSignalTouch;
100 typedef signals::signal<void(KeyEvent&),EventCombiner<KeyEvent> > EventSignalKey;
101 typedef signals::signal<void(FileDropEvent&),EventCombiner<FileDropEvent> > EventSignalFileDrop;
102 typedef signals::signal<void()> EventSignalWindow;
103 
106  virtual const char * what() const throw() { return "Invalid Window"; }
107 };
108 
111  FullScreenOptions() : mKioskMode( true ), mSecondaryDisplayBlanking( false ), mExclusive( false )
112  {}
113 
115  FullScreenOptions& kioskMode( bool enable = true ) { mKioskMode = enable; return *this; }
117  FullScreenOptions& secondaryDisplayBlanking( bool enable = true ) { mSecondaryDisplayBlanking = enable; return *this; }
119  FullScreenOptions& exclusive( bool enable = true ) { mExclusive = enable; return *this; }
121  FullScreenOptions& display( DisplayRef display ) { mDisplay = display; return *this; }
122 
124  DisplayRef getDisplay() const { return mDisplay; }
126  bool isKioskModeEnabled() const { return mKioskMode; }
128  bool isSecondaryDisplayBlankingEnabled() const { return mSecondaryDisplayBlanking; }
130  bool isExclusive() const { return mExclusive; }
131 
132  private:
133  DisplayRef mDisplay;
134  bool mKioskMode, mSecondaryDisplayBlanking, mExclusive;
135 };
136 
137 class Window : public std::enable_shared_from_this<Window> {
138  public:
139  // Parameters for a Window, which are used to create the physical window by the App
140  struct Format {
142  : mRenderer( renderer ), mFullScreen( fullScreen ), mDisplay( display ), mSize( size ), mPos( pos ), mPosSpecified( false ),
143  mResizable( true ), mBorderless( false ), mAlwaysOnTop( false ), mFullScreenButtonEnabled( false ),
144  mTitleSpecified( false ), mTitle( "" )
145 #if defined( CINDER_COCOA_TOUCH )
146  , mRootViewController( NULL )
147 #endif
148  {
149  mFullScreenOptions.kioskMode( true );
150  }
151 
153  DisplayRef getDisplay() const { return mDisplay; }
155  void setDisplay( DisplayRef display ) { mDisplay = display; }
157  Format& display( DisplayRef displayRef ) { mDisplay = displayRef; return *this; }
159  bool isFullScreen() const { return mFullScreen; }
161  const FullScreenOptions& getFullScreenOptions() const { return mFullScreenOptions; }
163  void setFullScreen( bool fullScreen = true, const FullScreenOptions &options = FullScreenOptions() ) { mFullScreen = fullScreen; mFullScreenOptions = options; }
165  Format& fullScreen( bool fs = true ) { mFullScreen = fs; return *this; }
167  Vec2i getSize() const { return mSize; }
169  void setSize( const Vec2i &size ) { mSize = size; }
171  void setSize( int32_t width, int32_t height ) { mSize = Vec2i( width, height ); }
173  Format& size( const Vec2i &s ) { mSize = s; return *this; }
175  Format& size( int32_t width, int32_t height ) { mSize = Vec2i( width, height ); return *this; }
176 
178  Vec2i getPos() const { return mPos; }
180  void setPos( const Vec2i &pos ) { mPos = pos; mPosSpecified = true; }
182  void setPos( int32_t x, int32_t y ) { mPos = Vec2i( x, y ); mPosSpecified = true; }
184  Format& pos( const Vec2i &pos ) { mPos = pos; mPosSpecified = true; return *this; }
186  Format& pos( int32_t x, int32_t y ) { mPos = Vec2i( x, y ); mPosSpecified = true; return *this; }
188  bool isPosSpecified() const { return mPosSpecified; }
190  void unspecifyPos() { mPosSpecified = false; }
191 
193  RendererRef getRenderer() const { return mRenderer; }
195  void setRenderer( RendererRef renderer ) { mRenderer = renderer; }
197  Format& renderer( RendererRef r ) { mRenderer = r; return *this; }
198 
199 #if defined( CINDER_COCOA_TOUCH )
200  UIViewController* getRootViewController() const { return mRootViewController;}
203  void setRootViewController( UIViewController *v ) { mRootViewController = v; }
205  Format& rootViewController( UIViewController *v ) { mRootViewController = v; return *this; }
206 #endif
207 
209  bool isResizable() const { return mResizable; }
211  void setResizable( bool resizable = true ) { mResizable = resizable; }
213  Format& resizable( bool res = true ) { mResizable = res; return *this; }
215  bool isBorderless() const { return mBorderless; }
217  void setBorderless( bool borderless = true ) { mBorderless = borderless; }
219  Format& borderless( bool border = true ) { mBorderless = border; return *this; }
221  bool isAlwaysOnTop() const { return mAlwaysOnTop; }
223  void setAlwaysOnTop( bool alwaysOnTop = true ) { mAlwaysOnTop = alwaysOnTop; }
225  Format& alwaysOnTop( bool top = true ) { mAlwaysOnTop = top; return *this; }
227  void enableFullScreenButton( bool enabled = true ) { mFullScreenButtonEnabled = enabled; }
229  Format& fullScreenButton( bool enabled = true ) { mFullScreenButtonEnabled = enabled; return *this; }
231  bool isFullScreenButtonEnabled() const { return mFullScreenButtonEnabled; }
232 
234  std::string getTitle() const { return mTitle; }
236  void setTitle( const std::string &title ) { mTitle = title; mTitleSpecified = true; }
238  Format& title( const std::string &t ) { setTitle( t ); return *this; }
240  bool isTitleSpecified() const { return mTitleSpecified; }
242  void unspecifyTitle() { mTitleSpecified = false; }
243 
244 
245  private:
246  RendererRef mRenderer;
247  bool mFullScreen;
248  FullScreenOptions mFullScreenOptions;
249  DisplayRef mDisplay;
250  Vec2i mSize, mPos;
251  bool mPosSpecified;
252  bool mResizable, mBorderless, mAlwaysOnTop, mFullScreenButtonEnabled;
253  std::string mTitle;
254  bool mTitleSpecified;
255 
256 #if defined( CINDER_COCOA_TOUCH )
257  UIViewController *mRootViewController;
258 #endif
259  };
260 
262  bool isFullScreen() const;
264  void setFullScreen( bool fullScreen = true, const FullScreenOptions& options = FullScreenOptions() );
266  int32_t getWidth() const { return getSize().x; }
268  int32_t getHeight() const { return getSize().y; }
270  float getAspectRatio() const { return getSize().x / (float)getSize().y; }
272  Area getBounds() const { return Area( 0, 0, getSize().x, getSize().y ); }
274  virtual Vec2i getSize() const;
276  void setSize( int32_t width, int32_t height ) { setSize( Vec2i( width, height ) ); }
278  void setSize( const Vec2i &size );
280  Vec2i getPos() const;
282  void setPos( int32_t x, int32_t y ) const { setPos( Vec2i( x, y ) ); }
284  void setPos( const Vec2i &pos ) const;
286  Vec2f getCenter() const { return Vec2f( getWidth() / 2.0f, getHeight() / 2.0f ); }
288  void spanAllDisplays();
289 
291  float getContentScale() const;
293  float toPixels( float s ) const { return s * getContentScale(); }
295  Vec2f toPixels( Vec2f s ) const { return s * getContentScale(); }
297  Vec2i toPixels( Vec2i s ) const { return Vec2i( (int32_t)(s.x * getContentScale()), (int32_t)(s.y * getContentScale()) ); }
299  Area toPixels( const Area &a ) const { const float s = getContentScale(); return Area( (int32_t)(a.x1 * s), (int32_t)(a.y1 * s), (int32_t)(a.x2 * s), (int32_t)(a.y2 * s) ); }
301  Rectf toPixels( const Rectf &a ) const { return a * getContentScale(); }
303  float toPoints( float s ) const { return s / getContentScale(); }
305  Vec2f toPoints( Vec2f s ) const { return s / getContentScale(); }
307  Vec2i toPoints( Vec2i s ) const { return Vec2i( (int32_t)(s.x / getContentScale()), (int32_t)(s.y / getContentScale()) ); }
309  Area toPoints( const Area &a ) const { const float s = 1.0f / getContentScale(); return Area( (int32_t)(a.x1 * s), (int32_t)(a.y1 * s), (int32_t)(a.x2 * s), (int32_t)(a.y2 * s) ); }
311  Rectf toPoints( const Rectf &a ) const { return a / getContentScale(); }
312 
314  std::string getTitle() const;
316  void setTitle( const std::string &title );
317 
319  bool isBorderless() const;
321  void setBorderless( bool borderless = true );
323  bool isAlwaysOnTop() const;
325  void setAlwaysOnTop( bool alwaysOnTop = true );
326 
328  void hide();
330  void show();
332  bool isHidden() const;
333 
335  void close();
336 
338  DisplayRef getDisplay() const;
340  RendererRef getRenderer() const;
342  void* getNative() const;
343 #if defined( CINDER_COCOA_TOUCH )
344  UIViewController* getNativeViewController();
346 #elif defined( CINDER_WINRT )
347  DX_WINDOW_TYPE getNativeCoreWindow();
348 #endif
349 #if defined( CINDER_MSW )
350  HDC getDc() const { return getRenderer()->getDc(); }
352 #endif
353 
355  void emitMouseDown( MouseEvent *event );
356  template<typename T, typename Y>
357  signals::connection connectMouseDown( T fn, Y *inst ) { return getSignalMouseDown().connect( std::bind( fn, inst, std::placeholders::_1 ) ); }
358 
360  void emitMouseDrag( MouseEvent *event );
361  template<typename T, typename Y>
362  signals::connection connectMouseDrag( T fn, Y *inst ) { return getSignalMouseDrag().connect( std::bind( fn, inst, std::placeholders::_1 ) ); }
363 
365  void emitMouseUp( MouseEvent *event );
366  template<typename T, typename Y>
367  signals::connection connectMouseUp( T fn, Y *inst ) { return getSignalMouseUp().connect( std::bind( fn, inst, std::placeholders::_1 ) ); }
368 
370  void emitMouseMove( MouseEvent *event );
371  template<typename T, typename Y>
372  signals::connection connectMouseMove( T fn, Y *inst ) { return getSignalMouseMove().connect( std::bind( fn, inst, std::placeholders::_1 ) ); }
373 
375  void emitMouseWheel( MouseEvent *event );
376  template<typename T, typename Y>
377  signals::connection connectMouseWheel( T fn, Y *inst ) { return getSignalMouseWheel().connect( std::bind( fn, inst, std::placeholders::_1 ) ); }
378 
380  void emitTouchesBegan( TouchEvent *event );
381  template<typename T, typename Y>
382  signals::connection connectTouchesBegan( T fn, Y *inst ) { return getSignalTouchesBegan().connect( std::bind( fn, inst, std::placeholders::_1 ) ); }
383 
385  void emitTouchesMoved( TouchEvent *event );
386  template<typename T, typename Y>
387  signals::connection connectTouchesMoved( T fn, Y *inst ) { return getSignalTouchesMoved().connect( std::bind( fn, inst, std::placeholders::_1 ) ); }
388 
390  void emitTouchesEnded( TouchEvent *event );
391  template<typename T, typename Y>
392  signals::connection connectTouchesEnded( T fn, Y *inst ) { return getSignalTouchesEnded().connect( std::bind( fn, inst, std::placeholders::_1 ) ); }
393 
395  const std::vector<TouchEvent::Touch>& getActiveTouches() const;
396 
398  void emitKeyDown( KeyEvent *event );
399  template<typename T, typename Y>
400  signals::connection connectKeyDown( T fn, Y *inst ) { return getSignalKeyDown().connect( std::bind( fn, inst, std::placeholders::_1 ) ); }
401 
403  void emitKeyUp( KeyEvent *event );
404  template<typename T, typename Y>
405  signals::connection connectKeyUp( T fn, Y *inst ) { return getSignalKeyUp().connect( std::bind( fn, inst, std::placeholders::_1 ) ); }
406 
407  EventSignalWindow& getSignalDraw() { return mSignalDraw; }
409  void emitDraw();
410  template<typename T, typename Y>
411  signals::connection connectDraw( T fn, Y *inst ) { return getSignalDraw().connect( std::bind( fn, inst ) ); }
412 
414  EventSignalWindow& getSignalPostDraw() { return mSignalPostDraw; }
415  template<typename T, typename Y>
416  signals::connection connectPostDraw( T fn, Y *inst ) { return getSignalPostDraw().connect( std::bind( fn, inst ) ); }
417 
418  EventSignalWindow& getSignalMove() { return mSignalMove; }
419  void emitMove();
420  template<typename T, typename Y>
421  signals::connection connectMove( T fn, Y *inst ) { return getSignalMove().connect( std::bind( fn, inst ) ); }
422 
423  EventSignalWindow& getSignalResize() { return mSignalResize; }
424  void emitResize();
425  template<typename T, typename Y>
426  signals::connection connectResize( T fn, Y *inst ) { return getSignalResize().connect( std::bind( fn, inst ) ); }
427 
428  EventSignalWindow& getSignalDisplayChange() { return mSignalDisplayChange; }
429  void emitDisplayChange();
430  template<typename T, typename Y>
431  signals::connection connectDisplayChange( T fn, Y *inst ) { return getSignalDisplayChange().connect( std::bind( fn, inst ) ); }
432 
434  EventSignalWindow& getSignalClose() { return mSignalClose; }
436  void emitClose();
437  template<typename T, typename Y>
438  signals::connection connectClose( T fn, Y *inst ) { return getSignalClose().connect( std::bind( fn, inst ) ); }
439 
441  void emitFileDrop( FileDropEvent *event );
442  template<typename T, typename Y>
443  signals::connection connectFileDrop( T fn, Y *inst ) { return getSignalFileDrop().connect( std::bind( fn, inst, std::placeholders::_1 ) ); }
444 
446  template<typename T>
447  T* getUserData() { return static_cast<T*>( mUserData.get() ); }
449  template<typename T>
450  void setUserData( T *userData ) { mUserData = std::shared_ptr<void>( std::shared_ptr<T>( userData ) ); }
451 
453  bool isValid() const { return ! mValid; }
454  void setInvalid() { mValid = false; }
455 
457  // This should not be called except by App implementations
458 #if defined( CINDER_COCOA ) && defined( __OBJC__ )
459  static WindowRef privateCreate__( id<WindowImplCocoa> impl, App *app )
460 #elif defined( CINDER_MSW )
461  static WindowRef privateCreate__( WindowImplMsw *impl, App *app )
462 #elif defined( CINDER_WINRT )
463  static WindowRef privateCreate__( WindowImplWinRT *impl, App *app )
464 #else
465  static WindowRef privateCreate__( WindowImplCocoa *impl, App *app )
466 #endif
467  {
468  WindowRef result( new Window );
469  result->setImpl( impl );
470  result->setApp( app );
471 
472  return result;
473  }
475 
476  App* getApp() const { return mApp; }
477 
478  protected:
479  Window() : mValid( true ), mImpl( 0 ) {}
480 
481  void testValid() const {
482  if( ! mValid )
483  throw ExcInvalidWindow();
484  }
485 
486  void setApp( App *app ) { mApp = app; }
487 
488 #if defined( CINDER_COCOA )
489  #if defined( __OBJC__ )
490  void setImpl( id<WindowImplCocoa> impl ) { mImpl = impl; }
491  #else
492  void setImpl( WindowImplCocoa *impl ) { mImpl = impl; }
493  #endif
494 #elif defined( CINDER_MSW )
495  void setImpl( WindowImplMsw *impl ) { mImpl = impl; }
496 #elif defined( CINDER_WINRT )
497  void setImpl( WindowImplWinRT *impl ) { mImpl = impl; }
498 #endif
499 
501  bool mValid;
502  std::shared_ptr<void> mUserData;
503 
509 
510 #if defined( CINDER_COCOA )
511  #if defined( __OBJC__ )
512  id<WindowImplCocoa> mImpl;
513  #else
514  WindowImplCocoa *mImpl; // necessary to trick c++ translation units
515  #endif
516 #elif defined( CINDER_MSW )
517  WindowImplMsw *mImpl;
518 #elif defined( CINDER_WINRT )
519  WindowImplWinRT *mImpl;
520 #endif
521 };
522 
523 } } // namespace cinder::app
void setSize(int32_t width, int32_t height)
Sets the size of the Window to ( width, height ) measured in points.
Definition: Window.h:276
void emitTouchesMoved(TouchEvent *event)
Definition: Window.cpp:356
void setFullScreen(bool fullScreen=true, const FullScreenOptions &options=FullScreenOptions())
Sets whether the Window will be created full-screen with FullScreenOptions options. Default is false. If true, FullScreenOptions mode defaults to kiosk.
Definition: Window.h:163
GLdouble GLdouble GLdouble r
Definition: GLee.h:1474
NSString * getTitle()
Definition: AppCocoaTouch.mm:1005
int32_t getHeight() const
Returns the height of the Window in points.
Definition: Window.h:268
EventSignalMouse mSignalMouseMove
Definition: Window.h:504
void emitKeyUp(KeyEvent *event)
Definition: Window.cpp:397
void setBorderless(bool borderless=true)
Sets whether the window has a border (chrome/frame)
Definition: Window.cpp:167
EventSignalWindow & getSignalClose()
Returns the Signal emitted whenever a Window is closing. The WindowRef parameter is still valid at th...
Definition: Window.h:434
void emitMouseMove(MouseEvent *event)
Definition: Window.cpp:338
GLenum GLint GLint y
Definition: GLee.h:987
void emitTouchesEnded(TouchEvent *event)
Definition: Window.cpp:365
Vec2f toPixels(Vec2f s) const
Returns a Vec2f mapped from points to pixels by multiplying by getContentScale()
Definition: Window.h:295
void hide()
Definition: AppCocoaTouch.mm:1028
void emitKeyDown(KeyEvent *event)
Definition: Window.cpp:388
GLdouble GLdouble GLdouble GLdouble top
Definition: GLee.h:13559
void * getNative()
Definition: AppCocoaTouch.mm:1051
Vec2i toPoints(Vec2i s) const
Returns a Vec2i mapped from pixels to points by dividing by getContentScale()
Definition: Window.h:307
void * getNative() const
Returns the associated NSView on Mac OS X, UIView on iOS, or HWND on MSW.
Definition: Window.cpp:255
EventSignalTouch & getSignalTouchesEnded()
Definition: Window.h:389
FullScreenOptions & kioskMode(bool enable=true)
(OS X only) Sets the fullscreen mode to 'kiosk', which means don't use the 10.7 way of animating to f...
Definition: Window.h:115
Format & resizable(bool res=true)
Sets whether the Window created will be resizable. Defaults to true.
Definition: Window.h:213
bool isBorderless() const
Returns whether the window has a border (chrome/frame)
Definition: Window.cpp:156
void enable(GLenum state)
Enables the OpenGL State state. Equivalent to calling to glEnable( state );.
Definition: dx.h:198
signals::connection connectMouseWheel(T fn, Y *inst)
Definition: Window.h:377
Represents a mouse event.
Definition: MouseEvent.h:34
BOOL isAlwaysOnTop()
Definition: AppCocoaTouch.mm:1019
EventSignalMouse mSignalMouseWheel
Definition: Window.h:504
EventSignalMouse mSignalMouseUp
Definition: Window.h:504
Vec2< float > Vec2f
Definition: Vector.h:1314
Definition: Area.h:37
Format & borderless(bool border=true)
Sets whether the Window created will have no border. Defaults to false.
Definition: Window.h:219
signals::connection connectMouseDown(T fn, Y *inst)
Definition: Window.h:357
GLsizei const GLchar ** string
Definition: GLee.h:2427
void setUserData(T *userData)
Sets the window-specific data associated with this Window. The variable is deleted upon destruction o...
Definition: Window.h:450
Rectf toPixels(const Rectf &a) const
Returns a Rectf mapped from points to pixels by multiplying by getContentScale()
Definition: Window.h:301
int32_t y2
Definition: Area.h:101
RendererRef getRenderer() const
Returns the Renderer which will be instantiated for the Window. Defaults to an instance of the App's ...
Definition: Window.h:193
void close()
Definition: AppCocoaTouch.mm:1001
FullScreenOptions & display(DisplayRef display)
Sets the display which will be used in fullscreen mode. Defaults to the Window's current Display...
Definition: Window.h:121
static DisplayRef getMainDisplay()
Returns the system's primary display.
Definition: Display.cpp:302
Options passed when entering fullscreen.
Definition: Window.h:110
Vec2i getPos() const
Returns the position in points measured relative to the system's primary display's upper-left corner ...
Definition: Window.h:178
void enableFullScreenButton(bool enabled=true)
On Mac OS X enables the native full screen toggle button. Defaults to false.
Definition: Window.h:227
bool isFullScreenButtonEnabled() const
On Mac OS X returns whether the native full screen toggle button is displayed. Defaults to false...
Definition: Window.h:231
T * getUserData()
Returns the window-specific data associated with this Window.
Definition: Window.h:447
EventSignalMouse & getSignalMouseDrag()
Definition: Window.h:359
Vec2f getCenter() const
Returns the center of the Window in its own coordinate system measured in points. ...
Definition: Window.h:286
void setFullScreen(bool fullScreen=true, const FullScreenOptions &options=FullScreenOptions())
Sets the Window to be full-screen or not.
Definition: Window.cpp:48
Format & size(const Vec2i &s)
Sets the size in points at which the Window will be created. Default is 640 x 480.
Definition: Window.h:173
float getContentScale()
Definition: AppCocoaTouch.mm:996
GLenum GLsizei width
Definition: GLee.h:969
void setDisplay(DisplayRef display)
Sets the Display the Window will be created on. Defaults to the primary display.
Definition: Window.h:155
void setApp(App *app)
Definition: Window.h:486
Area getBounds() const
Returns the bounding Area of the Window in points: [0,0]-(width,height)
Definition: Window.h:272
bool isAlwaysOnTop() const
Returns whether the window always remains above all other windows.
Definition: Window.cpp:178
signals::connection connectResize(T fn, Y *inst)
Definition: Window.h:426
BOOL isHidden()
Definition: AppCocoaTouch.mm:1036
static Vec2< int > zero()
Definition: Vector.h:295
signals::connection connectMove(T fn, Y *inst)
Definition: Window.h:421
void setAlwaysOnTop(bool alwaysOnTop=true)
Sets whether the Window created will always be above all other windows, including other applications'...
Definition: Window.h:223
signals::connection connectClose(T fn, Y *inst)
Definition: Window.h:438
T x
Definition: Vector.h:71
EventSignalWindow mSignalClose
Definition: Window.h:507
EventSignalWindow mSignalDisplayChange
Definition: Window.h:507
Format & size(int32_t width, int32_t height)
Sets the size in points at which the Window will be created. Default is 640 x 480.
Definition: Window.h:175
EventSignalWindow mSignalResize
Definition: Window.h:507
EventSignalWindow mSignalPostDraw
Definition: Window.h:507
bool isBorderless() const
Returns whether the Window created will have no border. Defaults to false.
Definition: Window.h:215
typedef void(APIENTRYP GLEEPFNGLBLENDCOLORPROC)(GLclampf red
bool isTitleSpecified() const
Returns whether a non-default title has been requested for the Window.
Definition: Window.h:240
bool isValid() const
Returns whether this Window is valid. false means it should no longer be used (neither read nor write...
Definition: Window.h:453
signals::connection connectPostDraw(T fn, Y *inst)
Definition: Window.h:416
Format & fullScreen(bool fs=true)
Sets whether the Window will be created full-screen. Default is false.
Definition: Window.h:165
EventSignalTouch mSignalTouchesEnded
Definition: Window.h:505
Format & pos(int32_t x, int32_t y)
Sets the position in points measured relative to the system's primary display's upper-left corner at ...
Definition: Window.h:186
GLuint res
Definition: GLee.h:10843
signals::connection connectMouseUp(T fn, Y *inst)
Definition: Window.h:367
Definition: Window.h:137
BOOL isFullScreen()
Definition: AppCocoaTouch.mm:969
Rectf toPoints(const Rectf &a) const
Returns a Rectf mapped from pixels to points by dividing by getContentScale()
Definition: Window.h:311
EventSignalKey mSignalKeyUp
Definition: Window.h:506
void emitMouseDrag(MouseEvent *event)
Definition: Window.cpp:311
const std::vector< TouchEvent::Touch > & getActiveTouches() const
Returns a std::vector of all active touches.
Definition: Window.cpp:375
Format & fullScreenButton(bool enabled=true)
On Mac OS X enables the native full screen toggle button. Defaults to false.
Definition: Window.h:229
Format & display(DisplayRef displayRef)
Sets the Display the Window will be created on. Defaults to the primary display.
Definition: Window.h:157
EventSignalWindow & getSignalMove()
Definition: Window.h:418
EventSignalKey & getSignalKeyDown()
Definition: Window.h:397
FullScreenOptions & exclusive(bool enable=true)
(OS X only) Sets whether the Window related to these options is the only accessible window...
Definition: Window.h:119
std::shared_ptr< Window > WindowRef
Definition: Event.h:49
signals::connection connectTouchesEnded(T fn, Y *inst)
Definition: Window.h:392
EventSignalKey & getSignalKeyUp()
Definition: Window.h:402
void setPos(int32_t x, int32_t y) const
Sets the position of the Window's upper-left corner relative to the primary display's upper-left corn...
Definition: Window.h:282
signals::connection connectKeyUp(T fn, Y *inst)
Definition: Window.h:405
float toPixels(float s) const
Returns a scalar mapped from points to pixels by multiplying by getContentScale() ...
Definition: Window.h:293
void emitMove()
Definition: Window.cpp:282
float getContentScale() const
Returns the multiplier (typically 2 on high-density (Retina) displays, 1 otherwise) mapping points to...
Definition: Window.cpp:111
void show()
Shows a window that was hidden with hide()
Definition: Window.cpp:211
RendererRef getRenderer() const
Returns the Renderer associated with the Window.
Definition: Window.cpp:244
bool isFullScreen() const
Returns whether the Window will be created full-screen. Default is false.
Definition: Window.h:159
Window()
Definition: Window.h:479
Area toPoints(const Area &a) const
Returns an Area mapped from pixels to points by dividing by getContentScale()
Definition: Window.h:309
Area toPixels(const Area &a) const
Returns an Area mapped from points to pixels by multiplying by getContentScale()
Definition: Window.h:299
Definition: AppImplMsw.h:103
Definition: App.h:127
FullScreenOptions & secondaryDisplayBlanking(bool enable=true)
Sets whether secondary displays should be blanked (made black). Default is false. ...
Definition: Window.h:117
void emitMouseDown(MouseEvent *event)
Definition: Window.cpp:302
EventSignalWindow & getSignalPostDraw()
Returns the signal which is emitted after the draw signal and app's draw() virtual method...
Definition: Window.h:414
void emitDraw()
Fires the 'draw' signal. Note in general this should not be called directly as it doesn't perform all...
Definition: Window.cpp:406
GLenum GLsizei GLsizei height
Definition: GLee.h:1029
float toPoints(float s) const
Returns a scalar mapped from pixels to points by dividing by getContentScale()
Definition: Window.h:303
UIViewController * getNativeViewController()
Definition: AppCocoaTouch.mm:1056
EventSignalTouch & getSignalTouchesMoved()
Definition: Window.h:384
void unspecifyTitle()
Unspecifies a non-default title for the window, effectively requestion the default title...
Definition: Window.h:242
BOOL isBorderless()
Definition: AppCocoaTouch.mm:1010
App * mApp
Definition: Window.h:500
bool isExclusive() const
Returns whether the Window related to these options is the only accessible window.
Definition: Window.h:130
EventSignalMouse mSignalMouseDrag
Definition: Window.h:504
EventSignalMouse & getSignalMouseUp()
Definition: Window.h:364
EventSignalFileDrop mSignalFileDrop
Definition: Window.h:508
GLenum GLint x
Definition: GLee.h:987
int32_t x1
Definition: Area.h:101
void emitFileDrop(FileDropEvent *event)
Definition: Window.cpp:413
std::string getTitle() const
Returns the Window's title as a UTF-8 string.
Definition: Window.cpp:133
int32_t x2
Definition: Area.h:101
std::shared_ptr< class Renderer > RendererRef
Definition: Renderer.h:85
bool isResizable() const
Returns whether the Window created will be resizable. Defaults to true.
Definition: Window.h:209
EventSignalTouch & getSignalTouchesBegan()
Definition: Window.h:379
void testValid() const
Definition: Window.h:481
void setSize(const Vec2i &size)
Sets the size in points at which the Window will be created. Default is 640 x 480.
Definition: Window.h:169
void show()
Definition: AppCocoaTouch.mm:1032
EventCombiner< MouseEvent > EventSignalMouse
Definition: Window.h:98
EventSignalMouse & getSignalMouseWheel()
Definition: Window.h:374
EventSignalMouse & getSignalMouseDown()
Definition: Window.h:354
std::shared_ptr< void > mUserData
Definition: Window.h:502
Vec2f toPoints(Vec2f s) const
Returns a Vec2f mapped from pixels to points by dividing by getContentScale()
Definition: Window.h:305
EventSignalKey mSignalKeyDown
Definition: Window.h:506
Format(RendererRef renderer=RendererRef(), DisplayRef display=Display::getMainDisplay(), bool fullScreen=false, Vec2i size=Vec2i(640, 480), Vec2i pos=Vec2i::zero())
Definition: Window.h:141
const GLdouble * v
Definition: GLee.h:1384
EventCombiner< KeyEvent > EventSignalKey
Definition: Window.h:100
signals::connection connectDraw(T fn, Y *inst)
Definition: Window.h:411
bool mValid
Definition: Window.h:501
FullScreenOptions()
Definition: Window.h:111
void spanAllDisplays()
Sets the position and size of the Window so that it spans all connected displays. ...
Definition: Window.cpp:103
void setTitle(const std::string &title)
Sets the title of the Window as a UTF-8 string.
Definition: Window.h:236
void emitDisplayChange()
Definition: Window.cpp:296
int32_t getWidth() const
Returns the width of the Window in points.
Definition: Window.h:266
DisplayRef getDisplay() const
Returns the Display on which the Window resides.
Definition: Window.cpp:233
Definition: AppImplWinRT.h:95
void setAlwaysOnTop(bool alwaysOnTop=true)
Sets whether the window always remains above all other windows.
Definition: Window.cpp:189
EventSignalWindow & getSignalDisplayChange()
Definition: Window.h:428
T y
Definition: Vector.h:71
App * getApp() const
Definition: Window.h:476
void setTitle(const std::string &title)
Sets the Window's title as a UTF-8 string.
Definition: Window.cpp:145
std::shared_ptr< class Display > DisplayRef
Definition: Display.h:53
EventCombiner< TouchEvent > EventSignalTouch
Definition: Window.h:99
Format & pos(const Vec2i &pos)
Sets the position in points measured relative to the system's primary display's upper-left corner at ...
Definition: Window.h:184
void setBorderless(bool borderless=true)
Sets whether the Window created will have no border. Defaults to false.
Definition: Window.h:217
Vec2i getSize() const
Returns the size in points at which the Window will be created. Default is 640 x 480.
Definition: Window.h:167
void hide()
Hides the window but does not destroy it.
Definition: Window.cpp:200
bool isAlwaysOnTop() const
Returns whether the Window created will always be above all other windows, including other applicatio...
Definition: Window.h:221
Format & alwaysOnTop(bool top=true)
Sets whether the Window created will always be above all other windows, including other applications'...
Definition: Window.h:225
EventSignalMouse mSignalMouseDown
Definition: Window.h:504
signals::connection connectTouchesBegan(T fn, Y *inst)
Definition: Window.h:382
signals::connection connectMouseDrag(T fn, Y *inst)
Definition: Window.h:362
DisplayRef getDisplay() const
Returns the display on which the fullscreen should occur. A NULL value implies the default...
Definition: Window.h:124
bool isFullScreen() const
Returns whether the Window is full-screen or not.
Definition: Window.cpp:37
void setResizable(bool resizable=true)
Sets whether the Window created will be resizable. Defaults to true.
Definition: Window.h:211
void setPos(int32_t x, int32_t y)
Sets the position in points measured relative to the system's primary display's upper-left corner at ...
Definition: Window.h:182
signals::connection connectFileDrop(T fn, Y *inst)
Definition: Window.h:443
Represents a file-drop event, typically received from Windows Explorer or Mac OS X Finder...
Definition: FileDropEvent.h:36
std::string getTitle() const
Returns the title of the Window as a UTF-8 string.
Definition: Window.h:234
bool isPosSpecified() const
Returns whether a non-default position has been requested for the Window.
Definition: Window.h:188
bool isKioskModeEnabled() const
Returns whether kiosk mode is enabled.
Definition: Window.h:126
void setPos(const Vec2i &pos)
Sets the position in points measured relative to the system's primary display's upper-left corner at ...
Definition: Window.h:180
GLboolean GLboolean GLboolean GLboolean a
Definition: GLee.h:2964
void emitResize()
Definition: Window.cpp:288
Definition: Window.h:140
EventCombiner< FileDropEvent > EventSignalFileDrop
Definition: Window.h:101
EventSignalTouch mSignalTouchesMoved
Definition: Window.h:505
float getAspectRatio() const
Returns the Window aspect ratio, which is its width / height.
Definition: Window.h:270
void unspecifyPos()
Unspecifies a non-default position for the window, effectively requestion the default position...
Definition: Window.h:190
bool isSecondaryDisplayBlankingEnabled() const
Returns whether blanking of secondary displays in enabled. Default is false.
Definition: Window.h:128
const FullScreenOptions & getFullScreenOptions() const
Returns the options associated with fullscreen at startup.
Definition: Window.h:161
DisplayRef getDisplay() const
Returns the Display the Window will be created on. Defaults to the primary display.
Definition: Window.h:153
Format & title(const std::string &t)
Sets the title of the Window as a UTF-8 string.
Definition: Window.h:238
void setRenderer(RendererRef renderer)
Sets the Renderer which will be instantiated for the Window.
Definition: Window.h:195
int32_t y1
Definition: Area.h:101
Vec2i toPixels(Vec2i s) const
Returns a Vec2i mapped from points to pixels by multiplying by getContentScale()
Definition: Window.h:297
void emitClose()
Fires the 'close' signal.
Definition: Window.cpp:277
signals::connection connectTouchesMoved(T fn, Y *inst)
Definition: Window.h:387
EventSignalWindow mSignalMove
Definition: Window.h:507
signals::connection connectKeyDown(T fn, Y *inst)
Definition: Window.h:400
Format & renderer(RendererRef r)
Sets the Renderer which will be instantiated for the Window.
Definition: Window.h:197
Definition: Exception.h:32
signals::connection connectDisplayChange(T fn, Y *inst)
Definition: Window.h:431
EventSignalFileDrop & getSignalFileDrop()
Definition: Window.h:440
bool isHidden() const
Returns whether the window has been hidden with hide()
Definition: Window.cpp:222
GLuint id
Definition: GLee.h:2035
EventSignalMouse & getSignalMouseMove()
Definition: Window.h:369
Vec2i getPos() const
Gets the position of the Window's upper-left corner measured in points, relative to the primary displ...
Definition: Window.cpp:81
void emitMouseWheel(MouseEvent *event)
Definition: Window.cpp:329
Represents a touch event.
Definition: TouchEvent.h:34
EventSignalWindow mSignalDraw
Definition: Window.h:507
GLdouble GLdouble t
Definition: GLee.h:1426
GLdouble s
Definition: GLee.h:1378
GLclampf f
Definition: GLee.h:15307
EventSignalWindow & getSignalResize()
Definition: Window.h:423
GLint GLint GLsizei GLsizei GLsizei GLint border
Definition: GLee.h:1161
void emitTouchesBegan(TouchEvent *event)
Definition: Window.cpp:347
void close()
Closes and destroys the Window.
Definition: Window.cpp:122
Represents a keyboard event.
Definition: KeyEvent.h:32
void emitMouseUp(MouseEvent *event)
Definition: Window.cpp:320
GLsizeiptr size
Definition: GLee.h:2089
EventSignalTouch mSignalTouchesBegan
Definition: Window.h:505
signals::connection connectMouseMove(T fn, Y *inst)
Definition: Window.h:372
virtual Vec2i getSize() const
Gets the size of the Window measured in points.
Definition: Window.cpp:59
void setInvalid()
Definition: Window.h:454
Thrown when an operation is performed on a WindowRef which refers to an invalid Window.
Definition: Window.h:105
Vec2< int > Vec2i
Definition: Vector.h:1313
void setSize(int32_t width, int32_t height)
Sets the size in points at which the Window will be created. Default is 640 x 480.
Definition: Window.h:171
EventSignalWindow & getSignalDraw()
Definition: Window.h:407
void setFullScreen(bool fullScreen=true)
Sets whether the active App is in full-screen mode based on fullScreen.
Definition: App.h:607