Cinder  0.8.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | Static Protected Attributes | List of all members
cinder::app::AppBasic Class Reference

#include <AppBasic.h>

Inheritance diagram for cinder::app::AppBasic:
[legend]

Classes

class  Settings
 

Public Types

typedef std::shared_ptr< WindowWindowRef
 

Public Member Functions

 AppBasic ()
 
virtual ~AppBasic ()
 
virtual void prepareSettings (Settings *settings)
 
EventSignalShouldQuitgetSignalShouldQuit ()
 This is fired before the app is quit. If any slots return false then the app quitting is canceled. More...
 
WindowRef createWindow (const Window::Format &format=Window::Format())
 Creates a new Window. More...
 
virtual float getFrameRate () const
 Returns the maximum frame-rate the App will attempt to maintain measured in frames-per-second. More...
 
virtual void setFrameRate (float frameRate)
 Sets the maximum frame-rate the App will attempt to maintain \ a frameRate frames-per-second. More...
 
virtual void disableFrameRate ()
 Disables frameRate limiting. More...
 
virtual bool isFrameRateEnabled () const
 Returns whether frameRate limiting is enabled. More...
 
void hideCursor ()
 Hides the mouse cursor. More...
 
void showCursor ()
 Shows the mouse cursor. More...
 
const SettingsgetSettings () const
 
virtual void quit ()
 Ceases execution of the application. More...
 
const std::vector< std::string > & getArgs () const
 Returns a vector of the command line arguments passed to the app. More...
 
virtual fs::path getAppPath () const
 Returns the path to the application on disk. More...
 
virtual app::WindowRef getWindow () const
 Gets the currently active Window. More...
 
virtual size_t getNumWindows () const
 Returns the number of Windows the app has open. More...
 
virtual WindowRef getWindowIndex (size_t index) const
 Gets a Window by index, in the range [0, getNumWindows()). More...
 
virtual WindowRef getForegroundWindow () const
 Gets the foreground Window, which has keyboard and mouse focus. More...
 
virtual void setup ()
 Override to perform any application setup after the Renderer has been initialized. More...
 
virtual void shutdown ()
 Override to perform any application cleanup before exiting. More...
 
virtual void update ()
 Override to perform any once-per-loop computation. More...
 
virtual void draw ()
 Override to perform any rendering once-per-loop or in response to OS-prompted requests for refreshes. More...
 
virtual void mouseDown (MouseEvent event)
 Override to receive mouse-down events. More...
 
virtual void mouseUp (MouseEvent event)
 Override to receive mouse-up events. More...
 
virtual void mouseWheel (MouseEvent event)
 Override to receive mouse-wheel events. More...
 
virtual void mouseMove (MouseEvent event)
 Override to receive mouse-move events. More...
 
virtual void mouseDrag (MouseEvent event)
 Override to receive mouse-drag events. More...
 
virtual void touchesBegan (TouchEvent event)
 Override to respond to the beginning of a multitouch sequence. More...
 
virtual void touchesMoved (TouchEvent event)
 Override to respond to movement (drags) during a multitouch sequence. More...
 
virtual void touchesEnded (TouchEvent event)
 Override to respond to the end of a multitouch sequence. More...
 
virtual void keyDown (KeyEvent event)
 Override to receive key-down events. More...
 
virtual void keyUp (KeyEvent event)
 Override to receive key-up events. More...
 
virtual void resize ()
 Override to receive window resize events. More...
 
virtual void fileDrop (FileDropEvent event)
 Override to receive file-drop events. More...
 
signals::signal< void()> & getSignalUpdate ()
 Emitted at the start of each application update cycle. More...
 
signals::signal< void()> & getSignalShutdown ()
 Emitted prior to the application shutting down. More...
 
void emitShutdown ()
 
signals::signal< void()> & getSignalWillResignActive ()
 
void emitWillResignActive ()
 
signals::signal< void()> & getSignalDidBecomeActive ()
 
void emitDidBecomeActive ()
 
const std::vector
< TouchEvent::Touch > & 
getActiveTouches () const
 
RendererRef getRenderer () const
 Returns the Renderer of the active Window. More...
 
DisplayRef getDisplay () const
 Returns the Display of the active Window. More...
 
virtual void enablePowerManagement (bool powerManagement=true)
 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 More...
 
virtual bool isPowerManagementEnabled () const
 is power management enabled, allowing screensavers and the system's power management to hide the application More...
 
int getWindowWidth () const
 Returns the width of the App's current window measured in points. More...
 
int getWindowHeight () const
 Returns the height of the App's current window measured in points. More...
 
