Permalink
Browse files

Moving multiTouch-enabled to an App::Setting rather than derived clas…

…s' Settings
  • Loading branch information...
1 parent a11f70f commit 2e33d66bfa80c7af7b602edcd382dd4b3e40c9aa @andrewfb andrewfb committed Apr 18, 2013
View
@@ -179,6 +179,11 @@ class App {
//! Sets the Window::Format which will be used if no calls are made to Settings::prepareWindow()
void setDefaultWindowFormat( const Window::Format &format ) { mDefaultWindowFormat = format; }
+ //! Registers the app to receive multiTouch events from the operating system. Disabled by default on desktop platforms, enabled on mobile.
+ void enableMultiTouch( bool enable = true ) { mEnableMultiTouch = enable; }
+ //! Returns whether the app is registered to receive multiTouch events from the operating system. Disabled by default on desktop platforms, enabled on mobile.
+ bool isMultiTouchEnabled() const { return mEnableMultiTouch; }
+
//! a value of \c true allows screensavers or the system's power management to hide the app. Default value is \c false on desktop, and \c true on mobile
void enablePowerManagement( bool aPowerManagement = true );
//! is power management enabled, allowing screensavers and the system's power management to hide the application
@@ -213,6 +218,7 @@ class App {
float mFrameRate;
bool mPowerManagement; // allow screensavers or power management to hide app. default: false
bool mEnableHighDensityDisplay;
+ bool mEnableMultiTouch;
std::string mTitle;
friend class App;
@@ -79,18 +79,12 @@ class AppBasic : public App {
bool isConsoleWindowEnabled() const { return mEnableMswConsole; }
#endif
- //! Registers the app to receive multiTouch events from the operating system. Disabled by default on desktop platforms, enabled on mobile.
- void enableMultiTouch( bool enable = true ) { mEnableMultiTouch = enable; }
- //! Returns whether the app is registered to receive multiTouch events from the operating system. Disabled by default on desktop platforms, enabled on mobile.
- bool isMultiTouchEnabled() const { return mEnableMultiTouch; }
-
//! Sets whether the app quits automatically when its last window is closed. Enabled by default.
void enableQuitOnLastWindowClose( bool enable = true ) { mQuitOnLastWindowClose = enable; }
//! Returns whether the app quits automatically when its last window is closed. Enabled by default.
bool isQuitOnLastWindowCloseEnabled() const { return mQuitOnLastWindowClose; }
private:
- bool mEnableMultiTouch;
bool mQuitOnLastWindowClose;
#if defined( CINDER_MSW )
bool mEnableMswConsole;
@@ -56,23 +56,18 @@ class AppCocoaTouch : public App {
class Settings : public App::Settings {
public:
Settings()
- : App::Settings(), mEnableMultiTouch( true ), mEnableStatusBar( false )
+ : App::Settings(), mEnableStatusBar( false )
{
mPowerManagement = false;
}
- //! Registers the app to receive multiTouch events from the operating system. Enabled by default. If disabled, touch events are mapped to mouse events.
- void enableMultiTouch( bool enable = true ) { mEnableMultiTouch = enable; }
- //! Returns whether the app is registered to receive multiTouch events from the operating system. Enabled by default. If disabled, touch events are mapped to mouse events.
- bool isMultiTouchEnabled() const { return mEnableMultiTouch; }
-
//! Determines whether the system status bar is visible initially. Default is \c false.
void enableStatusBar( bool enable = true ) { mEnableStatusBar = enable; }
//! Returns whether the system status bar is visible initially. Default is \c false.
bool isStatusBarEnabled() const { return mEnableStatusBar; }
private:
- bool mEnableMultiTouch, mEnableStatusBar;
+ bool mEnableStatusBar;
};
AppCocoaTouch();
@@ -41,13 +41,7 @@ class AppCocoaView : public App {
public:
Settings();
- //! Registers the app to receive multiTouch events from the operating system. Disabled by default on desktop platforms, enabled on mobile.
- void enableMultiTouch( bool enable = true ) { mEnableMultiTouch = enable; }
- //! Returns whether the app is registered to receive multiTouch events from the operating system. Disabled by default on desktop platforms, enabled on mobile.
- bool isMultiTouchEnabled() const { return mEnableMultiTouch; }
-
private:
- bool mEnableMultiTouch;
};
AppCocoaView();
@@ -128,7 +128,6 @@
- (void)mouseWheel:(cinder::app::MouseEvent*)event;
- (void)keyDown:(cinder::app::KeyEvent*)event;
- (void)keyUp:(cinder::app::KeyEvent*)event;
-- (BOOL)wantsMultiTouch;
- (void)touchesBegan:(cinder::app::TouchEvent*)event;
- (void)touchesMoved:(cinder::app::TouchEvent*)event;
- (void)touchesEnded:(cinder::app::TouchEvent*)event;
@@ -44,7 +44,6 @@
- (void)mouseWheel:(cinder::app::MouseEvent*)event;
- (void)keyDown:(cinder::app::KeyEvent*)event;
- (void)keyUp:(cinder::app::KeyEvent*)event;
-- (BOOL)wantsMultiTouch;
- (void)touchesBegan:(cinder::app::TouchEvent*)event;
- (void)touchesMoved:(cinder::app::TouchEvent*)event;
- (void)touchesEnded:(cinder::app::TouchEvent*)event;
View
@@ -63,8 +63,10 @@ App::Settings::Settings()
mFrameRate = 60.0f;
#if defined( CINDER_COCOA_TOUCH )
mEnableHighDensityDisplay = true;
+ mEnableMultiTouch = true;
#else
mEnableHighDensityDisplay = false;
+ mEnableMultiTouch = false;
#endif
}
@@ -257,8 +257,7 @@ bool AppBasic::privateShouldQuit()
//////////////////////////////////////////////////////////////////////////////////////////////
// AppBasic::Settings
AppBasic::Settings::Settings()
- : App::Settings(),
- mEnableMultiTouch( false ), mQuitOnLastWindowClose( true )
+ : App::Settings(), mQuitOnLastWindowClose( true )
{
#if defined( CINDER_MSW )
mEnableMswConsole = false;
@@ -156,11 +156,6 @@ - (void)keyDown:(cinder::app::KeyEvent*)event
mWindowRef->emitKeyDown( event );
}
-- (BOOL)wantsMultiTouch
-{
- return mAppImpl->mApp->getSettings().isMultiTouchEnabled();
-}
-
- (void)keyUp:(cinder::app::KeyEvent*)event
{
[mAppImpl setActiveWindow:self];
@@ -512,7 +507,7 @@ - (bool)isFrameRateEnabled
}
AppCocoaView::Settings::Settings()
- : App::Settings(), mEnableMultiTouch( false )
+ : App::Settings()
{
}
@@ -634,11 +634,6 @@ - (void)keyUp:(cinder::app::KeyEvent*)event
mWindowRef->emitKeyUp( event );
}
-- (BOOL)wantsMultiTouch
-{
- return mAppImpl->mApp->getSettings().isMultiTouchEnabled();
-}
-
- (void)touchesBegan:(cinder::app::TouchEvent*)event
{
[mAppImpl setActiveWindow:self];
@@ -88,7 +88,7 @@ - (void)setupRendererWithFrame:(NSRect)frame renderer:(cinder::app::RendererRef)
[self registerForDraggedTypes:[NSArray arrayWithObject:NSFilenamesPboardType]];
// register for touch events
- if( mDelegate && [mDelegate wantsMultiTouch] ) {
+ if( mDelegate && mApp->getSettings().isMultiTouchEnabled() ) {
[self setAcceptsTouchEvents:YES];
[self setWantsRestingTouches:YES];
if( ! mTouchIdMap )
@@ -491,7 +491,7 @@ - (void)applicationWillResignActive:(NSNotification *)aNotification
- (void)setDelegate:(id<CinderViewDelegate>)delegate
{
mDelegate = delegate;
- if( delegate && [delegate wantsMultiTouch] ) {
+ if( delegate && mApp->getSettings().isMultiTouchEnabled() ) {
[self setAcceptsTouchEvents:YES];
if( ! mTouchIdMap )
mTouchIdMap = [[NSMutableDictionary alloc] initWithCapacity:10];
@@ -11,7 +11,7 @@ using namespace ci::app;
void MyCinderApp::prepareSettings( Settings *settings )
{
testCbo.setState( TestCallbackOrder::PREPARESETTINGS );
- settings->enableMultiTouch( true );
+ settings->enableMultiTouch( false );
}
void MyCinderApp::setup()

0 comments on commit 2e33d66

Please sign in to comment.