[dasher] Add tapping facility to StylusFilter (i.e. it can be used like click mode too).



commit 21eddce9e883b7a5dfbc8e01f9060a2021cf6286
Author: Alan Lawrence <acl33 inf phy cam ac uk>
Date:   Tue Aug 11 19:20:01 2009 +0200

    Add tapping facility to StylusFilter (i.e. it can be used like click mode too).

 ChangeLog                       |    1 +
 Src/DasherCore/Parameters.h     |    4 +++-
 Src/DasherCore/StylusFilter.cpp |   24 ++++++++++++++++++++++--
 Src/DasherCore/StylusFilter.h   |    3 +++
 4 files changed, 29 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 08c306b..0c0b276 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 2009-08-11  Alan Lawrence <acl33 inf phy cam ac uk>
 
 	* Split DasherButtons into one class per style; add option for scanning menu
+	* Add tapping facility to StylusFilter.
 
 2009-08-10  Alan Lawrence <acl33 inf phy cam ac uk>
 
diff --git a/Src/DasherCore/Parameters.h b/Src/DasherCore/Parameters.h
index 12a0c30..e5c2ba8 100644
--- a/Src/DasherCore/Parameters.h
+++ b/Src/DasherCore/Parameters.h
@@ -64,7 +64,8 @@ enum {
   LP_TWO_PUSH_OUTER, LP_TWO_PUSH_UP, LP_TWO_PUSH_DOWN, LP_TWO_PUSH_TOLERANCE,
   LP_DYNAMIC_BUTTON_LAG, LP_STATIC1B_TIME, LP_STATIC1B_ZOOM,
   LP_DEMO_SPRING, LP_DEMO_NOISE_MEM, LP_DEMO_NOISE_MAG, LP_MAXZOOM, 
-  LP_DYNAMIC_SPEED_INC, LP_DYNAMIC_SPEED_FREQ, LP_DYNAMIC_SPEED_DEC, END_OF_LPS
+  LP_DYNAMIC_SPEED_INC, LP_DYNAMIC_SPEED_FREQ, LP_DYNAMIC_SPEED_DEC,
+  LP_TAP_TIME, END_OF_LPS
 };
 
 enum {
@@ -231,6 +232,7 @@ static lp_table longparamtable[] = {
   {LP_DYNAMIC_SPEED_INC, "DynamicSpeedInc", PERS, 3, "%age by which dynamic mode auto speed control increases speed"},
   {LP_DYNAMIC_SPEED_FREQ, "DynamicSpeedFreq", PERS, 10, "Seconds after which dynamic mode auto speed control increases speed"},
   {LP_DYNAMIC_SPEED_DEC, "DynamicSpeedDec", PERS, 8, "%age by which dynamic mode auto speed control decreases speed on reverse"},
+  {LP_TAP_TIME, "TapTime", PERS, 200, "Max length of a stylus 'tap' rather than hold (ms)"},
 };
 
 static sp_table stringparamtable[] = {
diff --git a/Src/DasherCore/StylusFilter.cpp b/Src/DasherCore/StylusFilter.cpp
index 391caef..272a593 100644
--- a/Src/DasherCore/StylusFilter.cpp
+++ b/Src/DasherCore/StylusFilter.cpp
@@ -9,13 +9,33 @@ CStylusFilter::CStylusFilter(Dasher::CEventHandler *pEventHandler, CSettingsStor
   : CDefaultFilter(pEventHandler, pSettingsStore, pInterface, iID, szName) {
 }
 
+bool CStylusFilter::Timer(int iTime, CDasherView *pView, CDasherModel *pModel, Dasher::VECTOR_SYMBOL_PROB *pAdded, int *pNumDeleted)
+{
+  if (GetBoolParameter(BP_DASHER_PAUSED))
+  {
+    //continue any zoom scheduled by a previous click...
+    return pModel->NextScheduledStep(iTime, pAdded, pNumDeleted);
+    //note that this skips the rest of CDefaultFilter::Timer;
+    //however, given we're paused, this is only the Start Handler,
+    //which we're not using anyway.
+  }
+  return CDefaultFilter::Timer(iTime, pView, pModel, pAdded, pNumDeleted);
+}
 
 void CStylusFilter::KeyDown(int iTime, int iId, CDasherView *pView, CDasherModel *pModel, CUserLogBase *pUserLog) {
-  if(iId == 100)
+  if(iId == 100) {
     m_pInterface->Unpause(iTime);
+    m_iKeyDownTime = iTime;
+  }
 }
 
 void CStylusFilter::KeyUp(int iTime, int iId, CDasherView *pView, CDasherModel *pModel) {
-  if(iId == 100)
+  if(iId == 100) {
     m_pInterface->PauseAt(0, 0);
+    if (iTime - m_iKeyDownTime < GetLongParameter(LP_TAP_TIME)) {
+      myint iDasherX, iDasherY;
+      pView->GetCoordinates(iDasherX, iDasherY);
+      pModel->ScheduleZoom(iDasherX, iDasherY, GetLongParameter(LP_MAXZOOM));
+    }
+  }
 }
diff --git a/Src/DasherCore/StylusFilter.h b/Src/DasherCore/StylusFilter.h
index cb9392d..adc9e0a 100644
--- a/Src/DasherCore/StylusFilter.h
+++ b/Src/DasherCore/StylusFilter.h
@@ -10,8 +10,11 @@ class CStylusFilter : public CDefaultFilter {
  public:
   CStylusFilter(Dasher::CEventHandler * pEventHandler, CSettingsStore *pSettingsStore, CDasherInterfaceBase *pInterface, ModuleID_t iID, const char *szName);
 
+  virtual bool Timer(int Time, CDasherView *pView, CDasherModel *pModel, Dasher::VECTOR_SYMBOL_PROB *pAdded, int *pNumDeleted);
   virtual void KeyDown(int iTime, int iId, CDasherView *pView, CDasherModel *pModel, CUserLogBase *pUserLog);
   virtual void KeyUp(int iTime, int iId, CDasherView *pView, CDasherModel *pModel);
+ private:
+  int m_iKeyDownTime;
 };
 }
 /// @}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]