[dasher: 2/16] Fix menu mode scanning, make menu+direct modes operable by mouse



commit 0b89f028bbb2dcec0916424a63d12c43f07e51f7
Author: Alan Lawrence <acl33 inf phy cam ac uk>
Date:   Wed Sep 2 14:56:02 2009 +0100

    Fix menu mode scanning, make menu+direct modes operable by mouse
    
    Also changed DasherInterfaceBase::HandleClick{Up,Down} to pass on co-ordinates.
    Should we be using these, rather than calling DasherView::GetCoordinates(x,y)?

 Src/DasherCore/ButtonMode.cpp          |   21 +++++++++++++++++++++
 Src/DasherCore/ButtonMode.h            |    3 +++
 Src/DasherCore/DasherButtons.cpp       |    6 ++++--
 Src/DasherCore/DasherInterfaceBase.cpp |    4 ++--
 4 files changed, 30 insertions(+), 4 deletions(-)
---
diff --git a/Src/DasherCore/ButtonMode.cpp b/Src/DasherCore/ButtonMode.cpp
index 9bc5445..89376fb 100644
--- a/Src/DasherCore/ButtonMode.cpp
+++ b/Src/DasherCore/ButtonMode.cpp
@@ -188,6 +188,27 @@ bool CButtonMode::Timer(int Time, CDasherView *pView, CDasherModel *pModel, Dash
   return CDasherButtons::Timer(Time, pView, pModel, pAdded, pNumDeleted);
 }
 
+void CButtonMode::KeyDown(int iTime, int iId, CDasherView *pView, CDasherModel *pModel, CUserLogBase *pUserLog, bool bPos, int iX, int iY)
+{
+  if (iId == 100 && !m_bMenu) {
+    //Mouse!
+    myint iDasherX, iDasherY;
+    pView->GetCoordinates(iDasherX, iDasherY);
+    for (int i = 0; i < m_iNumBoxes; i++)
+    {
+      if (iDasherY < m_pBoxes[i].iDisplayBottom &&
+          iDasherY > m_pBoxes[i].iDisplayTop &&
+          iDasherX < (m_pBoxes[i].iDisplayBottom - m_pBoxes[i].iDisplayTop)) {
+        //user has clicked in box! Simulate press of appropriate (direct-mode) button...
+        CDasherButtons::KeyDown(iTime, (i==m_iNumBoxes-1) ? 1 : i+2, pView, pModel, pUserLog);
+        return;
+      }
+    }
+    //not in any box. Fall through, just to be conservative...
+  }
+  CInputFilter::KeyDown(iTime, iId, pView, pModel, pUserLog, bPos, iX, iY);
+}
+
 void CButtonMode::DirectKeyDown(int iTime, int iId, CDasherView *pView, CDasherModel *pModel, CUserLogBase *pUserLog) {
   CDasherButtons::DirectKeyDown(iTime, iId, pView, pModel, pUserLog);
  if (iId!=100) m_iLastTime = iTime;
diff --git a/Src/DasherCore/ButtonMode.h b/Src/DasherCore/ButtonMode.h
index 3b720f3..fde8479 100644
--- a/Src/DasherCore/ButtonMode.h
+++ b/Src/DasherCore/ButtonMode.h
@@ -29,6 +29,9 @@ class CButtonMode : public CDasherButtons
   bool Timer(int Time, CDasherView *pView, CDasherModel *pModel, Dasher::VECTOR_SYMBOL_PROB *pAdded, int *pNumDeleted);
   bool DecorateView(CDasherView *pView);
 
+  //override to get mouse clicks/taps back again
+  virtual void KeyDown(int Time, int iId, CDasherView *pDasherView, CDasherModel *pModel, CUserLogBase *pUserLog, bool bPos, int iX, int iY);
+  
   bool GetSettings(SModuleSettings **pSettings, int *iCount);
  protected: 
   void SetupBoxes();
diff --git a/Src/DasherCore/DasherButtons.cpp b/Src/DasherCore/DasherButtons.cpp
index 8bed265..119765a 100644
--- a/Src/DasherCore/DasherButtons.cpp
+++ b/Src/DasherCore/DasherButtons.cpp
@@ -37,6 +37,7 @@ void CDasherButtons::Activate() {
   //ick - can't do this at construction time! This should get called before anything
   // which depends on it, tho...
   if (!m_pBoxes) SetupBoxes();
+
   m_iScanTime = std::numeric_limits<int>::min();
 }
 
@@ -53,6 +54,7 @@ void CDasherButtons::KeyDown(int iTime, int iId, CDasherView *pView, CDasherMode
        break;
     case 2:
     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);
       if(iActiveBox != m_iNumBoxes-1)
@@ -81,8 +83,8 @@ void CDasherButtons::DirectKeyDown(int iTime, int iId, CDasherView *pView, CDash
 
 bool CDasherButtons::Timer(int Time, CDasherView *m_pDasherView, CDasherModel *m_pDasherModel, Dasher::VECTOR_SYMBOL_PROB *pAdded, int *pNumDeleted) {
   if (m_bMenu && GetLongParameter(LP_BUTTON_SCAN_TIME) &&
-      Time - m_iScanTime > GetLongParameter(LP_BUTTON_SCAN_TIME)) {
-    m_iScanTime = Time;
+      Time > m_iScanTime) {
+    m_iScanTime = Time + GetLongParameter(LP_BUTTON_SCAN_TIME);
     m_bDecorationChanged = true;
     ++iActiveBox;
     if(iActiveBox == m_iNumBoxes)
diff --git a/Src/DasherCore/DasherInterfaceBase.cpp b/Src/DasherCore/DasherInterfaceBase.cpp
index 5b344f1..0e732dd 100644
--- a/Src/DasherCore/DasherInterfaceBase.cpp
+++ b/Src/DasherCore/DasherInterfaceBase.cpp
@@ -1053,7 +1053,7 @@ void CDasherInterfaceBase::HandleClickUp(int iTime, int iX, int iY) {
   }
 #endif
 
-  KeyUp(iTime, 100);
+  KeyUp(iTime, 100, true, iX, iY);
 }
 
 void CDasherInterfaceBase::HandleClickDown(int iTime, int iX, int iY) {
@@ -1071,7 +1071,7 @@ void CDasherInterfaceBase::HandleClickDown(int iTime, int iX, int iY) {
   }
 #endif
 
-  KeyDown(iTime, 100);
+  KeyDown(iTime, 100, true, iX, iY);
 }
 
 



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