Cinder  0.9.1
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
cinder::app::AppBase Class Referenceabstract

#include <AppBase.h>

Inherited by cinder::app::AppCocoaTouch, cinder::app::AppCocoaView, cinder::app::AppMac, cinder::app::AppMsw, cinder::app::AppScreenSaver, and cinder::app::AppWinRt.

Classes

class  Settings
 

Public Member Functions

virtual ~AppBase ()
 
virtual void setup ()
 
virtual void update ()
 
virtual void draw ()
 
virtual void mouseDown (MouseEvent event)
 
virtual void mouseUp (MouseEvent event)
 
virtual void mouseWheel (MouseEvent event)
 
virtual void mouseMove (MouseEvent event)
 
virtual void mouseDrag (MouseEvent event)
 
virtual void touchesBegan (TouchEvent event)
 
virtual void touchesMoved (TouchEvent event)
 
virtual void touchesEnded (TouchEvent event)
 
virtual void keyDown (KeyEvent event)
 
virtual void keyUp (KeyEvent event)
 
virtual void resize ()
 
virtual void fileDrop (FileDropEvent event)
 
virtual void cleanup ()
 
virtual void quit ()=0
 
signals::Signal< void()> & getSignalUpdate ()
 
EventSignalShouldQuit & getSignalShouldQuit ()
 
signals::Signal< void()> & getSignalCleanup ()
 
void emitCleanup ()
 
signals::Signal< void()> & getSignalWillResignActive ()
 
void emitWillResignActive ()
 
signals::Signal< void()> & getSignalDidBecomeActive ()
 
void emitDidBecomeActive ()
 
signals::Signal< void(const DisplayRef &display)> & getSignalDisplayConnected ()
 
void emitDisplayConnected (const DisplayRef &display)
 
signals::Signal< void(const DisplayRef &display)> & getSignalDisplayDisconnected ()
 
void emitDisplayDisconnected (const DisplayRef &display)
 
signals::Signal< void(const DisplayRef &display)> & getSignalDisplayChanged ()
 
void emitDisplayChanged (const DisplayRef &display)
 
const std::vector< TouchEvent::Touch > & getActiveTouches () const
 
RendererRef getRenderer () const
 
DisplayRef getDisplay () const
 
virtual WindowRef createWindow (const Window::Format &format=Window::Format())=0
 
virtual WindowRef getWindow () const =0
 
virtual WindowRef getForegroundWindow () const =0
 
virtual size_t getNumWindows () const =0
 
virtual WindowRef getWindowIndex (size_t index) const =0
 
virtual ivec2 getMousePos () const =0
 
virtual void hideCursor ()=0
 
virtual void showCursor ()=0
 
virtual void enablePowerManagement (bool powerManagement=true)
 
virtual bool isPowerManagementEnabled () const
 
int getWindowWidth () const
 
int getWindowHeight () const
 
void setWindowSize (int windowWidth, int windowHeight)
 
void setWindowSize (const ivec2 &size)
 
vec2 getWindowCenter () const
 
ivec2 getWindowSize () const
 
float getWindowAspectRatio () const
 
Area getWindowBounds () const
 
float getWindowContentScale () const
 
ivec2 getWindowPos () const
 
int getWindowPosX () const
 
int getWindowPosY () const
 
void setWindowPos (int x, int y)
 
virtual void setWindowPos (const ivec2 &windowPos)
 
virtual float getFrameRate () const =0
 
virtual void setFrameRate (float frameRate)=0
 
virtual void disableFrameRate ()=0
 
virtual bool isFrameRateEnabled () const =0
 
float getAverageFps () const
 
double getFpsSampleInterval () const
 
void setFpsSampleInterval (double sampleInterval)
 
virtual bool isFullScreen () const
 
virtual void setFullScreen (bool fullScreen, const FullScreenOptions &options=FullScreenOptions())
 
double getElapsedSeconds () const
 
uint32_t getElapsedFrames () const
 
bool isMultiTouchEnabled () const
 
bool isHighDensityDisplayEnabled () const
 
DataSourceRef loadResource (const fs::path &resourcePath, int mswID, const std::string &mswType) const
 
DataSourceRef loadAsset (const fs::path &relativePath)
 
fs::path getAssetPath (const fs::path &relativePath) const
 
void addAssetDirectory (const fs::path &dirPath)
 
fs::path getAppPath () const
 
fs::path getOpenFilePath (const fs::path &initialPath=fs::path(), const std::vector< std::string > &extensions=std::vector< std::string >())
 
fs::path getFolderPath (const fs::path &initialPath=fs::path())
 
fs::path getSaveFilePath (const fs::path &initialPath=fs::path(), const std::vector< std::string > &extensions=std::vector< std::string >())
 
