cinder::app::App Class Reference

#include <App.h>

Inherited by cinder::app::AppBasic, cinder::app::AppCinderView, cinder::app::AppCocoaTouch, and cinder::app::AppScreenSaver.

List of all members.

Classes

class  Settings

Public Member Functions

 App ()
virtual ~App ()
virtual void setup ()
 Override to perform any application setup after the Renderer has been initialized.
virtual void shutdown ()
 Override to perform any application cleanup before exiting.
virtual void update ()
 Override to perform any once-per-loop computation.
virtual void draw ()
 Override to perform any rendering once-per-loop or in response to OS-prompted requests for refreshes.
virtual void mouseDown (MouseEvent event)
 Override to receive mouse-down events.
virtual void mouseUp (MouseEvent event)
 Override to receive mouse-up events.
virtual void mouseWheel (MouseEvent event)
 Override to receive mouse-wheel events.
virtual void mouseMove (MouseEvent event)
 Override to receive mouse-move events.
virtual void mouseDrag (MouseEvent event)
 Override to receive mouse-drag events.
virtual void keyDown (KeyEvent event)
 Override to receive key-down events.
virtual void keyUp (KeyEvent event)
 Override to receive key-up events.
virtual void resize (ResizeEvent event)
 Override to receive window resize events.
virtual void fileDrop (FileDropEvent event)
 Override to receive file-drop events.
virtual void quit ()=0
 Quits the application gracefully.
CallbackId registerMouseDown (std::function< bool(MouseEvent)> callback)
 Registers a callback for mouseDown events. Returns a unique identifier which can be used as a parameter to unregisterMouseDown().
template<typename T >
CallbackId registerMouseDown (T *obj, bool(T::*callback)(MouseEvent))
 Registers a callback for mouseDown events. Returns a unique identifier which can be used as a parameter to unregisterMouseDown().
void unregisterMouseDown (CallbackId id)
 Unregisters a callback for mouseDown events.
CallbackId registerMouseUp (std::function< bool(MouseEvent)> callback)
 Registers a callback for mouseUp events. Returns a unique identifier which can be used as a parameter to unregisterMouseUp().
template<typename T >
CallbackId registerMouseUp (T *obj, bool(T::*callback)(MouseEvent))
 Registers a callback for mouseUp events. Returns a unique identifier which can be used as a parameter to unregisterMouseUp().
void unregisterMouseUp (CallbackId id)
 Unregisters a callback for mouseUp events.
CallbackId registerMouseWheel (std::function< bool(MouseEvent)> callback)
 Registers a callback for mouseWheel events. Returns a unique identifier which can be used as a parameter to unregisterMouseWheel().
template<typename T >
CallbackId registerMouseWheel (T *obj, bool(T::*callback)(MouseEvent))
 Registers a callback for mouseWheel events. Returns a unique identifier which can be used as a parameter to unregisterMouseWheel().
void unregisterMouseWheel (CallbackId id)
 Unregisters a callback for mouseWheel events.
CallbackId registerMouseMove (std::function< bool(MouseEvent)> callback)
 Registers a callback for mouseMove events. Returns a unique identifier which can be used as a parameter to unregisterMouseMove().
template<typename T >
CallbackId registerMouseMove (T *obj, bool(T::*callback)(MouseEvent))
 Registers a callback for mouseMove events. Returns a unique identifier which can be used as a parameter to unregisterMouseMove().
void unregisterMouseMove (CallbackId id)
 Unregisters a callback for mouseMove events.
CallbackId registerMouseDrag (std::function< bool(MouseEvent)> callback)
 Registers a callback for mouseDrag events. Returns a unique identifier which can be used as a parameter to unregisterMouseDrag().
template<typename T >
CallbackId registerMouseDrag (T *obj, bool(T::*callback)(MouseEvent))
 Registers a callback for mouseDrag events. Returns a unique identifier which can be used as a parameter to unregisterMouseDrag().
void unregisterMouseDrag (CallbackId id)
 Unregisters a callback for mouseDrag events.
CallbackId registerKeyDown (std::function< bool(KeyEvent)> callback)
 Registers a callback for keyDown events. Returns a unique identifier which can be used as a parameter to unregisterKeyDown().
