[dasher] Fix Gtk2 Control Mode and remove SetControlOffset()



commit 8295a7e7e061d4b4642b850892d6c3fbe8eb59ea
Author: Alan Lawrence <acl33 inf phy cam ac uk>
Date:   Mon Jun 14 17:23:20 2010 +0100

    Fix Gtk2 Control Mode and remove SetControlOffset()
    
    Test _EditorAction.iControlID to prevent spurious activations when entering
    root control node.
    
    SetControlOffset's only function appeared to be to change the offset of a
    control edit node which had just performed it's function - likely long after
    its children have been generated using & recording the old offset!
    Not setting it does affect the inheritance/carrying-through of context but only
    in subtle cases so the simpler way (without it, now) seems, at least, no worse!

 Src/DasherCore/DasherInterfaceBase.cpp |    5 -----
 Src/DasherCore/DasherInterfaceBase.h   |    2 --
 Src/DasherCore/DasherModel.cpp         |    7 -------
 Src/DasherCore/DasherModel.h           |    2 --
 Src/DasherCore/DasherNode.h            |    6 ------
 Src/Gtk2/GtkDasherControl.cpp          |    6 ------
 Src/Gtk2/GtkDasherControl.h            |    1 -
 Src/Gtk2/dasher_editor_internal.cpp    |    7 +++++--
 Src/Gtk2/dasher_main.cpp               |    4 ----
 9 files changed, 5 insertions(+), 35 deletions(-)
---
diff --git a/Src/DasherCore/DasherInterfaceBase.cpp b/Src/DasherCore/DasherInterfaceBase.cpp
index 09ea7bc..e72aee2 100644
--- a/Src/DasherCore/DasherInterfaceBase.cpp
+++ b/Src/DasherCore/DasherInterfaceBase.cpp
@@ -1117,11 +1117,6 @@ void CDasherInterfaceBase::SetOffset(int iOffset) {
     m_pDasherModel->SetOffset(iOffset, m_pDasherView);
 }
 