std::ostream & console ()
 
const std::vector< std::string > & getCommandLineArgs () const
 
Timelinetimeline ()
 
asio::io_service & io_service ()
 
void dispatchAsync (const std::function< void()> &fn)
 
template<typename T >
std::result_of< T()>::type dispatchSync (T fn)
 
RendererRef getDefaultRenderer () const
 
Surface copyWindowSurface ()
 
Surface copyWindowSurface (const Area &area)
 
virtual void restoreWindowContext ()
 
virtual bool receivesEvents () const
 

Static Public Member Functions

static bool isMainThread ()
 
static AppBaseget ()
 

Protected Member Functions

 AppBase ()
 

Protected Attributes

bool mPowerManagement
 

Static Protected Attributes

static AppBasesInstance = nullptr
 
static SettingssSettingsFromMain = nullptr
 

Detailed Description

Base class that all apps derive from.

Constructor & Destructor Documentation

cinder::app::AppBase::~AppBase ( )
virtual
cinder::app::AppBase::AppBase ( )
protected

Member Function Documentation

virtual void cinder::app::AppBase::setup ( )
virtual

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

virtual void cinder::app::AppBase::update ( )
virtual

Override to perform any once-per-loop computation.

virtual void cinder::app::AppBase::draw ( )
virtual

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

virtual void cinder::app::AppBase::mouseDown ( MouseEvent  event)
virtual

Override to receive mouse-down events.

virtual void cinder::app::AppBase::mouseUp ( MouseEvent  event)
virtual

Override to receive mouse-up events.

virtual void cinder::app::AppBase::mouseWheel ( MouseEvent  event)
virtual

Override to receive mouse-wheel events.

virtual void cinder::app::AppBase::mouseMove ( MouseEvent  event)
virtual

Override to receive mouse-move events.

virtual void cinder::app::AppBase::mouseDrag ( MouseEvent  event)
virtual

Override to receive mouse-drag events.

virtual void cinder::app::AppBase::touchesBegan ( TouchEvent  event)
virtual

Override to respond to the beginning of a multitouch sequence.

virtual void cinder::app::AppBase::touchesMoved ( TouchEvent  event)
virtual

Override to respond to movement (drags) during a multitouch sequence.

virtual void cinder::app::AppBase::touchesEnded ( TouchEvent  event)
virtual

Override to respond to the end of a multitouch sequence.

virtual void cinder::app::AppBase::keyDown ( KeyEvent  event)
virtual

Override to receive key-down events.

virtual void cinder::app::AppBase::keyUp ( KeyEvent  event)
virtual

Override to receive key-up events.

virtual void cinder::app::AppBase::resize ( )
virtual

Override to receive window resize events.

virtual void cinder::app::AppBase::fileDrop ( FileDropEvent  event)
virtual

Override to receive file-drop events.

virtual void cinder::app::AppBase::cleanup ( )
virtual

Override to cleanup any resources before app destruction.

virtual void cinder::app::AppBase::quit ( )
pure virtual

Requests that the application exit gracefully. Use std::terminate() instead to end application immediately.

Implemented in cinder::app::AppCocoaTouch, cinder::app::AppScreenSaver, cinder::app::AppMsw, cinder::app::AppWinRt, cinder::app::AppCocoaView, and cinder::app::AppMac.

signals::Signal<void()>& cinder::app::AppBase::getSignalUpdate ( )

Emitted at the start of each application update cycle.

EventSignalShouldQuit& cinder::app::AppBase::getSignalShouldQuit ( )

Signal that emits before the app quit process begins. If any slots return false then the app quitting is canceled.

signals::Signal<void()>& cinder::app::AppBase::getSignalCleanup ( )

Emitted prior to the application shutting down.

void cinder::app::AppBase::emitCleanup ( )
signals::Signal<void()>& cinder::app::AppBase::getSignalWillResignActive ( )
void cinder::app::AppBase::emitWillResignActive ( )
signals::Signal<void()>& cinder::app::AppBase::getSignalDidBecomeActive ( )
void cinder::app::AppBase::emitDidBecomeActive ( )
signals::Signal<void(const DisplayRef &display)>& cinder::app::AppBase::getSignalDisplayConnected ( )

Emitted when a new display is connected to the system.

void cinder::app::AppBase::emitDisplayConnected ( const DisplayRef display)

Emits a signal indicating a new display has connected to the system.

signals::Signal<void(const DisplayRef &display)>& cinder::app::AppBase::getSignalDisplayDisconnected ( )

Emitted when a display is removed from the system.

void cinder::app::AppBase::emitDisplayDisconnected ( const DisplayRef display)

Emits a signal indicating a display has disconnected from the system.

