[dasher] Clear BP_DASHER_PAUSED while a ScheduledZoom is in progress



commit 13563f987132a61ff53ae36c80054ce32e2e6be8
Author: Alan Lawrence <acl33 inf phy cam ac uk>
Date:   Tue Feb 2 23:14:51 2010 +0000

    Clear BP_DASHER_PAUSED while a ScheduledZoom is in progress
    
    i.e. always indicates when display is moving.
    Also fixed OneButtonFilter decorations.
    ScheduleZoom Unpause()s; NextScheduledStep sets BP_DASHER_PAUSED after last step
      (So as not to trigger StopEvents - like Control Mode "pause" not "halt")
    Extra 'long Time' param added to ScheduleZoom.
    PauseAt(x,y) renamed to Pause(), removing unused x/y params, inc for MacOSX;
    CDasherModel and CFrameRate::NewFrame renamed to RecordFrame;
    Pause()&unpause() do nothing if BP_DASHER_PAUSED already has appropriate value.
    Fixed "pause outside canvas", no longer prevents all movement when enabled.

 Src/DasherCore/AlternatingDirectMode.cpp |   10 +++++-----
 Src/DasherCore/CircleStartHandler.cpp    |    2 +-
 Src/DasherCore/ClickFilter.cpp           |    2 +-
 Src/DasherCore/DasherButtons.cpp         |    4 ++--
 Src/DasherCore/DasherGameMode.cpp        |   10 +++++-----
 Src/DasherCore/DasherInterfaceBase.cpp   |   14 ++++++++++----
 Src/DasherCore/DasherInterfaceBase.h     |   13 ++++++-------
 Src/DasherCore/DasherModel.cpp           |   18 ++++++++++++------
 Src/DasherCore/DasherModel.h             |    7 ++++---
 Src/DasherCore/DefaultFilter.cpp         |   11 ++++++-----
 Src/DasherCore/DynamicFilter.cpp         |    4 ++--
 Src/DasherCore/FrameRate.cpp             |    2 +-
 Src/DasherCore/FrameRate.h               |    2 +-
 Src/DasherCore/OneButtonFilter.cpp       |   13 +++++++++----
 Src/DasherCore/OneButtonFilter.h         |    4 +++-
 Src/DasherCore/StylusFilter.cpp          |    9 +++++++--
 Src/MacOSX/DasherApp.h                   |    2 +-
 Src/MacOSX/DasherApp.mm                  |    4 ++--
 Src/iPhone/Classes/DasherAppDelegate.mm  |    2 +-
 Src/iPhone/Classes/IPhoneFilters.cpp     |    2 +-
 Src/iPhone/Classes/PlainDragFilter.cpp   |    2 +-
 21 files changed, 81 insertions(+), 56 deletions(-)