template<typename T >
CallbackId registerKeyDown (T *obj, bool(T::*callback)(KeyEvent))
 Registers a callback for keyDown events. Returns a unique identifier which can be used as a parameter to unregisterKeyDown().
void unregisterKeyDown (CallbackId id)
 Unregisters a callback for keyDown events.
CallbackId registerKeyUp (std::function< bool(KeyEvent)> callback)
 Registers a callback for keyUp events. Returns a unique identifier which can be used as a parameter to unregisterKeyUp().
template<typename T >
CallbackId registerKeyUp (T *obj, bool(T::*callback)(KeyEvent))
 Registers a callback for keyUp events. Returns a unique identifier which can be used as a parameter to unregisterKeyUp().
void unregisterKeyUp (CallbackId id)
 Unregisters a callback for keyUp events.
CallbackId registerResize (std::function< bool(ResizeEvent)> callback)
 Registers a callback for resize events. Returns a unique identifier which can be used as a parameter to unregisterKeyUp().
template<typename T >
CallbackId registerResize (T *obj, bool(T::*callback)(ResizeEvent))
 Registers a callback for resize events. Returns a unique identifier which can be used as a parameter to unregisterResize().
void unregisterResize (CallbackId id)
 Unregisters a callback for resize events.
CallbackId registerFileDrop (std::function< bool(FileDropEvent)> callback)
 Registers a callback for fileDrop events. Returns a unique identifier which can be used as a parameter to unregisterKeyUp().
template<typename T >
CallbackId registerFileDrop (T *obj, bool(T::*callback)(FileDropEvent))
 Registers a callback for fileDrop events. Returns a unique identifier which can be used as a parameter to unregisterFileDrop().
void unregisterFileDrop (CallbackId id)
 Unregisters a callback for fileDrop events.
virtual const SettingsgetSettings () const =0
RenderergetRenderer () const
virtual int getWindowWidth () const =0
 Returns the width of the App's window measured in pixels, or the screen when in full-screen mode.
virtual void setWindowWidth (int windowWidth)=0
 Sets the width of the App's window measured in pixels. Ignored in full-screen mode.
virtual int getWindowHeight () const =0
 Returns the height of the App's window measured in pixels, or the screen when in full-screen mode.
virtual void setWindowHeight (int windowHeight)=0
 Sets the height of the App's window measured in pixels. Ignored in full-screen mode.
virtual void setWindowSize (int windowWidth, int windowHeight)=0
 Sets the size of the App's window. Ignored in full-screen mode.
void setWindowSize (const Vec2i &size)
 Sets the size of the App's window. Ignored in full-screen mode.
Vec2f getWindowCenter () const
 Returns the center of the App's window or the screen in full-screen mode.
Vec2i getWindowSize () const
 Returns the size of the App's window or the screen in full-screen mode.
float getWindowAspectRatio () const
 Returns the aspect ratio of the App's window or the screen in full-screen mode.
Area getWindowBounds () const
 Returns the bounding area of the App's window or the screen in full-screen mode.
virtual float getFrameRate () const =0
 Returns the maximum frame-rate the App will attempt to maintain.
virtual void setFrameRate (float aFrameRate)=0
 Sets the maximum frame-rate the App will attempt to maintain.
float getAverageFps () const
 Returns the average frame-rate attained by the App as measured in frames-per-second.
double getFpsSampleInterval () const
 Returns the sampling rate in seconds for measuring the average frame-per-second as returned by getAverageFps().
void setFpsSampleInterval (double sampleInterval)
 Sets the sampling rate in seconds for measuring the average frame-per-second as returned by getAverageFps().
virtual bool isFullScreen () const =0
 Returns whether the App is in full-screen mode or not.
virtual void setFullScreen (bool aFullScreen)=0
 Sets whether the active App is in full-screen mode based on fullScreen.
double getElapsedSeconds () const
 Returns the number of seconds which have elapsed since application launch.
uint32_t getElapsedFrames () const
 Returns the number of animation frames which have elapsed since application launch.
virtual std::string getAppPath ()=0
 Returns the path to the application on disk.
std::string getOpenFilePath (const std::string &initialPath="", std::vector< std::string > extensions=std::vector< std::string >())
 Presents the user with a file-open dialog and returns the selected file path.
std::string getFolderPath (const std::string &initialPath="")
 Presents the user with a folder-open dialog and returns the selected folder.