signals::Signal<void(const DisplayRef &display)>& cinder::app::AppBase::getSignalDisplayChanged ( )

Emitted when the resolution or some other property of a Display is changed.

void cinder::app::AppBase::emitDisplayChanged ( const DisplayRef display)

Emits a signal when the resolution or some other property of a Display has changed.

const std::vector<TouchEvent::Touch>& cinder::app::AppBase::getActiveTouches ( ) const
RendererRef cinder::app::AppBase::getRenderer ( ) const

Returns the Renderer of the active Window.

DisplayRef cinder::app::AppBase::getDisplay ( ) const

Returns the Display of the active Window.

virtual WindowRef cinder::app::AppBase::createWindow ( const Window::Format format = Window::Format())
pure virtual
virtual WindowRef cinder::app::AppBase::getWindow ( ) const
pure virtual

Returns the the currently active Window. Throws ExcInvalidWindow if called with no active window.

Implemented in cinder::app::AppScreenSaver, cinder::app::AppCocoaTouch, cinder::app::AppMsw, cinder::app::AppWinRt, cinder::app::AppCocoaView, and cinder::app::AppMac.

virtual WindowRef cinder::app::AppBase::getForegroundWindow ( ) const
pure virtual
virtual size_t cinder::app::AppBase::getNumWindows ( ) const
pure virtual
virtual WindowRef cinder::app::AppBase::getWindowIndex ( size_t  index) const
pure virtual
virtual ivec2 cinder::app::AppBase::getMousePos ( ) const
pure virtual

Returns the current location of the mouse in screen coordinates measured in points. Can be called outside the normal event loop.

Implemented in cinder::app::AppCocoaTouch, cinder::app::AppScreenSaver, cinder::app::AppMsw, cinder::app::AppWinRt, cinder::app::AppCocoaView, and cinder::app::AppMac.

virtual void cinder::app::AppBase::hideCursor ( )
pure virtual
virtual void cinder::app::AppBase::showCursor ( )
pure virtual
virtual void cinder::app::AppBase::enablePowerManagement ( bool  powerManagement = true)
virtual

a value of true allows screensavers or the system's power management to hide the app. Default value is false on desktop, and true on mobile

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

virtual bool cinder::app::AppBase::isPowerManagementEnabled ( ) const
virtual

is power management enabled, allowing screensavers and the system's power management to hide the application

Reimplemented in cinder::app::AppMac.

int cinder::app::AppBase::getWindowWidth ( ) const

Returns the width of the App's current window measured in points.

int cinder::app::AppBase::getWindowHeight ( ) const

Returns the height of the App's current window measured in points.

void cinder::app::AppBase::setWindowSize ( int  windowWidth,
int  windowHeight 
)

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

void cinder::app::AppBase::setWindowSize ( const ivec2 &  size)

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

vec2 cinder::app::AppBase::getWindowCenter ( ) const

Returns the center of the App's window measured in points.

Equivalent to vec2( getWindowWidth() * 0.5, getWindowHeight() * 0.5 )

ivec2 cinder::app::AppBase::getWindowSize ( ) const

Returns the size of the App's current window measured in points.

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

Returns the aspect ratio of the App's current window.

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

Returns the bounding area of the App's current window measured in points.

Equivalent to Area( 0, 0, getWindowWidth(), getWindowHeight() );

float cinder::app::AppBase::getWindowContentScale ( ) const

Returns the contentScale of the App's window, which is the multiplier that maps points to pixels.

ivec2 cinder::app::AppBase::getWindowPos ( ) const

Returns tcoordinates of the top-left corner of the current window measured in points.

int cinder::app::AppBase::getWindowPosX ( ) const

Returns the X coordinate of the top-left corner of the current window measured in points.

int cinder::app::AppBase::getWindowPosY ( ) const

Returns the Y coordinate of the top-left corner of the current window contents measured in points.

void cinder::app::AppBase::setWindowPos ( int  x,
int  y 
)

Sets the coordinates of the top-left corner of the current window measured in points.

virtual void cinder::app::AppBase::setWindowPos ( const ivec2 &  windowPos)
virtual

Sets the coordinates of the top-left corner of the current window measured points.

virtual float cinder::app::AppBase::getFrameRate ( ) const
pure virtual

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

Implemented in cinder::app::AppCocoaTouch, cinder::app::AppScreenSaver, cinder::app::AppMsw, cinder::app::AppWinRt, cinder::app::AppCocoaView, and cinder::app::AppMac.

virtual void cinder::app::AppBase::setFrameRate ( float  frameRate)
pure virtual

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

Implemented in cinder::app::AppCocoaTouch, cinder::app::AppScreenSaver, cinder::app::AppMsw, cinder::app::AppWinRt, cinder::app::AppCocoaView, and cinder::app::AppMac.