-void CDasherInterfaceBase::SetControlOffset(int iOffset) {
-  if(m_pDasherModel)
-    m_pDasherModel->SetControlOffset(iOffset);
-}
-
 // Returns 0 on success, an error string on failure.
 const char* CDasherInterfaceBase::ClSet(const std::string &strKey, const std::string &strValue) {
   if(m_pSettingsStore)
diff --git a/Src/DasherCore/DasherInterfaceBase.h b/Src/DasherCore/DasherInterfaceBase.h
index a73e7c9..638705a 100644
--- a/Src/DasherCore/DasherInterfaceBase.h
+++ b/Src/DasherCore/DasherInterfaceBase.h
@@ -356,8 +356,6 @@ public:
 
   std::string GetContext(int iStart, int iLength);
 
-  void SetControlOffset(int iOffset);
-
   /// Set a key value pair by name - designed to allow operation from
   /// the command line.  Returns 0 on success, an error string on failure. 
   ///
diff --git a/Src/DasherCore/DasherModel.cpp b/Src/DasherCore/DasherModel.cpp
index 536ea35..527d584 100644
--- a/Src/DasherCore/DasherModel.cpp
+++ b/Src/DasherCore/DasherModel.cpp
@@ -801,10 +801,3 @@ void CDasherModel::SetOffset(int iLocation, CDasherView *pView) {
   InitialiseAtOffset(iLocation, pView);
 }
 
-void CDasherModel::SetControlOffset(int iOffset) {
-  // This is a hack, making many dubious assumptions which happen to
-  // work right now.
-  CDasherNode *pNode = Get_node_under_crosshair();
-  
-  pNode->SetControlOffset(iOffset);
-}
diff --git a/Src/DasherCore/DasherModel.h b/Src/DasherCore/DasherModel.h
index 82482f3..d8c050b 100644
--- a/Src/DasherCore/DasherModel.h
+++ b/Src/DasherCore/DasherModel.h
@@ -198,8 +198,6 @@ class Dasher::CDasherModel:public Dasher::CFrameRate, private NoClones
   /// Create the children of a Dasher node
   void ExpandNode(CDasherNode * pNode); 
   
-  void SetControlOffset(int iOffset);
-
  private:
 
   /// Common portion of OneStepTowards / NextScheduledStep, taking
diff --git a/Src/DasherCore/DasherNode.h b/Src/DasherCore/DasherNode.h
index b700500..9c7265b 100644
--- a/Src/DasherCore/DasherNode.h
+++ b/Src/DasherCore/DasherNode.h
@@ -248,12 +248,6 @@ class Dasher::CDasherNode:private NoClones {
   ///
   virtual void GetContext(CDasherInterfaceBase *pInterface, std::vector<symbol> &vContextSymbols, int iOffset, int iLength);
   
-  /// ACL Not really sure why we should have to have this, but seems it's needed for something
-  /// to do with speech on Linux. I'm preserving it for now (indeed, making it part of CDasherNode,
-  /// rather than CControlManager::CContNode, where it should be - but that would require making
-  /// m_iOffset visible), as hopefully all speech functionality will be redone shortly...
-  void SetControlOffset(int iOffset) {m_iOffset = iOffset;};
-  
   ///
   /// See if this node represents the specified alphanumeric character; if so, set it's NF_GAME flag and
   /// return true; otherwise, return false.
diff --git a/Src/Gtk2/GtkDasherControl.cpp b/Src/Gtk2/GtkDasherControl.cpp
index 230bd7f..9e3c0d0 100644
--- a/Src/Gtk2/GtkDasherControl.cpp
+++ b/Src/Gtk2/GtkDasherControl.cpp
@@ -329,12 +329,6 @@ gtk_dasher_control_add_action_button(GtkDasherControl *pControl, const gchar *sz
   pPrivate->pControl->AddActionButton(szCommand);
 }
 
-void 
-gtk_dasher_control_set_control_offset(GtkDasherControl *pControl, gint iOffset) {
-  GtkDasherControlPrivate *pPrivate = GTK_DASHER_CONTROL_GET_PRIVATE(pControl);
-  pPrivate->pControl->SetControlOffset(iOffset);
-}
-
 const char *
 gtk_dasher_control_cl_set(GtkDasherControl *pControl, const gchar *szKey, const gchar *szValue) {
   GtkDasherControlPrivate *pPrivate = GTK_DASHER_CONTROL_GET_PRIVATE(pControl);
diff --git a/Src/Gtk2/GtkDasherControl.h b/Src/Gtk2/GtkDasherControl.h
index 0a22c87..2980421 100644
--- a/Src/Gtk2/GtkDasherControl.h
+++ b/Src/Gtk2/GtkDasherControl.h
@@ -94,7 +94,6 @@ void gtk_dasher_control_game_messageout(GtkDasherControl *pControl, int message,
 void gtk_dasher_control_force_pause(GtkDasherControl *pControl);
 double gtk_dasher_control_get_framerate(GtkDasherControl *pControl);
 void gtk_dasher_control_add_action_button(GtkDasherControl *pControl, const gchar *szCommand);
-void gtk_dasher_control_set_control_offset(GtkDasherControl *pControl, gint iOffset);
 void gtk_dasher_user_log_new_trial(GtkDasherControl * pControl);
 void gtk_dasher_control_set_focus(GtkDasherControl * pControl);
 const gchar* gtk_dasher_control_cl_set(GtkDasherControl *pControl, const gchar *szKey, const gchar *szValue);
diff --git a/Src/Gtk2/dasher_editor_internal.cpp b/Src/Gtk2/dasher_editor_internal.cpp
index 3d576ac..f419e94 100644
--- a/Src/Gtk2/dasher_editor_internal.cpp
+++ b/Src/Gtk2/dasher_editor_internal.cpp
@@ -424,13 +424,16 @@ dasher_editor_internal_handle_control(DasherEditor *pSelf, int iNodeID) {
 
   if(iNodeID == Dasher::CControlManager::CTL_USER + 1)
     dasher_editor_internal_clear(pSelf, false); // Clear node is a special case (it shouldn't be)
-  else {
+  else if (pPrivate->pActionRing) {
     EditorAction *pCurrentAction = pPrivate->pActionRing;
     bool bStarted = false;
     
     while(!bStarted || (pCurrentAction != pPrivate->pActionRing)) {
       bStarted = true;
-      if((iNodeID >= pCurrentAction->iControlID) && (iNodeID <= pCurrentAction->iControlID + pCurrentAction->iNSub)) {
+      //ACL 14/6/10 Adding test that iControlID is a sensible value -
+      // it never is, as it's never set, but it prevents the old code from
+      // being erroneously activated when e.g. the root control node is entered!
+      if(pCurrentAction->iControlID >= Dasher::CControlManager::CTL_USER && (iNodeID >= pCurrentAction->iControlID) && (iNodeID <= pCurrentAction->iControlID + pCurrentAction->iNSub)) {
 	dasher_action_execute(pCurrentAction->pAction, DASHER_EDITOR(pSelf), iNodeID - pCurrentAction->iControlID - 1); 
 	//	dasher_editor_internal_clear(pSelf, true); 
       }
diff --git a/Src/Gtk2/dasher_main.cpp b/Src/Gtk2/dasher_main.cpp
index c25396f..46afe64 100644
--- a/Src/Gtk2/dasher_main.cpp
+++ b/Src/Gtk2/dasher_main.cpp
@@ -1415,10 +1415,6 @@ handle_control_event(GtkDasherControl *pDasherControl, gint iEvent, gpointer dat
 
   DasherMainPrivate *pPrivate = DASHER_MAIN_GET_PRIVATE(g_pDasherMain);
   dasher_editor_handle_control(pPrivate->pEditor, iEvent);
-
-  gtk_dasher_control_set_control_offset(GTK_DASHER_CONTROL(pPrivate->pDasherWidget), 
-                                        dasher_editor_get_offset(pPrivate->pEditor));
-
   g_bSend = true;
   // ---
 }



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