void setWindowSize (int windowWidth, int windowHeight)
 Sets the size of the App's current window measured in points. Ignored in full-screen mode. More...
 
void setWindowSize (const Vec2i &size)
 Sets the size of the App's window measured in points. Ignored in full-screen mode. More...
 
Vec2f getWindowCenter () const
 Returns the center of the App's window measured in points. More...
 
Vec2i getWindowSize () const
 Returns the size of the App's current window measured in points. More...
 
float getWindowAspectRatio () const
 Returns the aspect ratio of the App's current window. More...
 
Area getWindowBounds () const
 Returns the bounding area of the App's current window measured in points. More...
 
float getWindowContentScale () const
 Returns the contentScale of the App's window, which is the multiplier that maps points to pixels. More...
 
Vec2i getWindowPos () const
 Returns tcoordinates of the top-left corner of the current window measured in points. More...
 
int getWindowPosX () const
 Returns the X coordinate of the top-left corner of the current window measured in points. More...
 
int getWindowPosY () const
 Returns the Y coordinate of the top-left corner of the current window contents measured in points. More...
 
void setWindowPos (int x, int y)
 Sets the coordinates of the top-left corner of the current window measured in points. More...
 
virtual void setWindowPos (const Vec2i &windowPos)
 Sets the coordinates of the top-left corner of the current window measured points. More...
 
float getAverageFps () const
 Returns the average frame-rate attained by the App as measured in frames-per-second. More...
 
double getFpsSampleInterval () const
 Returns the sampling rate in seconds for measuring the average frame-per-second as returned by getAverageFps() More...
 
void setFpsSampleInterval (double sampleInterval)
 Sets the sampling rate in seconds for measuring the average frame-per-second as returned by getAverageFps() More...
 
bool isFullScreen () const
 Returns whether the App is in full-screen mode or not. More...
 
void setFullScreen (bool aFullScreen, const FullScreenOptions &options=FullScreenOptions())
 Sets whether the active App is in full-screen mode based on fullScreen. More...
 
double getElapsedSeconds () const
 Returns the number of seconds which have elapsed since application launch. More...
 
uint32_t getElapsedFrames () const
 Returns the number of animation frames which have elapsed since application launch. More...
 
DataSourceRef loadAsset (const fs::path &relativePath)
 Returns a DataSourceRef to an application asset. Throws a AssetLoadExc on failure. More...
 
fs::path getAssetPath (const fs::path &relativePath)
 Returns a fs::path to an application asset. Returns an empty path on failure. More...
 
void addAssetDirectory (const fs::path &dirPath)
 Adds an absolute path 'dirPath' to the list of directories which are searched for assets. More...
 
fs::path getOpenFilePath (const fs::path &initialPath="", std::vector< std::string > extensions=std::vector< std::string >())
 Presents the user with a folder-open dialog and returns the selected folder path in the spcified callback. More...
 
fs::path getFolderPath (const fs::path &initialPath="")
 Presents the user with a folder-open dialog and returns the selected folder. More...
 
fs::path getSaveFilePath (const fs::path &initialPath="", std::vector< std::string > extensions=std::vector< std::string >())
 Presents the user with a file-save dialog and returns the selected file path. More...
 
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. More...
 
Timelinetimeline ()
 Returns a reference to the App's Timeline. More...
 
boost::asio::io_service & io_service ()
 Returns a reference to the App's boost::asio::io_service() More...
 
void dispatchAsync (const std::function< void()> &fn)
 defined( CINDER_WINRT ) More...
 
template<typename T >
std::result_of< T()>::type dispatchSync (T fn)
 
RendererRef getDefaultRenderer () const
 Returns the default Renderer which will be used when creating a new Window. Set by the app instantiation macro automatically. More...
 
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. More...
 
RendererRef findSharedRenderer (RendererRef searchRenderer) const
 Finds any Renderer of the same type as searchRenderer among existing windows. This is generally not necessary and used to enable context sharing between Windows. Returns NULL on failure. More...
 
virtual bool receivesEvents () const
 

Static Public Member Functions

static AppBasicget ()
 Returns a pointer to the current global AppBasic. More...
 
static Vec2i getMousePos ()
 Returns the current location of the mouse in screen coordinates measured in points. Can be called outside the normal event loop. More...
 
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. More...
 
static bool isPrimaryThread ()
 Return true if the calling thread is the Application's primary thread. More...
 

Protected Attributes

EventSignalShouldQuit mSignalShouldQuit
 
std::vector< std::stringmCommandLineArgs
 
