![]() |
Cinder
0.9.1
|
#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 |
Timeline & | timeline () |
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 AppBase * | get () |
Protected Member Functions | |
AppBase () | |
Protected Attributes | |
bool | mPowerManagement |
Static Protected Attributes | |
static AppBase * | sInstance = nullptr |
static Settings * | sSettingsFromMain = nullptr |
Base class that all apps derive from.
|
virtual |
|
protected |
|
virtual |
Override to perform any application setup after the Renderer has been initialized.
|
virtual |
Override to perform any once-per-loop computation.
|
virtual |
Override to perform any rendering once-per-loop or in response to OS-prompted requests for refreshes.
|
virtual |
Override to receive mouse-down events.
|
virtual |
Override to receive mouse-up events.
|
virtual |
Override to receive mouse-wheel events.
|
virtual |
Override to receive mouse-move events.
|
virtual |
Override to receive mouse-drag events.
|
virtual |
Override to respond to the beginning of a multitouch sequence.
|
virtual |
Override to respond to movement (drags) during a multitouch sequence.
|
virtual |
Override to respond to the end of a multitouch sequence.
|
virtual |
Override to receive key-down events.
|
virtual |
Override to receive key-up events.
|
virtual |
Override to receive window resize events.
|
virtual |
Override to receive file-drop events.
|
virtual |
Override to cleanup any resources before app destruction.
|
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 |
DisplayRef cinder::app::AppBase::getDisplay | ( | ) | const |
|
pure virtual |
Creates and returns a reference to a new Window, adhering to format.
Implemented in cinder::app::AppScreenSaver, cinder::app::AppCocoaTouch, cinder::app::AppCocoaView, cinder::app::AppMsw, cinder::app::AppWinRt, and cinder::app::AppMac.
|
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.
|
pure virtual |
Gets the foreground Window, which has keyboard and mouse focus.
Implemented in cinder::app::AppScreenSaver, cinder::app::AppCocoaTouch, cinder::app::AppMsw, cinder::app::AppCocoaView, cinder::app::AppWinRt, and cinder::app::AppMac.
|
pure virtual |
Returns the number of Windows the app has open.
Implemented in cinder::app::AppScreenSaver, cinder::app::AppCocoaTouch, cinder::app::AppMsw, cinder::app::AppWinRt, cinder::app::AppCocoaView, and cinder::app::AppMac.
|
pure virtual |
Gets a Window by index, in the range [0, getNumWindows()). Throw ExcInvalidWindow if index is out of bounds.
Implemented in cinder::app::AppScreenSaver, cinder::app::AppCocoaTouch, cinder::app::AppMsw, cinder::app::AppWinRt, cinder::app::AppCocoaView, and cinder::app::AppMac.
|
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.
|
pure virtual |
Hides the mouse cursor.
Implemented in cinder::app::AppCocoaTouch, cinder::app::AppScreenSaver, cinder::app::AppMsw, cinder::app::AppCocoaView, cinder::app::AppWinRt, and cinder::app::AppMac.
|
pure virtual |
Shows the mouse cursor.
Implemented in cinder::app::AppCocoaTouch, cinder::app::AppScreenSaver, cinder::app::AppMsw, cinder::app::AppCocoaView, cinder::app::AppWinRt, and cinder::app::AppMac.
|
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 |
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 |
Sets the coordinates of the top-left corner of the current window measured points.
|
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.
|
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.
|
pure virtual |
Disables frameRate limiting.
Implemented in cinder::app::AppCocoaTouch, cinder::app::AppScreenSaver, cinder::app::AppMsw, cinder::app::AppWinRt, cinder::app::AppCocoaView, and cinder::app::AppMac.
|
pure virtual |
Returns whether frameRate limiting is enabled.
Implemented in cinder::app::AppCocoaTouch, cinder::app::AppScreenSaver, cinder::app::AppMsw, cinder::app::AppWinRt, cinder::app::AppCocoaView, and cinder::app::AppMac.
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 |
Returns whether the App is in full-screen mode or not.
Reimplemented in cinder::app::AppCocoaTouch.
|
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 |
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).
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.
fs::path cinder::app::AppBase::getFolderPath | ( | const fs::path & | initialPath = fs::path() | ) |
Presents the user with an open-folder dialog.
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.
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.
|
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()
std::result_of< T()>::type cinder::app::AppBase::dispatchSync | ( | T | fn | ) |
RendererRef cinder::app::AppBase::getDefaultRenderer | ( | ) | const |
Surface cinder::app::AppBase::copyWindowSurface | ( | ) |
|
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 |
Reimplemented in cinder::app::AppScreenSaver.
|
static |
Returns a pointer to the active App.
|
staticprotected |
|
staticprotected |
|
protected |