[dasher] Rm BP_SMOOTH_OFFSET
- From: Patrick Welche <pwelche src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dasher] Rm BP_SMOOTH_OFFSET
- Date: Tue, 12 Jul 2011 15:27:58 +0000 (UTC)
commit 3df8f766de22947035d9555a0d74fdbc838d793f
Author: Alan Lawrence <acl33 inf phy cam ac uk>
Date: Thu Jun 23 16:23:43 2011 +0100
Rm BP_SMOOTH_OFFSET
True whenever it mattered; whenever false, would have made no difference
CDashIntf pauses filter before Deactivate; DynamicFilter calls AbortOffset
upon pause (as long as Offset applied via DynamicFilter::ApplyOffset)
- should now be applied in all cases.
Src/DasherCore/DasherInterfaceBase.cpp | 2 ++
Src/DasherCore/DasherModel.cpp | 9 +--------
Src/DasherCore/DynamicFilter.cpp | 11 ++++++++++-
Src/DasherCore/DynamicFilter.h | 6 +++++-
Src/DasherCore/Parameters.cpp | 1 -
Src/DasherCore/Parameters.h | 2 +-
Src/DasherCore/TwoButtonDynamicFilter.cpp | 28 +---------------------------
Src/DasherCore/TwoButtonDynamicFilter.h | 9 ---------
Src/DasherCore/TwoPushDynamicFilter.cpp | 2 +-
9 files changed, 21 insertions(+), 49 deletions(-)
---
diff --git a/Src/DasherCore/DasherInterfaceBase.cpp b/Src/DasherCore/DasherInterfaceBase.cpp
index b94123a..9061b7d 100644
--- a/Src/DasherCore/DasherInterfaceBase.cpp
+++ b/Src/DasherCore/DasherInterfaceBase.cpp
@@ -766,6 +766,8 @@ void CDasherInterfaceBase::KeyUp(int iTime, int iId, bool bPos, int iX, int iY)
void CDasherInterfaceBase::CreateInputFilter()
{
+ SetBoolParameter(BP_DASHER_PAUSED,true); //seems a sensible precaution!
+
if(m_pInputFilter) {
m_pInputFilter->Deactivate();
m_pInputFilter = NULL;
diff --git a/Src/DasherCore/DasherModel.cpp b/Src/DasherCore/DasherModel.cpp
index c1cdd76..7db4376 100644
--- a/Src/DasherCore/DasherModel.cpp
+++ b/Src/DasherCore/DasherModel.cpp
@@ -97,12 +97,6 @@ void CDasherModel::HandleEvent(int iParameter) {
CFrameRate::HandleEvent(iParameter);
switch (iParameter) {
- case BP_SMOOTH_OFFSET:
- if (!GetBoolParameter(BP_SMOOTH_OFFSET))
- //smoothing has just been turned off. End any transition/jump currently
- // in progress at it's current point
- AbortOffset();
- break;
case BP_DASHER_PAUSED:
if(GetBoolParameter(BP_SLOW_START))
m_iStartTime = 0;
@@ -624,8 +618,7 @@ void CDasherModel::Offset(int iOffset) {
m_Rootmin += iOffset;
m_Rootmax += iOffset;
- if (GetBoolParameter(BP_SMOOTH_OFFSET))
- m_iDisplayOffset -= iOffset;
+ m_iDisplayOffset -= iOffset;
}
void CDasherModel::AbortOffset() {
diff --git a/Src/DasherCore/DynamicFilter.cpp b/Src/DasherCore/DynamicFilter.cpp
index 78f9410..2163bfc 100644
--- a/Src/DasherCore/DynamicFilter.cpp
+++ b/Src/DasherCore/DynamicFilter.cpp
@@ -24,7 +24,7 @@
using namespace Dasher;
CDynamicFilter::CDynamicFilter(CSettingsUser *pCreator, CDasherInterfaceBase *pInterface, ModuleID_t iID, const char *szName)
- : CInputFilter(pInterface, iID, szName), CSettingsUserObserver(pCreator) {
+ : CInputFilter(pInterface, iID, szName), CSettingsUserObserver(pCreator), m_pModel(NULL) {
m_bDecorationChanged = true;
m_bKeyDown = false;
pause();
@@ -135,6 +135,11 @@ void CDynamicFilter::HandleEvent(int iParameter) {
}
}
+void CDynamicFilter::pause() {
+ m_iState = 0;
+ if (m_pModel) m_pModel->AbortOffset();
+}
+
void CDynamicFilter::reverse()
{
m_iState = 1;
@@ -152,3 +157,7 @@ void CDynamicFilter::run()
m_iState = 2;
}
+void CDynamicFilter::ApplyOffset(CDasherModel *pModel, int iOffset) {
+ (m_pModel=pModel)->Offset(iOffset);
+}
+
diff --git a/Src/DasherCore/DynamicFilter.h b/Src/DasherCore/DynamicFilter.h
index 110809f..c3c0e6c 100644
--- a/Src/DasherCore/DynamicFilter.h
+++ b/Src/DasherCore/DynamicFilter.h
@@ -51,17 +51,21 @@ class CDynamicFilter : public CInputFilter, public CSettingsUserObserver {
bool isPaused() {return m_iState == 0;}
bool isReversing() {return m_iState == 1;}
bool isRunning() {return m_iState==2;}
- virtual void pause() {m_iState = 0;}
+ virtual void pause();
virtual void reverse();
virtual void run();
virtual bool TimerImpl(unsigned long Time, CDasherView *m_pDasherView, CDasherModel *m_pDasherModel, CExpansionPolicy **pol) = 0;
+ ///Subclasses should all this (rather than pModel->Offset()) to offset the model
+ /// (it also stores the model, to abort the offset upon pause if necessary)
+ void ApplyOffset(CDasherModel *pModel, int iOffset);
private:
int m_iState; // 0 = paused, 1 = reversing, >=2 = running (extensible by subclasses)
int m_iHeldId;
int m_iKeyDownTime;
unsigned int m_uSpeedControlTime;
+ CDasherModel *m_pModel;
};
}
#endif
diff --git a/Src/DasherCore/Parameters.cpp b/Src/DasherCore/Parameters.cpp
index c2e1f3e..50fc272 100644
--- a/Src/DasherCore/Parameters.cpp
+++ b/Src/DasherCore/Parameters.cpp
@@ -38,7 +38,6 @@ const bp_table boolparamtable[] = {
#else
{BP_NONLINEAR_Y, "NonlinearY", PERS, true, "Apply nonlinearities to Y axis (i.e. compress top & bottom)"},
#endif
- {BP_SMOOTH_OFFSET, "DelayView", !PERS, false, "Smooth dynamic-button-mode jumps over several frames"},
{BP_STOP_OUTSIDE, "PauseOutside", PERS, false, "Whether to stop when pointer leaves canvas area"},
#ifdef TARGET_OS_IPHONE
{BP_BACKOFF_BUTTON, "BackoffButton", PERS, false, "Whether to enable the extra backoff button in dynamic mode"},
diff --git a/Src/DasherCore/Parameters.h b/Src/DasherCore/Parameters.h
index a747608..bbad1a4 100644
--- a/Src/DasherCore/Parameters.h
+++ b/Src/DasherCore/Parameters.h
@@ -38,7 +38,7 @@ enum {
BP_LM_LETTER_EXCLUSION, BP_AUTO_SPEEDCONTROL,
BP_LM_ADAPTIVE, BP_SOCKET_INPUT_ENABLE, BP_SOCKET_DEBUG,
BP_CIRCLE_START, BP_GLOBAL_KEYBOARD, BP_NONLINEAR_Y,
- BP_SMOOTH_OFFSET, BP_STOP_OUTSIDE, BP_BACKOFF_BUTTON,
+ BP_STOP_OUTSIDE, BP_BACKOFF_BUTTON,
BP_TWOBUTTON_REVERSE, BP_2B_INVERT_DOUBLE, BP_SLOW_START,
BP_COPY_ALL_ON_STOP, BP_SPEAK_ALL_ON_STOP, BP_SPEAK_WORDS,
BP_CONTROL_MODE_HAS_HALT, BP_CONTROL_MODE_HAS_EDIT, BP_CONTROL_MODE_HAS_COPY, BP_CONTROL_MODE_HAS_SPEECH,
diff --git a/Src/DasherCore/TwoButtonDynamicFilter.cpp b/Src/DasherCore/TwoButtonDynamicFilter.cpp
index 2491c07..3224405 100644
--- a/Src/DasherCore/TwoButtonDynamicFilter.cpp
+++ b/Src/DasherCore/TwoButtonDynamicFilter.cpp
@@ -115,31 +115,6 @@ bool CTwoButtonDynamicFilter::TimerImpl(unsigned long Time, CDasherView *m_pDash
return true;
}
-void CTwoButtonDynamicFilter::Activate() {
- SetBoolParameter(BP_SMOOTH_OFFSET, true);
-}
-
-void CTwoButtonDynamicFilter::Deactivate() {
- SetBoolParameter(BP_SMOOTH_OFFSET, false);
-}
-
-void CTwoButtonDynamicFilter::run() {
- SetBoolParameter(BP_SMOOTH_OFFSET, true);
- CButtonMultiPress::run();
-}
-
-void CTwoButtonDynamicFilter::pause() {
- SetBoolParameter(BP_SMOOTH_OFFSET, false);
- CButtonMultiPress::pause();
-}
-
-void CTwoButtonDynamicFilter::reverse() {
- //hmmmm. If we ever actually did Offset() while reversing,
- // we might want BP_SMOOTH_OFFSET on....
- SetBoolParameter(BP_SMOOTH_OFFSET, false);
- CButtonMultiPress::reverse();
-}
-
void CTwoButtonDynamicFilter::ActionButton(int iTime, int iButton, int iType, CDasherModel *pModel) {
double dFactor(GetBoolParameter(BP_TWOBUTTON_REVERSE) ? -1.0 : 1.0);
@@ -171,8 +146,7 @@ void CTwoButtonDynamicFilter::ActionButton(int iTime, int iButton, int iType, CD
return;
}
//fell through to apply offset
- int iOffset(dFactor * GetLongParameter(LP_TWO_BUTTON_OFFSET) * m_dLagMul);
- pModel->Offset(iOffset);
+ ApplyOffset(pModel,dFactor * GetLongParameter(LP_TWO_BUTTON_OFFSET) * m_dLagMul);
pModel->ResetNats();
if(CUserLogBase *pUserLog=m_pInterface->GetUserLogPtr())
diff --git a/Src/DasherCore/TwoButtonDynamicFilter.h b/Src/DasherCore/TwoButtonDynamicFilter.h
index a9f0b2b..aa71eaa 100644
--- a/Src/DasherCore/TwoButtonDynamicFilter.h
+++ b/Src/DasherCore/TwoButtonDynamicFilter.h
@@ -35,9 +35,6 @@ class CTwoButtonDynamicFilter : public CButtonMultiPress {
// Inherited methods
virtual bool DecorateView(CDasherView *pView, CDasherInput *pInput);
- virtual void Activate();
- virtual void Deactivate();
-
virtual bool GetSettings(SModuleSettings **pSettings, int *iCount);
virtual bool GetMinWidth(int &iMinWidth);
@@ -45,10 +42,6 @@ class CTwoButtonDynamicFilter : public CButtonMultiPress {
virtual void HandleEvent(int iParameter);
protected:
- virtual void run();
- virtual void pause();
- virtual void reverse();
-
//override to inspect x,y coords of mouse clicks/taps
virtual void KeyDown(int Time, int iId, CDasherView *pDasherView, CDasherInput *pInput, CDasherModel *pModel, bool bPos, int iX, int iY);
virtual void KeyUp(int Time, int iId, CDasherView *pDasherView, CDasherInput *pInput, CDasherModel *pModel, bool bPos, int iX, int iY);
@@ -58,8 +51,6 @@ class CTwoButtonDynamicFilter : public CButtonMultiPress {
virtual bool TimerImpl(unsigned long Time, CDasherView *m_pDasherView, CDasherModel *m_pDasherModel, CExpansionPolicy **pol);
virtual void ActionButton(int iTime, int iButton, int iType, CDasherModel *pModel);
double m_dLagMul;
-
- void ApplyOffset(CDasherModel *pModel, long lOffset);
};
}
/// @}
diff --git a/Src/DasherCore/TwoPushDynamicFilter.cpp b/Src/DasherCore/TwoPushDynamicFilter.cpp
index 21972ee..1922e09 100644
--- a/Src/DasherCore/TwoPushDynamicFilter.cpp
+++ b/Src/DasherCore/TwoPushDynamicFilter.cpp
@@ -207,7 +207,7 @@ void CTwoPushDynamicFilter::ActionButton(int iTime, int iButton, int iType, CDas
reverse();
else
{
- pModel->Offset(m_aiTarget[m_iActiveMarker]);
+ ApplyOffset(pModel,m_aiTarget[m_iActiveMarker]);
pModel->ResetNats();
//don't really have to reset there, but seems as good a place as any
m_dNatsSinceFirstPush = -std::numeric_limits<double>::infinity(); //"waiting for first push"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]