std::string getSaveFilePath (const std::string &initialPath="", std::vector< std::string > extensions=std::vector< std::string >())
 Presents the user with a file-save dialog and returns the selected file path.
std::ostream & console ()
 Returns a reference to an output console, which is an alias to std::cout on the mac, and a wrapper around OutputDebugString on MSW.
Surface copyWindowSurface ()
Surface copyWindowSurface (const Area &area)
void restoreWindowContext ()
 Restores the current rendering context to be the App's window or the screen in full-screen mode. Generally this is only necessary if the app has displayed a dialog box or some other external window.
virtual bool getsWindowsPaintEvents ()=0
virtual bool receivesEvents () const

Static Public Member Functions

static DataSourceRef loadResource (const std::string &macPath, int mswID, const std::string &mswType)
 Returns a DataSourceRef to an application resource. On Mac OS X, macPath is a path relative to the bundle's resources folder. On Windows, mswID and mswType identify the resource as defined the application's .rc file(s). Throws ResourceLoadExc on failure.
static DataSourcePathRef loadResource (const std::string &macPath)
 Returns a DataSourceRef to an application resource. macPath is a path relative to the bundle's resources folder. Throws ResourceLoadExc on failure.
static std::string getResourcePath (const std::string &rsrcRelativePath)
 Returns the absolute file path to a resource located at rsrcRelativePath inside the bundle's resources folder. Throws ResourceLoadExc on failure.
static std::string getResourcePath ()
 Returns the absolute file path to the bundle's resources folder.
static DataSourceBufferRef loadResource (int mswID, const std::string &mswType)
 Returns a DataSourceRef to an application resource. mswID and mswType identify the resource as defined the application's .rc file(s).
static Appget ()
 Returns a pointer to the active App.

Friends

class AppImplMsw

Constructor & Destructor Documentation

cinder::app::App::App (  ) 
cinder::app::App::~App (  )  [virtual]

Member Function Documentation

virtual void cinder::app::App::setup (  )  [virtual]

Override to perform any application setup after the Renderer has been initialized.

virtual void cinder::app::App::shutdown (  )  [virtual]

Override to perform any application cleanup before exiting.

virtual void cinder::app::App::update (  )  [virtual]

Override to perform any once-per-loop computation.

virtual void cinder::app::App::draw (  )  [virtual]

Override to perform any rendering once-per-loop or in response to OS-prompted requests for refreshes.

virtual void cinder::app::App::mouseDown ( MouseEvent  event  )  [virtual]

Override to receive mouse-down events.

virtual void cinder::app::App::mouseUp ( MouseEvent  event  )  [virtual]

Override to receive mouse-up events.

virtual void cinder::app::App::mouseWheel ( MouseEvent  event  )  [virtual]

Override to receive mouse-wheel events.

virtual void cinder::app::App::mouseMove ( MouseEvent  event  )  [virtual]

Override to receive mouse-move events.

virtual void cinder::app::App::mouseDrag ( MouseEvent  event  )  [virtual]

Override to receive mouse-drag events.

virtual void cinder::app::App::keyDown ( KeyEvent  event  )  [virtual]

Override to receive key-down events.

virtual void cinder::app::App::keyUp ( KeyEvent  event  )  [virtual]

Override to receive key-up events.

virtual void cinder::app::App::resize ( ResizeEvent  event  )  [virtual]

Override to receive window resize events.

virtual void cinder::app::App::fileDrop ( FileDropEvent  event  )  [virtual]

Override to receive file-drop events.

virtual void cinder::app::App::quit (  )  [pure virtual]

Quits the application gracefully.

Implemented in cinder::app::AppBasic, cinder::app::AppCocoaTouch, and cinder::app::AppScreenSaver.

CallbackId cinder::app::App::registerMouseDown ( std::function< bool(MouseEvent)>  callback  ) 

Registers a callback for mouseDown events. Returns a unique identifier which can be used as a parameter to unregisterMouseDown().