Settings mSettings
 
RendererRef mDefaultRenderer
 
bool mPowerManagement
 

Static Protected Attributes

static AppBasicsInstance
 

Member Typedef Documentation

typedef std::shared_ptr<Window> cinder::app::AppBasic::WindowRef

Constructor & Destructor Documentation

cinder::app::AppBasic::AppBasic ( )
cinder::app::AppBasic::~AppBasic ( )
virtual

Member Function Documentation

virtual void cinder::app::AppBasic::prepareSettings ( Settings settings)
virtual
EventSignalShouldQuit& cinder::app::AppBasic::getSignalShouldQuit ( )

This is fired before the app is quit. If any slots return false then the app quitting is canceled.

WindowRef cinder::app::AppBasic::createWindow ( const Window::Format format = Window::Format())

Creates a new Window.

float cinder::app::AppBasic::getFrameRate ( ) const
virtual

Returns the maximum frame-rate the App will attempt to maintain measured in frames-per-second.

Implements cinder::app::App.

void cinder::app::AppBasic::setFrameRate ( float  frameRate)
virtual

Sets the maximum frame-rate the App will attempt to maintain \ a frameRate frames-per-second.

Implements cinder::app::App.

void cinder::app::AppBasic::disableFrameRate ( )
virtual

Disables frameRate limiting.

bool cinder::app::AppBasic::isFrameRateEnabled ( ) const
virtual

Returns whether frameRate limiting is enabled.

void cinder::app::AppBasic::hideCursor ( )

Hides the mouse cursor.

void cinder::app::AppBasic::showCursor ( )

Shows the mouse cursor.

const Settings& cinder::app::AppBasic::getSettings ( ) const
virtual

Implements cinder::app::App.

void cinder::app::AppBasic::quit ( )
virtual

Ceases execution of the application.

Implements cinder::app::App.

const std::vector<std::string>& cinder::app::AppBasic::getArgs ( ) const

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

fs::path cinder::app::AppBasic::getAppPath ( ) const
virtual

Returns the path to the application on disk.

Implements cinder::app::App.

WindowRef cinder::app::AppBasic::getWindow ( ) const
virtual

Gets the currently active Window.

Implements cinder::app::App.

size_t cinder::app::AppBasic::getNumWindows ( ) const
virtual

Returns the number of Windows the app has open.

Implements cinder::app::App.

WindowRef cinder::app::AppBasic::getWindowIndex ( size_t  index) const
virtual

Gets a Window by index, in the range [0, getNumWindows()).

Implements cinder::app::App.

WindowRef cinder::app::AppBasic::getForegroundWindow ( ) const
virtual

Gets the foreground Window, which has keyboard and mouse focus.

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

Returns a pointer to the current global AppBasic.

virtual void cinder::app::App::setup ( )
virtualinherited

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

virtual void cinder::app::App::shutdown ( )
virtualinherited

Override to perform any application cleanup before exiting.

virtual void cinder::app::App::update ( )
virtualinherited

Override to perform any once-per-loop computation.

virtual void cinder::app::App::draw ( )
virtualinherited

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)
virtualinherited

Override to receive mouse-down events.

virtual void cinder::app::App::mouseUp ( MouseEvent  event)
virtualinherited

Override to receive mouse-up events.

virtual void cinder::app::App::mouseWheel ( MouseEvent  event)
virtualinherited

Override to receive mouse-wheel events.

virtual void cinder::app::App::mouseMove ( MouseEvent  event)
virtualinherited

Override to receive mouse-move events.

virtual void cinder::app::App::mouseDrag ( MouseEvent  event)
virtualinherited

Override to receive mouse-drag events.

virtual void cinder::app::App::touchesBegan ( TouchEvent  event)
virtualinherited

Override to respond to the beginning of a multitouch sequence.

virtual void cinder::app::App::touchesMoved ( TouchEvent  event)
virtualinherited

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

virtual void cinder::app::App::touchesEnded ( TouchEvent  event)
virtualinherited

Override to respond to the end of a multitouch sequence.

virtual void cinder::app::App::keyDown ( KeyEvent  event)
virtualinherited

Override to receive key-down events.

virtual void cinder::app::App::keyUp ( KeyEvent  event)
virtualinherited

Override to receive key-up events.

virtual void cinder::app::App::resize ( )
virtualinherited

Override to receive window resize events.

virtual void cinder::app::App::fileDrop ( FileDropEvent  event)
virtualinherited

Override to receive file-drop events.

signals::signal<void()>& cinder::app::App::getSignalUpdate ( )
inherited