virtual void cinder::app::AppBase::disableFrameRate ( )
pure virtual
virtual bool cinder::app::AppBase::isFrameRateEnabled ( ) const
pure virtual
float cinder::app::AppBase::getAverageFps ( ) const

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

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

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

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

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

virtual bool cinder::app::AppBase::isFullScreen ( ) const
virtual

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

Reimplemented in cinder::app::AppCocoaTouch.

virtual void cinder::app::AppBase::setFullScreen ( bool  fullScreen,
const FullScreenOptions options = FullScreenOptions() 
)
virtual

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

Reimplemented in cinder::app::AppCocoaTouch.

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

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

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

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

bool cinder::app::AppBase::isMultiTouchEnabled ( ) const

Returns whether the app is registered to receive multiTouch events from the operating system, configurable via Settings at startup. Disabled by default on desktop platforms, enabled on mobile.

bool cinder::app::AppBase::isHighDensityDisplayEnabled ( ) const

Returns whether Windows created on a high-density (Retina) display will have their resolution doubled, configurable via Settings at startup. Default is true on iOS and false on other platforms.

DataSourceRef cinder::app::AppBase::loadResource ( const fs::path &  resourcePath,
int  mswID,
const std::string &  mswType 
) const

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

See also
CinderResources
DataSourceRef cinder::app::AppBase::loadAsset ( const fs::path &  relativePath)

Returns a DataSourceRef to an application asset. Throws a AssetLoadExc on failure.

fs::path cinder::app::AppBase::getAssetPath ( const fs::path &  relativePath) const

Returns a fs::path to an application asset. Returns an empty path on failure.

void cinder::app::AppBase::addAssetDirectory ( const fs::path &  dirPath)

Adds an absolute path 'dirPath' to the list of directories which are searched for assets.

fs::path cinder::app::AppBase::getAppPath ( ) const

Returns the path to the application on disk.

fs::path cinder::app::AppBase::getOpenFilePath ( const fs::path &  initialPath = fs::path(),
const std::vector< std::string > &  extensions = std::vector<std::string>() 
)

Presents the user with an open-file 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.

Returns
the selected file path, or an empty fs::path if the user cancelled or this operation isn't supported on the current platform.
fs::path cinder::app::AppBase::getFolderPath ( const fs::path &  initialPath = fs::path())

Presents the user with an open-folder dialog.

Returns
the selected file path, or an empty fs::path if the user cancelled or this operation isn't supported on the current platform.
fs::path cinder::app::AppBase::getSaveFilePath ( const fs::path &  initialPath = fs::path(),
const std::vector< std::string > &  extensions = std::vector<std::string>() 
)

Presents the user with a save-file 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.

Returns
the selected file path, or an empty fs::path if the user cancelled or this operation isn't supported on the current platform.
std::ostream & cinder::app::AppBase::console ( )

Returns a reference to an output console, which is by default an alias to std::cout. Other platforms may override to use other necessary console mechanisms.

const std::vector<std::string>& cinder::app::AppBase::getCommandLineArgs ( ) const

Returns a vector of the command line arguments passed to the app when intantiated.

Timeline& cinder::app::AppBase::timeline ( )

Returns a reference to the App's Timeline.

bool cinder::app::AppBase::isMainThread ( )
static

Returns true if the calling thread is the Application's main thread (the thread running the main function), false otherwise.

asio::io_service& cinder::app::AppBase::io_service ( )

Returns a reference to the App's boost::asio::io_service()

void cinder::app::AppBase::dispatchAsync ( const std::function< void()> &  fn)

Executes a std::function on the App's primary thread ahead of the next update()

template<typename T >
std::result_of< T()>::type cinder::app::AppBase::dispatchSync ( fn)
RendererRef cinder::app::AppBase::getDefaultRenderer ( ) const

Returns the default Renderer which will be used when creating a new Window. Set by the app instantiation macro automatically.

Surface cinder::app::AppBase::copyWindowSurface ( )
Returns
a copy of the current window's contents as a Surface8u
Surface cinder::app::AppBase::copyWindowSurface ( const Area area)
Returns
a copy of the Area area (measured in pixels) from the current window's contents as a Surface8u
void cinder::app::AppBase::restoreWindowContext ( )
virtual

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::AppBase::receivesEvents ( ) const
virtual

Reimplemented in cinder::app::AppScreenSaver.

static AppBase* cinder::app::AppBase::get ( )
static

Returns a pointer to the active App.

Member Data Documentation

AppBase * cinder::app::AppBase::sInstance = nullptr
staticprotected
AppBase::Settings * cinder::app::AppBase::sSettingsFromMain = nullptr
staticprotected
bool cinder::app::AppBase::mPowerManagement
protected

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