[dasher] Ensure Two-push mode markers stay down<up<outer when parameters adjusted
- From: Patrick Welche <pwelche src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dasher] Ensure Two-push mode markers stay down<up<outer when parameters adjusted
- Date: Tue, 18 Jan 2011 17:16:15 +0000 (UTC)
commit 4b6c3dd2e1a6e9369f48ba4c443f248cc1875e2a
Author: Alan Lawrence <acl33 inf phy cam ac uk>
Date: Thu Nov 18 12:01:37 2010 +0000
Ensure Two-push mode markers stay down<up<outer when parameters adjusted
Responds to CParameterNotificationEvent by making appropriate further calls
to SetLongParameter on other parameter(s).
This needs module settings dialogs to observe parameter changes even when
the dialog is on top; not all do this atm. (e.g. iPhone)
Src/DasherCore/TwoPushDynamicFilter.cpp | 32 +++++++++++++++++++++++-------
1 files changed, 24 insertions(+), 8 deletions(-)
---
diff --git a/Src/DasherCore/TwoPushDynamicFilter.cpp b/Src/DasherCore/TwoPushDynamicFilter.cpp
index 01f4959..a117ae8 100644
--- a/Src/DasherCore/TwoPushDynamicFilter.cpp
+++ b/Src/DasherCore/TwoPushDynamicFilter.cpp
@@ -28,8 +28,8 @@ using namespace Dasher;
static SModuleSettings sSettings[] = {
{LP_TWO_PUSH_OUTER, T_LONG, 1024, 2048, 2048, 128, _("Offset for outer (second) button")},
- {LP_TWO_PUSH_UP, T_LONG, 256, 2048, 2048/*divisor*/, 128/*step*/, _("Distance for 1st button UP")},
- {LP_TWO_PUSH_DOWN, T_LONG, 256, 2048, 2048, 128, _("Distance for 1st button DOWN")},
+ {LP_TWO_PUSH_UP, T_LONG, 257, 2047, 2048/*divisor*/, 128/*step*/, _("Distance for 1st button UP")},
+ {LP_TWO_PUSH_DOWN, T_LONG, 256, 2046, 2048, 128, _("Distance for 1st button DOWN")},
{LP_TWO_PUSH_TOLERANCE, T_LONG, 50, 1000, 1, 10, _("Tolerance for inaccurate timing of button pushes (in ms)")},
/* TRANSLATORS: The time for which a button must be held before it counts as a 'long' (rather than short) press. */
{LP_HOLD_TIME, T_LONG, 100, 10000, 1000, 100, _("Long press time")},
@@ -107,14 +107,30 @@ void CTwoPushDynamicFilter::HandleEvent(Dasher::CEvent * pEvent)
Dasher::CParameterNotificationEvent * pEvt(static_cast < Dasher::CParameterNotificationEvent * >(pEvent));
switch (pEvt->m_iParameter)
{
- case LP_TWO_PUSH_OUTER: //deliberate fallthrough
- case LP_TWO_PUSH_UP: //deliberate fallthrough
+ case LP_TWO_PUSH_OUTER:
+ if (GetLongParameter(LP_TWO_PUSH_OUTER)<=GetLongParameter(LP_TWO_PUSH_UP)) {
+ //two_push_outer being moved down; force two_push_up down too
+ SetLongParameter(LP_TWO_PUSH_UP, GetLongParameter(LP_TWO_PUSH_OUTER)-1);
+ return; // as HandleEvent on latter will execute same code (below)
+ }
+ //deliberate fallthrough
+ case LP_TWO_PUSH_UP:
+ if (GetLongParameter(LP_TWO_PUSH_UP)>=GetLongParameter(LP_TWO_PUSH_OUTER)) {
+ //two_push_up must have changed, or we'd have caught this in previous check for two_push_outer
+ SetLongParameter(LP_TWO_PUSH_OUTER, GetLongParameter(LP_TWO_PUSH_UP)+1);
+ return;
+ }
+ if (GetLongParameter(LP_TWO_PUSH_UP)<=GetLongParameter(LP_TWO_PUSH_DOWN)) {
+ SetLongParameter(LP_TWO_PUSH_DOWN, GetLongParameter(LP_TWO_PUSH_UP)-1);
+ return;
+ }
+ //deliberate fallthrough
case LP_TWO_PUSH_DOWN:
+ if (GetLongParameter(LP_TWO_PUSH_DOWN)>=GetLongParameter(LP_TWO_PUSH_UP)) {
+ SetLongParameter(LP_TWO_PUSH_UP, GetLongParameter(LP_TWO_PUSH_DOWN)+1);
+ return;
+ }
{
-//cout << "Initializing - outer " << GetLongParameter(LP_TWO_PUSH_OUTER) << " up " << GetLongParameter(LP_TWO_PUSH_UP) << " down " << GetLongParameter(LP_TWO_PUSH_DOWN) << "\n";
- DASHER_ASSERT (GetLongParameter(LP_TWO_PUSH_UP) < GetLongParameter(LP_TWO_PUSH_OUTER));
- DASHER_ASSERT (GetLongParameter(LP_TWO_PUSH_DOWN) < GetLongParameter(LP_TWO_PUSH_OUTER));
- DASHER_ASSERT (GetLongParameter(LP_TWO_PUSH_UP) > GetLongParameter(LP_TWO_PUSH_DOWN));
//TODO, that means short gap at the top - allow other way around also?
double dOuter = GetLongParameter(LP_TWO_PUSH_OUTER);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]