---
diff --git a/Src/DasherCore/AlternatingDirectMode.cpp b/Src/DasherCore/AlternatingDirectMode.cpp
index b902265..2ee76d4 100644
--- a/Src/DasherCore/AlternatingDirectMode.cpp
+++ b/Src/DasherCore/AlternatingDirectMode.cpp
@@ -95,21 +95,21 @@ void CAlternatingDirectMode::DirectKeyDown(int iTime, int iId, CDasherView *pVie
   switch(iId) {
   case 2:
     if(m_iLastBox == 1)
-      pModel->ScheduleZoom((m_pBoxes[2].iBottom - m_pBoxes[2].iTop)/2, (m_pBoxes[2].iBottom + m_pBoxes[2].iTop)/2);
+      pModel->ScheduleZoom(iTime, (m_pBoxes[2].iBottom - m_pBoxes[2].iTop)/2, (m_pBoxes[2].iBottom + m_pBoxes[2].iTop)/2);
     else
-      pModel->ScheduleZoom((m_pBoxes[0].iBottom - m_pBoxes[0].iTop)/2, (m_pBoxes[0].iBottom + m_pBoxes[0].iTop)/2);
+      pModel->ScheduleZoom(iTime, (m_pBoxes[0].iBottom - m_pBoxes[0].iTop)/2, (m_pBoxes[0].iBottom + m_pBoxes[0].iTop)/2);
     m_iLastBox = 1;
     break;
   case 3:
   case 4:
     if(m_iLastBox == 2)
-      pModel->ScheduleZoom((m_pBoxes[3].iBottom - m_pBoxes[3].iTop)/2, (m_pBoxes[3].iBottom + m_pBoxes[3].iTop)/2);
+      pModel->ScheduleZoom(iTime, (m_pBoxes[3].iBottom - m_pBoxes[3].iTop)/2, (m_pBoxes[3].iBottom + m_pBoxes[3].iTop)/2);
     else
-      pModel->ScheduleZoom((m_pBoxes[1].iBottom - m_pBoxes[1].iTop)/2, (m_pBoxes[1].iBottom + m_pBoxes[1].iTop)/2);
+      pModel->ScheduleZoom(iTime, (m_pBoxes[1].iBottom - m_pBoxes[1].iTop)/2, (m_pBoxes[1].iBottom + m_pBoxes[1].iTop)/2);
     m_iLastBox = 2;
     break;
   case 1:
-    pModel->ScheduleZoom((m_pBoxes[4].iBottom - m_pBoxes[4].iTop)/2, (m_pBoxes[4].iBottom + m_pBoxes[4].iTop)/2);
+    pModel->ScheduleZoom(iTime, (m_pBoxes[4].iBottom - m_pBoxes[4].iTop)/2, (m_pBoxes[4].iBottom + m_pBoxes[4].iTop)/2);
     break;
   }
 
diff --git a/Src/DasherCore/CircleStartHandler.cpp b/Src/DasherCore/CircleStartHandler.cpp
index 9ac296a..b3d5020 100644
--- a/Src/DasherCore/CircleStartHandler.cpp
+++ b/Src/DasherCore/CircleStartHandler.cpp
@@ -151,7 +151,7 @@ void CCircleStartHandler::Timer(int iTime, CDasherView *m_pDasherView, CDasherMo
   if(iTime - m_iChangeTime > 1000) {
     if(iNewStatus == 4) {
       iNewStatus = 2;
-      m_pInterface->PauseAt(0, 0);
+      m_pInterface->Pause();
     } 
     else if(iNewStatus == 5) {
       iNewStatus = 3;
diff --git a/Src/DasherCore/ClickFilter.cpp b/Src/DasherCore/ClickFilter.cpp
index c7eeb03..f95eec8 100644
--- a/Src/DasherCore/ClickFilter.cpp
+++ b/Src/DasherCore/ClickFilter.cpp
@@ -65,7 +65,7 @@ void CClickFilter::KeyDown(int iTime, int iId, CDasherView *pDasherView, CDasher
 
       pDasherView->GetCoordinates(iDasherX, iDasherY);
 
-      pModel->ScheduleZoom(iDasherX,iDasherY, GetLongParameter(LP_MAXZOOM));
+      pModel->ScheduleZoom(iTime, iDasherX,iDasherY, GetLongParameter(LP_MAXZOOM));
     }
     break;
   default:
diff --git a/Src/DasherCore/DasherButtons.cpp b/Src/DasherCore/DasherButtons.cpp
index c082541..703199f 100644
--- a/Src/DasherCore/DasherButtons.cpp
+++ b/Src/DasherCore/DasherButtons.cpp
@@ -56,7 +56,7 @@ void CDasherButtons::KeyDown(int iTime, int iId, CDasherView *pView, CDasherMode
     case 3:
     case 100:
       m_bDecorationChanged = true;
-      pModel->ScheduleZoom((m_pBoxes[iActiveBox].iBottom - m_pBoxes[iActiveBox].iTop)/2, (m_pBoxes[iActiveBox].iBottom + m_pBoxes[iActiveBox].iTop)/2);
+      pModel->ScheduleZoom(iTime, (m_pBoxes[iActiveBox].iBottom - m_pBoxes[iActiveBox].iTop)/2, (m_pBoxes[iActiveBox].iBottom + m_pBoxes[iActiveBox].iTop)/2);
       if(iActiveBox != m_iNumBoxes-1)
         iActiveBox = 0;
       break;
@@ -78,7 +78,7 @@ void CDasherButtons::DirectKeyDown(int iTime, int iId, CDasherView *pView, CDash
   else
   iActiveBox = m_iNumBoxes-2;
 
-  pModel->ScheduleZoom((m_pBoxes[iActiveBox].iBottom - m_pBoxes[iActiveBox].iTop)/2, (m_pBoxes[iActiveBox].iBottom + m_pBoxes[iActiveBox].iTop)/2);
+  pModel->ScheduleZoom(iTime, (m_pBoxes[iActiveBox].iBottom - m_pBoxes[iActiveBox].iTop)/2, (m_pBoxes[iActiveBox].iBottom + m_pBoxes[iActiveBox].iTop)/2);
 }
 
 bool CDasherButtons::Timer(int Time, CDasherView *m_pDasherView, CDasherModel *m_pDasherModel, Dasher::VECTOR_SYMBOL_PROB *pAdded, int *pNumDeleted, CExpansionPolicy **pol) {
diff --git a/Src/DasherCore/DasherGameMode.cpp b/Src/DasherCore/DasherGameMode.cpp
index 0c08842..53b3847 100644
--- a/Src/DasherCore/DasherGameMode.cpp
+++ b/Src/DasherCore/DasherGameMode.cpp
@@ -134,7 +134,7 @@ void CDasherGameMode::NotifyGameCooperators(bool bGameOn)
   m_pView->SetGameMode(bGameOn);
   m_pDasherInterface->SetContext(std::string(""));
   m_pDasherInterface->SetBuffer(0);
-  m_pDasherInterface->PauseAt(0,0);
+  m_pDasherInterface->Pause();
 
 }
 
@@ -184,7 +184,7 @@ void CDasherGameMode::DemoModeStart(bool bFullDemo)
 void CDasherGameMode::DemoModeStop()
 {
   // Close down external first...
-  m_pDasherInterface->PauseAt(0,0);
+  m_pDasherInterface->Pause();
   m_pView->SetDemoMode(false);
 
   // ... then internal.
@@ -298,7 +298,7 @@ void CDasherGameMode::GameNext()
   m_pDasherInterface->GameMessageOut(GAME_MESSAGE_CLEAR_BUFFER, NULL);
   m_pDasherInterface->SetContext(std::string(""));
   m_pDasherInterface->SetBuffer(0);
-  m_pDasherInterface->PauseAt(0,0);
+  m_pDasherInterface->Pause();
  
   RunningScoreUpdates();
 }
@@ -336,7 +336,7 @@ void CDasherGameMode::FullDemoNext()
   m_pDasherInterface->GameMessageOut(GAME_MESSAGE_CLEAR_BUFFER, NULL);
   m_pDasherInterface->SetContext(std::string(""));
   m_pDasherInterface->SetBuffer(0);
-  m_pDasherInterface->PauseAt(0,0);
+  m_pDasherInterface->Pause();
 
   // We start in 3 seconds.
   Callback(&CDasherGameMode::DemoGo,3000);
@@ -654,7 +654,7 @@ void CDasherGameMode::PrivateSentenceFinished()
   m_bDrawHelperArrow=false;
   m_bDrawTargetArrow=false;
   m_bSentenceFinished=true;
-  m_pDasherInterface->PauseAt(0,0);
+  m_pDasherInterface->Pause();
   if(!m_pDemo) {
     string msg = m_pLevel->m_strPerformance.str();
     m_pDasherInterface->GameMessageOut(GAME_MESSAGE_HELP_MESSAGE, &msg);
diff --git a/Src/DasherCore/DasherInterfaceBase.cpp b/Src/DasherCore/DasherInterfaceBase.cpp
index 6bedc92..eeb7dfb 100644
--- a/Src/DasherCore/DasherInterfaceBase.cpp
+++ b/Src/DasherCore/DasherInterfaceBase.cpp
@@ -358,7 +358,7 @@ void CDasherInterfaceBase::InterfaceEventHandler(Dasher::CEvent *pEvent) {
 
     switch(pControlEvent->m_iID) {
     case CControlManager::CTL_STOP:
-      PauseAt(0,0);
+      Pause();
       break;
     case CControlManager::CTL_PAUSE:
   //Halt Dasher - without a stop event, so does not result in speech etc.
@@ -435,7 +435,8 @@ void CDasherInterfaceBase::CreateNCManager() {
     CreateModel(iOffset);
 }
 
-void CDasherInterfaceBase::PauseAt(int MouseX, int MouseY) {
+void CDasherInterfaceBase::Pause() {
+  if (GetBoolParameter(BP_DASHER_PAUSED)) return; //already paused, no need to do anything.
   SetBoolParameter(BP_DASHER_PAUSED, true);
 
   // Request a full redraw at the next time step.
@@ -455,6 +456,7 @@ void CDasherInterfaceBase::GameMessageIn(int message, void* messagedata) {
 }
 
 void CDasherInterfaceBase::Unpause(unsigned long Time) {
+  if (!GetBoolParameter(BP_DASHER_PAUSED)) return; //already running, no need to do anything
   SetBoolParameter(BP_DASHER_PAUSED, false);
 
   if(m_pDasherModel != 0)
@@ -507,7 +509,7 @@ void CDasherInterfaceBase::NewFrame(unsigned long iTime, bool bForceRedraw) {
   // if(m_iCurrentState != ST_NORMAL)
   //  return;
 
-  bool bChanged(false);
+  bool bChanged(false), bWasPaused(GetBoolParameter(BP_DASHER_PAUSED));
   CExpansionPolicy *pol=m_defaultPolicy;
   if(m_pDasherView != 0) {
     if(!GetBoolParameter(BP_TRAINING)) {
@@ -540,6 +542,10 @@ void CDasherInterfaceBase::NewFrame(unsigned long iTime, bool bForceRedraw) {
     }
   }
 
+  //check: if we were paused before, and the input filter didn't unpause,
+  // then nothing can have changed:
+  DASHER_ASSERT(!bWasPaused || !GetBoolParameter(BP_DASHER_PAUSED) || !bChanged);
+                
   // Flags at this stage:
   //
   // - bChanged = the display was updated, so needs to be rendered to the display
@@ -563,7 +569,7 @@ void CDasherInterfaceBase::NewFrame(unsigned long iTime, bool bForceRedraw) {
   // This just passes the time through to the framerate tracker, so we
   // know how often new frames are being drawn.
   if(m_pDasherModel != 0)
-    m_pDasherModel->NewFrame(iTime);
+    m_pDasherModel->RecordFrame(iTime);
 
   bReentered=false;
 }
diff --git a/Src/DasherCore/DasherInterfaceBase.h b/Src/DasherCore/DasherInterfaceBase.h
index 7446d24..0443d6e 100644
--- a/Src/DasherCore/DasherInterfaceBase.h
+++ b/Src/DasherCore/DasherInterfaceBase.h
@@ -220,14 +220,13 @@ public:
 
   //  void Start();
 
-  /// Pause Dasher
-  /// \todo Parameters are ignored (?) - remove from definition.
+  /// Pause Dasher. Sets BP_DASHER_PAUSED and broadcasts a StopEvent.
+  /// (But does nothing if BP_DASHER_PAUSED is not set)
+  void Pause(); // are required to make
 
-  void PauseAt(int MouseX, int MouseY); // are required to make
-
-  /// Unpause Dasher
+  /// Unpause Dasher. Clears BP_DASHER_PAUSED, broadcasts a StartEvent.
+  /// (But does nothing if BP_DASHER_PAUSED is currently set).
   /// \param Time Time in ms, used to keep a constant frame rate
-
   void Unpause(unsigned long Time);     // Dasher run at the
 
   /// @}
@@ -341,7 +340,7 @@ public:
 
   void AddGameModeString(const std::string &strText) {
     m_deGameModeStrings.push_back(strText);
-    PauseAt(0,0);
+    Pause();
     //    CreateDasherModel();
     CreateNCManager();
     //    Start();
diff --git a/Src/DasherCore/DasherModel.cpp b/Src/DasherCore/DasherModel.cpp
index 3ed20bb..956fb7c 100644
--- a/Src/DasherCore/DasherModel.cpp
+++ b/Src/DasherCore/DasherModel.cpp
@@ -408,7 +408,7 @@ void CDasherModel::Get_new_root_coords(dasherint X, dasherint Y, dasherint &r1,
 
 bool CDasherModel::NextScheduledStep(unsigned long iTime, Dasher::VECTOR_SYMBOL_PROB *pAdded, int *pNumDeleted)
 {
-  DASHER_ASSERT(GetBoolParameter(BP_DASHER_PAUSED));
+  DASHER_ASSERT (!GetBoolParameter(BP_DASHER_PAUSED) || m_deGotoQueue.size()==0);
   if (m_deGotoQueue.size() == 0) return false;
   myint iNewMin, iNewMax;
   iNewMin = m_deGotoQueue.front().iN1;
@@ -416,12 +416,12 @@ bool CDasherModel::NextScheduledStep(unsigned long iTime, Dasher::VECTOR_SYMBOL_
   m_deGotoQueue.pop_front();
 
   UpdateBounds(iNewMin, iNewMax, iTime, pAdded, pNumDeleted);
+  if (m_deGotoQueue.size() == 0) m_pDasherInterface->Pause();
   return true;
 }
 
 void CDasherModel::OneStepTowards(myint miMousex, myint miMousey, unsigned long iTime, Dasher::VECTOR_SYMBOL_PROB* pAdded, int* pNumDeleted) {
-  //if (GetBoolParameter(BP_DASHER_PAUSED)) return false;
-  m_deGotoQueue.clear();
+  DASHER_ASSERT(!GetBoolParameter(BP_DASHER_PAUSED));
 
   myint iNewMin, iNewMax;
   // works out next viewpoint
@@ -447,8 +447,8 @@ void CDasherModel::UpdateBounds(myint iNewMin, myint iNewMax, unsigned long iTim
   HandleOutput(pAdded, pNumDeleted);
 }
 
-void CDasherModel::NewFrame(unsigned long Time) {
-  CFrameRate::NewFrame(Time);
+void CDasherModel::RecordFrame(unsigned long Time) {
+  CFrameRate::RecordFrame(Time);
   ///GAME MODE TEMP///Pass new frame events onto our teacher
   GameMode::CDasherGameMode* pTeacher = GameMode::CDasherGameMode::GetTeacher();
   if(m_bGameMode && pTeacher)
@@ -687,7 +687,7 @@ bool CDasherModel::CheckForNewRoot(CDasherView *pView) {
 }
 
 
-void CDasherModel::ScheduleZoom(dasherint X, dasherint Y, int iMaxZoom)
+void CDasherModel::ScheduleZoom(long time, dasherint X, dasherint Y, int iMaxZoom)
 {
   // 1 = min, 2 = max. y1, y2 is the length we select from Y1, Y2. With
   // that ratio we calculate the new root{min,max} r1, r2 from current R1, R2.
@@ -756,6 +756,12 @@ void CDasherModel::ScheduleZoom(dasherint X, dasherint Y, int iMaxZoom)
       sNewItem.iN2 = r2 - (s * (r2 - R2)) / nsteps;
       m_deGotoQueue.push_back(sNewItem);
   }
+  //steps having been scheduled, we're gonna start moving accordingly...
+  m_pDasherInterface->Unpause(time);
+}
+
+void CDasherModel::ClearScheduledSteps() {
+  m_deGotoQueue.clear();
 }
 
 
diff --git a/Src/DasherCore/DasherModel.h b/Src/DasherCore/DasherModel.h
index 9692dbe..b2fda97 100644
--- a/Src/DasherCore/DasherModel.h
+++ b/Src/DasherCore/DasherModel.h
@@ -82,7 +82,7 @@ class Dasher::CDasherModel:public Dasher::CFrameRate, private NoClones
   /// Notify the framerate class that a new frame has occurred
   /// Called from CDasherInterfaceBase::NewFrame
   ///
-  void NewFrame(unsigned long Time);
+  void RecordFrame(unsigned long Time);
 
   ///
   /// Apply an offset to the 'target' coordinates - implements the jumps in
@@ -139,9 +139,10 @@ class Dasher::CDasherModel:public Dasher::CFrameRate, private NoClones
   /// Schedule zoom to a given Dasher coordinate (used in click mode,
   /// button mode etc.)
   ///
+  void ScheduleZoom(long time, dasherint iDasherX, dasherint iDasherY, int iMaxZoom = 0);
 
-  void ScheduleZoom(dasherint iDasherX, dasherint iDasherY, int iMaxZoom = 0);
-
+  void ClearScheduledSteps();
+  
   ///
   /// Update the bounds of the root node for the next step in any
   /// still-in-progress zoom scheduled by ScheduleZoom (does nothing
diff --git a/Src/DasherCore/DefaultFilter.cpp b/Src/DasherCore/DefaultFilter.cpp
index b5fdffe..8b767cc 100644
--- a/Src/DasherCore/DefaultFilter.cpp
+++ b/Src/DasherCore/DefaultFilter.cpp
@@ -61,9 +61,10 @@ bool CDefaultFilter::Timer(int Time, CDasherView *m_pDasherView, CDasherModel *m
       myint iDasherMaxY;
       m_pDasherView->VisibleRegion(iDasherMinX, iDasherMinY, iDasherMaxX, iDasherMaxY);
   
-      if((iDasherX > iDasherMaxX) || (iDasherX < iDasherMinX) || (iDasherY > iDasherMaxY) || (iDasherY < iDasherMinY))
-        m_pInterface->PauseAt(0,0);
-		return false;
+      if((iDasherX > iDasherMaxX) || (iDasherX < iDasherMinX) || (iDasherY > iDasherMaxY) || (iDasherY < iDasherMinY)) {
+        m_pInterface->Pause();
+        return false;
+      }
     }
 
     m_pDasherModel->OneStepTowards(iDasherX,iDasherY, Time, pAdded, pNumDeleted);
@@ -87,7 +88,7 @@ void CDefaultFilter::KeyDown(int iTime, int iId, CDasherView *pDasherView, CDash
       if(GetBoolParameter(BP_DASHER_PAUSED))
 	m_pInterface->Unpause(iTime);
       else
-	m_pInterface->PauseAt(0, 0);
+	m_pInterface->Pause();
     }
     break; 
   case 100: // Start on mouse
@@ -95,7 +96,7 @@ void CDefaultFilter::KeyDown(int iTime, int iId, CDasherView *pDasherView, CDash
       if(GetBoolParameter(BP_DASHER_PAUSED))
 	m_pInterface->Unpause(iTime);
       else
-	m_pInterface->PauseAt(0, 0);
+	m_pInterface->Pause();
     }
     break;
   default:
diff --git a/Src/DasherCore/DynamicFilter.cpp b/Src/DasherCore/DynamicFilter.cpp
index 453745c..e4ddabc 100644
--- a/Src/DasherCore/DynamicFilter.cpp
+++ b/Src/DasherCore/DynamicFilter.cpp
@@ -105,7 +105,7 @@ void CDynamicFilter::Event(int iTime, int iButton, int iType, CDasherModel *pMod
       pUserLog->KeyDown(iButton, iType, 2);
     
     pause();
-    m_pInterface->PauseAt(0, 0);
+    m_pInterface->Pause();
   } else {
     //running; examine event/button-press type
     switch(iType) {
@@ -115,7 +115,7 @@ void CDynamicFilter::Event(int iTime, int iButton, int iType, CDasherModel *pMod
         if(pUserLog)
           pUserLog->KeyDown(iButton, iType, 2);
         pause();
-        m_pInterface->PauseAt(0, 0);
+        m_pInterface->Pause();
         break;
       }
       else if(iButton == 1) {
diff --git a/Src/DasherCore/FrameRate.cpp b/Src/DasherCore/FrameRate.cpp
index 86696a6..742b9af 100644
--- a/Src/DasherCore/FrameRate.cpp
+++ b/Src/DasherCore/FrameRate.cpp
@@ -18,7 +18,7 @@ CFrameRate::CFrameRate(CEventHandler *pEventHandler, CSettingsStore *pSettingsSt
   m_dMaxbitrate = GetLongParameter(LP_MAX_BITRATE) * GetLongParameter(LP_BOOSTFACTOR) / 10000.0;
 }
 
-void CFrameRate::NewFrame(unsigned long Time)
+void CFrameRate::RecordFrame(unsigned long Time)
 {
   m_iFrames++;
 
diff --git a/Src/DasherCore/FrameRate.h b/Src/DasherCore/FrameRate.h
index 6438a7b..11cd288 100644
--- a/Src/DasherCore/FrameRate.h
+++ b/Src/DasherCore/FrameRate.h
@@ -70,7 +70,7 @@ public:
   }
 
 
-  void NewFrame(unsigned long Time);
+  void RecordFrame(unsigned long Time);
   
 private:
   double m_dFr;                 // current frame rate (cache of LP_FRAMERATE/100.0)
diff --git a/Src/DasherCore/OneButtonFilter.cpp b/Src/DasherCore/OneButtonFilter.cpp
index a4f93cf..4eb72bb 100644
--- a/Src/DasherCore/OneButtonFilter.cpp
+++ b/Src/DasherCore/OneButtonFilter.cpp
@@ -29,7 +29,11 @@ bool COneButtonFilter::DecorateView(CDasherView *pView) {
   CDasherScreen *pScreen(pView->Screen());
 
   if (iLocation == 0) {
-    if (!bStarted) return false;
+    if (!bStarted) {
+      if (m_bNoDecorations) return false;
+      m_bNoDecorations = true;
+      return true;
+    }
     //reverse!
     CDasherScreen::point p[4];
     pView->Dasher2Screen(2048, 0, p[0].x, p[0].y);
@@ -44,6 +48,7 @@ bool COneButtonFilter::DecorateView(CDasherView *pView) {
     pView->Dasher2Screen(-1000, iLocation, p[1].x, p[1].y);
     pScreen->Polyline(p, 2, 1, 1);
   }
+  m_bNoDecorations = false;
   return true;
 }
 
@@ -69,11 +74,11 @@ void COneButtonFilter::KeyDown(int iTime, int iId, CDasherView *pView, CDasherMo
   if (bStarted) {
     if (iLocation == 0) {
       //back up by one zoom step.
-      pModel->ScheduleZoom(GetLongParameter(LP_STATIC1B_ZOOM) * 2048, 2048, 0);
+      pModel->ScheduleZoom(iTime, GetLongParameter(LP_STATIC1B_ZOOM) * 2048, 2048, 0);
     } else {
       iLocation -= (GetLongParameter(LP_DYNAMIC_BUTTON_LAG)*4096) / GetLongParameter(LP_STATIC1B_TIME);
-      if (iLocation < 0) iLocation +=4096;
-      pModel->ScheduleZoom(2048/GetLongParameter(LP_STATIC1B_ZOOM), iLocation, 0);
+      if (iLocation>4096) iLocation =8192-iLocation;
+      pModel->ScheduleZoom(iTime, 2048/GetLongParameter(LP_STATIC1B_ZOOM), iLocation, 0);
     }
     bStarted = false;
   } else {
diff --git a/Src/DasherCore/OneButtonFilter.h b/Src/DasherCore/OneButtonFilter.h
index 3163bca..f841714 100644
--- a/Src/DasherCore/OneButtonFilter.h
+++ b/Src/DasherCore/OneButtonFilter.h
@@ -16,8 +16,10 @@ class COneButtonFilter : public CInputFilter {
   virtual void KeyDown(int iTime, int iId, CDasherView *pView, CDasherModel *pModel, CUserLogBase *pUserLog);
   bool GetSettings(SModuleSettings **pSettings, int *iCount);
  private:
-
+  ///true iff the scan line is moving down/up, or is in the 'reverse' stage
   bool bStarted;
+  ///set by DecorateView: true iff we have drawn an undecorated display, else false.
+  bool m_bNoDecorations;
   int iStartTime;
   int iLocation;
 };
diff --git a/Src/DasherCore/StylusFilter.cpp b/Src/DasherCore/StylusFilter.cpp
index 7844292..1232f91 100644
--- a/Src/DasherCore/StylusFilter.cpp
+++ b/Src/DasherCore/StylusFilter.cpp
@@ -11,6 +11,9 @@ CStylusFilter::CStylusFilter(Dasher::CEventHandler *pEventHandler, CSettingsStor
 
 bool CStylusFilter::Timer(int iTime, CDasherView *pView, CDasherModel *pModel, Dasher::VECTOR_SYMBOL_PROB *pAdded, int *pNumDeleted, CExpansionPolicy **pol)
 {
+  if (pModel->NextScheduledStep(iTime, pAdded, pNumDeleted))
+      return true;
+  return CDefaultFilter::Timer(iTime, pView, pModel, pAdded, pNumDeleted, pol);
   if (GetBoolParameter(BP_DASHER_PAUSED))
   {
     //continue any zoom scheduled by a previous click...
@@ -24,6 +27,7 @@ bool CStylusFilter::Timer(int iTime, CDasherView *pView, CDasherModel *pModel, D
 
 void CStylusFilter::KeyDown(int iTime, int iId, CDasherView *pView, CDasherModel *pModel, CUserLogBase *pUserLog) {
   if(iId == 100) {
+    pModel->ClearScheduledSteps();
     m_pInterface->Unpause(iTime);
     m_iKeyDownTime = iTime;
   }
@@ -31,11 +35,12 @@ void CStylusFilter::KeyDown(int iTime, int iId, CDasherView *pView, CDasherModel
 
 void CStylusFilter::KeyUp(int iTime, int iId, CDasherView *pView, CDasherModel *pModel) {
   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));
+      pModel->ScheduleZoom(iTime, iDasherX, iDasherY, GetLongParameter(LP_MAXZOOM));
+    } else {
+      m_pInterface->Pause();
     }
   }
 }
diff --git a/Src/MacOSX/DasherApp.h b/Src/MacOSX/DasherApp.h
index a824c6a..5217f2f 100644
--- a/Src/MacOSX/DasherApp.h
+++ b/Src/MacOSX/DasherApp.h
@@ -33,7 +33,7 @@
 - (void)start;
 - (void)redraw;
 - (void)changeScreen:(COSXDasherScreen *)aScreen;
-- (void)pauseAtX:(int)x y:(int)y;
+- (void)pause;
 - (void)unpause:(unsigned long int)time;
 - (NSDictionary *)parameterDictionary;
 - (NSArray *)permittedValuesForParameter:(int)aParameter;
diff --git a/Src/MacOSX/DasherApp.mm b/Src/MacOSX/DasherApp.mm
index 1416542..55e1ae5 100644
--- a/Src/MacOSX/DasherApp.mm
+++ b/Src/MacOSX/DasherApp.mm
@@ -35,8 +35,8 @@
   aquaDasherControl->ChangeScreen( aScreen );
 }
 
-- (void)pauseAtX:(int)x y:(int)y {
-  aquaDasherControl->PauseAt(x, y);
+- (void)pause {
+  aquaDasherControl->Pause();
 }
 
 - (void)unpause:(unsigned long int)time {
diff --git a/Src/iPhone/Classes/DasherAppDelegate.mm b/Src/iPhone/Classes/DasherAppDelegate.mm
index 11ab971..04c7e66 100644
--- a/Src/iPhone/Classes/DasherAppDelegate.mm
+++ b/Src/iPhone/Classes/DasherAppDelegate.mm
@@ -280,7 +280,7 @@
 	
 - (void)settings {
   //avoid awful muddle if we change out of tap-to-start mode whilst running.... 
-  _dasherInterface->PauseAt(0,0);
+  _dasherInterface->Pause();
   [glView stopAnimation];
 	
   UITabBarController *tabs = [[[UITabBarController alloc] init] autorelease];
diff --git a/Src/iPhone/Classes/IPhoneFilters.cpp b/Src/iPhone/Classes/IPhoneFilters.cpp
index af2598c..7205586 100644
--- a/Src/iPhone/Classes/IPhoneFilters.cpp
+++ b/Src/iPhone/Classes/IPhoneFilters.cpp
@@ -77,5 +77,5 @@ void CIPhonePolarFilter::KeyDown(int iTime, int iId, CDasherView *pView, CDasher
 
 void CIPhonePolarFilter::KeyUp(int iTime, int iId, CDasherView *pView, CDasherModel *pModel) {
 	if(iId == 100)
-		m_pInterface->PauseAt(0, 0);
+		m_pInterface->Pause();
 }
\ No newline at end of file
diff --git a/Src/iPhone/Classes/PlainDragFilter.cpp b/Src/iPhone/Classes/PlainDragFilter.cpp
index 7eee448..dd7331c 100644
--- a/Src/iPhone/Classes/PlainDragFilter.cpp
+++ b/Src/iPhone/Classes/PlainDragFilter.cpp
@@ -33,6 +33,6 @@ void CPlainDragFilter::KeyUp(int iTime, int iId, CDasherView *pDasherView, CDash
 	if(iId == 100)
 	{
     DASHER_ASSERT(!GetBoolParameter(BP_DASHER_PAUSED));
-    m_pInterface->PauseAt(0, 0);
+    m_pInterface->Pause();
   }
 }
\ No newline at end of file



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