Emitted at the start of each application update cycle.

signals::signal<void()>& cinder::app::App::getSignalShutdown ( )
inherited

Emitted prior to the application shutting down.

void cinder::app::App::emitShutdown ( )
inherited
signals::signal<void()>& cinder::app::App::getSignalWillResignActive ( )
inherited
void cinder::app::App::emitWillResignActive ( )
inherited
signals::signal<void()>& cinder::app::App::getSignalDidBecomeActive ( )
inherited
void cinder::app::App::emitDidBecomeActive ( )
inherited
const std::vector<TouchEvent::Touch>& cinder::app::App::getActiveTouches ( ) const
inherited
RendererRef cinder::app::App::getRenderer ( ) const
inherited

Returns the Renderer of the active Window.

DisplayRef cinder::app::App::getDisplay ( ) const
inherited

Returns the Display of the active Window.

virtual void cinder::app::App::enablePowerManagement ( bool  powerManagement = true)
virtualinherited

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.

virtual bool cinder::app::App::isPowerManagementEnabled ( ) const
virtualinherited

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

int cinder::app::App::getWindowWidth ( ) const
inherited

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

int cinder::app::App::getWindowHeight ( ) const
inherited

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

void cinder::app::App::setWindowSize ( int  windowWidth,
int  windowHeight 
)
inherited

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

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

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

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

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

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

Vec2i cinder::app::App::getWindowSize ( ) const
inherited

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

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

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

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

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

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

float cinder::app::App::getWindowContentScale ( ) const
inherited

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

Vec2i cinder::app::App::getWindowPos ( ) const
inherited

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

int cinder::app::App::getWindowPosX ( ) const
inherited

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

int cinder::app::App::getWindowPosY ( ) const
inherited

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

void cinder::app::App::setWindowPos ( int  x,
int  y 
)
inherited

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

virtual void cinder::app::App::setWindowPos ( const Vec2i windowPos)
virtualinherited

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

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

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

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

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

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

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

bool cinder::app::App::isFullScreen ( ) const
inherited

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

void cinder::app::App::setFullScreen ( bool  aFullScreen,
const FullScreenOptions options = FullScreenOptions() 
)
inherited

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

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

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

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

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

Vec2i cinder::app::App::getMousePos ( )
staticinherited

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

DataSourceRef cinder::app::App::loadResource ( const std::string macPath,
int  mswID,
const std::string mswType 
)
staticinherited

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
Assets & Resources in Cinder
DataSourceRef cinder::app::App::loadAsset ( const fs::path &  relativePath)
inherited

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

fs::path cinder::app::App::getAssetPath ( const fs::path &  relativePath)
inherited

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

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

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

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

Presents the user with a folder-open dialog and returns the selected folder path in the spcified callback.

The dialog optionally begins at the path initialPath and can be limited to allow selection of files ending in the extensions enumerated in extensions. On WinRT, at least one extension must be specified in extensions or an exception will occur. If the active app is in snapped mode it will be unsnapped to present the dialog.

Returns
void. The selected folder path or an empty string if the user cancelled will be returned in the f callback.
fs::path cinder::app::App::getFolderPath ( const fs::path &  initialPath = "")
inherited

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

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

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 ( )
inherited

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

Timeline& cinder::app::App::timeline ( )
inherited

Returns a reference to the App's Timeline.

bool cinder::app::App::isPrimaryThread ( )
staticinherited

Return true if the calling thread is the Application's primary thread.

boost::asio::io_service& cinder::app::App::io_service ( )
inherited

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

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

defined( CINDER_WINRT )

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::App::dispatchSync ( fn)
inherited
RendererRef cinder::app::App::getDefaultRenderer ( ) const
inherited

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

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

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.

RendererRef cinder::app::App::findSharedRenderer ( RendererRef  searchRenderer) const
inherited

Finds any Renderer of the same type as searchRenderer among existing windows. This is generally not necessary and used to enable context sharing between Windows. Returns NULL on failure.

virtual bool cinder::app::App::receivesEvents ( ) const
virtualinherited

Reimplemented in cinder::app::AppScreenSaver.

Member Data Documentation

AppBasic * cinder::app::AppBasic::sInstance
staticprotected
EventSignalShouldQuit cinder::app::AppBasic::mSignalShouldQuit
protected
std::vector<std::string> cinder::app::AppBasic::mCommandLineArgs
protected
Settings cinder::app::AppBasic::mSettings
protected
RendererRef cinder::app::App::mDefaultRenderer
protectedinherited
bool cinder::app::App::mPowerManagement
protectedinherited

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