template<typename T >
CallbackId cinder::app::App::registerMouseDown ( T *  obj,
bool(T::*)(MouseEvent callback 
)

Registers a callback for mouseDown events. Returns a unique identifier which can be used as a parameter to unregisterMouseDown().

void cinder::app::App::unregisterMouseDown ( CallbackId  id  ) 

Unregisters a callback for mouseDown events.

CallbackId cinder::app::App::registerMouseUp ( std::function< bool(MouseEvent)>  callback  ) 

Registers a callback for mouseUp events. Returns a unique identifier which can be used as a parameter to unregisterMouseUp().

template<typename T >
CallbackId cinder::app::App::registerMouseUp ( T *  obj,
bool(T::*)(MouseEvent callback 
)

Registers a callback for mouseUp events. Returns a unique identifier which can be used as a parameter to unregisterMouseUp().

void cinder::app::App::unregisterMouseUp ( CallbackId  id  ) 

Unregisters a callback for mouseUp events.

CallbackId cinder::app::App::registerMouseWheel ( std::function< bool(MouseEvent)>  callback  ) 

Registers a callback for mouseWheel events. Returns a unique identifier which can be used as a parameter to unregisterMouseWheel().

template<typename T >
CallbackId cinder::app::App::registerMouseWheel ( T *  obj,
bool(T::*)(MouseEvent callback 
)

Registers a callback for mouseWheel events. Returns a unique identifier which can be used as a parameter to unregisterMouseWheel().

void cinder::app::App::unregisterMouseWheel ( CallbackId  id  ) 

Unregisters a callback for mouseWheel events.

CallbackId cinder::app::App::registerMouseMove ( std::function< bool(MouseEvent)>  callback  ) 

Registers a callback for mouseMove events. Returns a unique identifier which can be used as a parameter to unregisterMouseMove().

template<typename T >
CallbackId cinder::app::App::registerMouseMove ( T *  obj,
bool(T::*)(MouseEvent callback 
)

Registers a callback for mouseMove events. Returns a unique identifier which can be used as a parameter to unregisterMouseMove().

void cinder::app::App::unregisterMouseMove ( CallbackId  id  ) 

Unregisters a callback for mouseMove events.

CallbackId cinder::app::App::registerMouseDrag ( std::function< bool(MouseEvent)>  callback  ) 

Registers a callback for mouseDrag events. Returns a unique identifier which can be used as a parameter to unregisterMouseDrag().

template<typename T >
CallbackId cinder::app::App::registerMouseDrag ( T *  obj,
bool(T::*)(MouseEvent callback 
)

Registers a callback for mouseDrag events. Returns a unique identifier which can be used as a parameter to unregisterMouseDrag().

void cinder::app::App::unregisterMouseDrag ( CallbackId  id  ) 

Unregisters a callback for mouseDrag events.

CallbackId cinder::app::App::registerKeyDown ( std::function< bool(KeyEvent)>  callback  ) 

Registers a callback for keyDown events. Returns a unique identifier which can be used as a parameter to unregisterKeyDown().

template<typename T >
CallbackId cinder::app::App::registerKeyDown ( T *  obj,
bool(T::*)(KeyEvent callback 
)

Registers a callback for keyDown events. Returns a unique identifier which can be used as a parameter to unregisterKeyDown().

void cinder::app::App::unregisterKeyDown ( CallbackId  id  ) 

Unregisters a callback for keyDown events.

CallbackId cinder::app::App::registerKeyUp ( std::function< bool(KeyEvent)>  callback  ) 

Registers a callback for keyUp events. Returns a unique identifier which can be used as a parameter to unregisterKeyUp().

template<typename T >
CallbackId cinder::app::App::registerKeyUp ( T *  obj,
bool(T::*)(KeyEvent callback 
)

Registers a callback for keyUp events. Returns a unique identifier which can be used as a parameter to unregisterKeyUp().

void cinder::app::App::unregisterKeyUp ( CallbackId  id  ) 

Unregisters a callback for keyUp events.

CallbackId cinder::app::App::registerResize ( std::function< bool(ResizeEvent)>  callback  ) 

Registers a callback for resize events. Returns a unique identifier which can be used as a parameter to unregisterKeyUp().

template<typename T >
CallbackId cinder::app::App::registerResize ( T *  obj,
bool(T::*)(ResizeEvent callback 
)

Registers a callback for resize events. Returns a unique identifier which can be used as a parameter to unregisterResize().

void cinder::app::App::unregisterResize ( CallbackId  id  ) 

Unregisters a callback for resize events.

CallbackId cinder::app::App::registerFileDrop ( std::function< bool(FileDropEvent)>  callback  ) 

Registers a callback for fileDrop events. Returns a unique identifier which can be used as a parameter to unregisterKeyUp().

template<typename T >
CallbackId cinder::app::App::registerFileDrop ( T *  obj,
bool(T::*)(FileDropEvent callback 
)

Registers a callback for fileDrop events. Returns a unique identifier which can be used as a parameter to unregisterFileDrop().

void cinder::app::App::unregisterFileDrop ( CallbackId  id  ) 

Unregisters a callback for fileDrop events.

virtual const Settings& cinder::app::App::getSettings (  )  const [pure virtual]
Renderer* cinder::app::App::getRenderer (  )  const
virtual int cinder::app::App::getWindowWidth (  )  const [pure virtual]

Returns the width of the App's window measured in pixels, or the screen when in full-screen mode.

Implemented in cinder::app::AppBasic, cinder::app::AppCocoaTouch, and cinder::app::AppScreenSaver.

virtual void cinder::app::App::setWindowWidth ( int  windowWidth  )  [pure virtual]

Sets the width of the App's window measured in pixels. Ignored in full-screen mode.

Implemented in cinder::app::AppBasic, cinder::app::AppCocoaTouch, and cinder::app::AppScreenSaver.

virtual int cinder::app::App::getWindowHeight (  )  const [pure virtual]

Returns the height of the App's window measured in pixels, or the screen when in full-screen mode.

Implemented in cinder::app::AppBasic, cinder::app::AppCocoaTouch, and cinder::app::AppScreenSaver.

virtual void cinder::app::App::setWindowHeight ( int  windowHeight  )  [pure virtual]

Sets the height of the App's window measured in pixels. Ignored in full-screen mode.

Implemented in cinder::app::AppBasic, cinder::app::AppCocoaTouch, and cinder::app::AppScreenSaver.

virtual void cinder::app::App::setWindowSize ( int  windowWidth,
int  windowHeight 
) [pure virtual]

Sets the size of the App's window. Ignored in full-screen mode.

Implemented in cinder::app::AppBasic, cinder::app::AppCocoaTouch, and cinder::app::AppScreenSaver.

void cinder::app::App::setWindowSize ( const Vec2i size  ) 

Sets the size of the App's window. Ignored in full-screen mode.

Vec2f cinder::app::App::getWindowCenter (  )  const

Returns the center of the App's window or the screen in full-screen mode.

Equivalent to

 Vec2f( getWindowWidth() * 0.5, getWindowHeight() * 0.5 ) 
Vec2i cinder::app::App::getWindowSize (  )  const

Returns the size of the App's window or the screen in full-screen mode.

float cinder::app::App::getWindowAspectRatio (  )  const

Returns the aspect ratio of the App's window or the screen in full-screen mode.

Area cinder::app::App::getWindowBounds (  )  const

Returns the bounding area of the App's window or the screen in full-screen mode.

Equivalent to

virtual float cinder::app::App::getFrameRate (  )  const [pure virtual]

Returns the maximum frame-rate the App will attempt to maintain.

Implemented in cinder::app::AppBasic, cinder::app::AppCocoaTouch, and cinder::app::AppScreenSaver.

virtual void cinder::app::App::setFrameRate ( float  aFrameRate  )  [pure virtual]

Sets the maximum frame-rate the App will attempt to maintain.

Implemented in cinder::app::AppBasic, cinder::app::AppCocoaTouch, and cinder::app::AppScreenSaver.

float cinder::app::App::getAverageFps (  )  const

Returns the average frame-rate attained by the App as measured in frames-per-second.

double cinder::app::App::getFpsSampleInterval (  )  const

Returns the sampling rate in seconds for measuring the average frame-per-second as returned by getAverageFps().

void cinder::app::App::setFpsSampleInterval ( double  sampleInterval  ) 

Sets the sampling rate in seconds for measuring the average frame-per-second as returned by getAverageFps().

virtual bool cinder::app::App::isFullScreen (  )  const [pure virtual]

Returns whether the App is in full-screen mode or not.

Implemented in cinder::app::AppBasic, cinder::app::AppCocoaTouch, and cinder::app::AppScreenSaver.

virtual void cinder::app::App::setFullScreen ( bool  aFullScreen  )  [pure virtual]

Sets whether the active App is in full-screen mode based on fullScreen.

Implemented in cinder::app::AppBasic, cinder::app::AppCocoaTouch, and cinder::app::AppScreenSaver.

double cinder::app::App::getElapsedSeconds (  )  const

Returns the number of seconds which have elapsed since application launch.

Reimplemented in cinder::app::AppCocoaTouch.

uint32_t cinder::app::App::getElapsedFrames (  )  const

Returns the number of animation frames which have elapsed since application launch.

DataSourceRef cinder::app::App::loadResource ( const std::string &  macPath,
int  mswID,
const std::string &  mswType 
) [static]

Returns a DataSourceRef to an application resource. On Mac OS X, macPath is a path relative to the bundle's resources folder. On Windows, mswID and mswType identify the resource as defined the application's .rc file(s). Throws ResourceLoadExc on failure.

See also:
Using Resources in Cinder
DataSourcePathRef cinder::app::App::loadResource ( const std::string &  macPath  )  [static]

Returns a DataSourceRef to an application resource. macPath is a path relative to the bundle's resources folder. Throws ResourceLoadExc on failure.

See also:
Using Resources in Cinder
string cinder::app::App::getResourcePath ( const std::string &  rsrcRelativePath  )  [static]

Returns the absolute file path to a resource located at rsrcRelativePath inside the bundle's resources folder. Throws ResourceLoadExc on failure.

See also:
Using Resources in Cinder
string cinder::app::App::getResourcePath (  )  [static]

Returns the absolute file path to the bundle's resources folder.

See also:
Using Resources in Cinder
DataSourceBufferRef cinder::app::App::loadResource ( int  mswID,
const std::string &  mswType 
) [static]

Returns a DataSourceRef to an application resource. mswID and mswType identify the resource as defined the application's .rc file(s).

See also:
Using Resources in Cinder
virtual std::string cinder::app::App::getAppPath (  )  [pure virtual]

Returns the path to the application on disk.

Implemented in cinder::app::AppBasic, cinder::app::AppCocoaTouch, and cinder::app::AppScreenSaver.

string cinder::app::App::getOpenFilePath ( const std::string &  initialPath = "",
std::vector< std::string >  extensions = std::vector<std::string>() 
)

Presents the user with a file-open dialog and returns the selected file path.

The dialog optionally begins at the path initialPath and can be limited to allow selection of files ending in the extensions enumerated in extensions. If the active app is in full-screen mode it will temporarily switch to windowed-mode to present the dialog.

Returns:
the selected file path or an empty string if the user cancelled.
string cinder::app::App::getFolderPath ( const std::string &  initialPath = ""  ) 

Presents the user with a folder-open dialog and returns the selected folder.

string cinder::app::App::getSaveFilePath ( const std::string &  initialPath = "",
std::vector< std::string >  extensions = std::vector<std::string>() 
)

Presents the user with a file-save dialog and returns the selected file path.

The dialog optionally begins at the path initialPath and can be limited to allow selection of files ending in the extensions enumerated in extensions. If the active app is in full-screen mode it will temporarily switch to windowed-mode to present the dialog.

Returns:
the selected file path or an empty string if the user cancelled.
std::ostream & cinder::app::App::console (  ) 

Returns a reference to an output console, which is an alias to std::cout on the mac, and a wrapper around OutputDebugString on MSW.

Surface cinder::app::App::copyWindowSurface (  ) 
Returns:
a copy of the window's contents as a Surface8u
Surface cinder::app::App::copyWindowSurface ( const Area area  ) 
Returns:
a copy of the Area area from the window's contents as a Surface8u
void cinder::app::App::restoreWindowContext (  ) 

Restores the current rendering context to be the App's window or the screen in full-screen mode. Generally this is only necessary if the app has displayed a dialog box or some other external window.

virtual bool cinder::app::App::getsWindowsPaintEvents (  )  [pure virtual]

Implemented in cinder::app::AppScreenSaver.

virtual bool cinder::app::App::receivesEvents (  )  const [virtual]

Reimplemented in cinder::app::AppScreenSaver.

static App* cinder::app::App::get (  )  [static]

Returns a pointer to the active App.

Reimplemented in cinder::app::AppBasic, and cinder::app::AppCocoaTouch.


Friends And Related Function Documentation

friend class AppImplMsw [friend]

The documentation for this class was generated from the following files: