[dasher: 11/16] Made margin width a parameter: LP_MARGIN_WIDTH
- From: Patrick Welche <pwelche src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [dasher: 11/16] Made margin width a parameter: LP_MARGIN_WIDTH
- Date: Tue, 1 Dec 2009 16:15:04 +0000 (UTC)
commit 438679a3d8e6364da729d847e22d0f56fcc1b7f4
Author: Alan Lawrence <acl33 inf phy cam ac uk>
Date: Tue Sep 29 16:43:38 2009 +0100
Made margin width a parameter: LP_MARGIN_WIDTH
Src/DasherCore/DasherInterfaceBase.cpp | 3 +++
Src/DasherCore/DasherViewSquare.cpp | 29 +++++++++++++++++------------
Src/DasherCore/DasherViewSquare.h | 1 +
Src/DasherCore/Parameters.h | 3 ++-
4 files changed, 23 insertions(+), 13 deletions(-)
---
diff --git a/Src/DasherCore/DasherInterfaceBase.cpp b/Src/DasherCore/DasherInterfaceBase.cpp
index 0e732dd..1c02b7a 100644
--- a/Src/DasherCore/DasherInterfaceBase.cpp
+++ b/Src/DasherCore/DasherInterfaceBase.cpp
@@ -323,6 +323,9 @@ void CDasherInterfaceBase::InterfaceEventHandler(Dasher::CEvent *pEvent) {
case BP_DASHER_PAUSED:
ScheduleRedraw();
break;
+ case LP_MARGIN_WIDTH:
+ ScheduleRedraw();
+ break;
default:
break;
}
diff --git a/Src/DasherCore/DasherViewSquare.cpp b/Src/DasherCore/DasherViewSquare.cpp
index 378e6b3..d0c3304 100644
--- a/Src/DasherCore/DasherViewSquare.cpp
+++ b/Src/DasherCore/DasherViewSquare.cpp
@@ -101,6 +101,10 @@ void CDasherViewSquare::HandleEvent(Dasher::CEvent *pEvent) {
case LP_REAL_ORIENTATION:
m_bVisibleRegionValid = false;
break;
+ case LP_MARGIN_WIDTH:
+ m_bVisibleRegionValid = false;
+ SetScaleFactor();
+ break;
default:
break;
}
@@ -547,7 +551,7 @@ void CDasherViewSquare::Screen2Dasher(screenint iInputX, screenint iInputY, myin
// Things we're likely to need:
- myint iDasherWidth = (myint)GetLongParameter(LP_MAX_Y);
+ //myint iDasherWidth = (myint)GetLongParameter(LP_MAX_Y);
myint iDasherHeight = (myint)GetLongParameter(LP_MAX_Y);
screenint iScreenWidth = Screen()->GetWidth();
@@ -562,19 +566,19 @@ void CDasherViewSquare::Screen2Dasher(screenint iInputX, screenint iInputY, myin
switch(eOrientation) {
case Dasher::Opts::LeftToRight:
- iDasherX = iDasherWidth / 2 - ( iInputX - iScreenWidth / 2 ) * m_iScalingFactor / iScaleFactorX;
+ iDasherX = iCenterX - ( iInputX - iScreenWidth / 2 ) * m_iScalingFactor / iScaleFactorX;
iDasherY = iDasherHeight / 2 + ( iInputY - iScreenHeight / 2 ) * m_iScalingFactor / iScaleFactorY;
break;
case Dasher::Opts::RightToLeft:
- iDasherX = myint(iDasherWidth / 2 + ( iInputX - iScreenWidth / 2 ) * m_iScalingFactor/ iScaleFactorX);
+ iDasherX = myint(iCenterX + ( iInputX - iScreenWidth / 2 ) * m_iScalingFactor/ iScaleFactorX);
iDasherY = myint(iDasherHeight / 2 + ( iInputY - iScreenHeight / 2 ) * m_iScalingFactor/ iScaleFactorY);
break;
case Dasher::Opts::TopToBottom:
- iDasherX = myint(iDasherWidth / 2 - ( iInputY - iScreenHeight / 2 ) * m_iScalingFactor/ iScaleFactorY);
+ iDasherX = myint(iCenterX - ( iInputY - iScreenHeight / 2 ) * m_iScalingFactor/ iScaleFactorY);
iDasherY = myint(iDasherHeight / 2 + ( iInputX - iScreenWidth / 2 ) * m_iScalingFactor/ iScaleFactorX);
break;
case Dasher::Opts::BottomToTop:
- iDasherX = myint(iDasherWidth / 2 + ( iInputY - iScreenHeight / 2 ) * m_iScalingFactor/ iScaleFactorY);
+ iDasherX = myint(iCenterX + ( iInputY - iScreenHeight / 2 ) * m_iScalingFactor/ iScaleFactorY);
iDasherY = myint(iDasherHeight / 2 + ( iInputX - iScreenWidth / 2 ) * m_iScalingFactor/ iScaleFactorX);
break;
}
@@ -596,10 +600,11 @@ void CDasherViewSquare::SetScaleFactor( void )
// Try doing this a different way:
- myint iDasherMargin( 300 ); // Make this a parameter
+ myint iDasherMargin( GetLongParameter(LP_MARGIN_WIDTH) ); // Make this a parameter
myint iMinX( 0-iDasherMargin );
- myint iMaxX( iDasherWidth + iDasherMargin );
+ myint iMaxX( iDasherWidth - 2*iDasherMargin );
+ iCenterX = (iMinX + iMaxX)/2;
myint iMinY( 0 );
myint iMaxY( iDasherHeight );
@@ -674,7 +679,7 @@ void CDasherViewSquare::Dasher2Screen(myint iDasherX, myint iDasherY, screenint
// Things we're likely to need:
- myint iDasherWidth = (myint)GetLongParameter(LP_MAX_Y);
+ //myint iDasherWidth = (myint)GetLongParameter(LP_MAX_Y);
myint iDasherHeight = (myint)GetLongParameter(LP_MAX_Y);
screenint iScreenWidth = Screen()->GetWidth();
@@ -695,13 +700,13 @@ void CDasherViewSquare::Dasher2Screen(myint iDasherX, myint iDasherY, screenint
switch( eOrientation ) {
case Dasher::Opts::LeftToRight:
iScreenX = screenint(iScreenWidth / 2 -
- CustomIDiv((( iDasherX - iDasherWidth / 2 ) * iScaleFactorX), m_iScalingFactor));
+ CustomIDiv((( iDasherX - iCenterX ) * iScaleFactorX), m_iScalingFactor));
iScreenY = screenint(iScreenHeight / 2 +
CustomIDiv(( iDasherY - iDasherHeight / 2 ) * iScaleFactorY, m_iScalingFactor));
break;
case Dasher::Opts::RightToLeft:
iScreenX = screenint(iScreenWidth / 2 +
- CustomIDiv(( iDasherX - iDasherWidth / 2 ) * iScaleFactorX, m_iScalingFactor));
+ CustomIDiv(( iDasherX - iCenterX ) * iScaleFactorX, m_iScalingFactor));
iScreenY = screenint(iScreenHeight / 2 +
CustomIDiv(( iDasherY - iDasherHeight / 2 ) * iScaleFactorY, m_iScalingFactor));
break;
@@ -709,13 +714,13 @@ void CDasherViewSquare::Dasher2Screen(myint iDasherX, myint iDasherY, screenint
iScreenX = screenint(iScreenWidth / 2 +
CustomIDiv(( iDasherY - iDasherHeight / 2 ) * iScaleFactorX, m_iScalingFactor));
iScreenY = screenint(iScreenHeight / 2 -
- CustomIDiv(( iDasherX - iDasherWidth / 2 ) * iScaleFactorY, m_iScalingFactor));
+ CustomIDiv(( iDasherX - iCenterX ) * iScaleFactorY, m_iScalingFactor));
break;
case Dasher::Opts::BottomToTop:
iScreenX = screenint(iScreenWidth / 2 +
CustomIDiv(( iDasherY - iDasherHeight / 2 ) * iScaleFactorX, m_iScalingFactor));
iScreenY = screenint(iScreenHeight / 2 +
- CustomIDiv(( iDasherX - iDasherWidth / 2 ) * iScaleFactorY, m_iScalingFactor));
+ CustomIDiv(( iDasherX - iCenterX ) * iScaleFactorY, m_iScalingFactor));
break;
}
}
diff --git a/Src/DasherCore/DasherViewSquare.h b/Src/DasherCore/DasherViewSquare.h
index a103a73..b19b168 100644
--- a/Src/DasherCore/DasherViewSquare.h
+++ b/Src/DasherCore/DasherViewSquare.h
@@ -188,6 +188,7 @@ private:
double m_dXmpa, m_dXmpb, m_dXmpc, m_dXmpd;
screenint CanvasX, CanvasY, CanvasBorder;
+ screenint iCenterX;
Cymap m_ymap;
// Cached values for scaling
diff --git a/Src/DasherCore/Parameters.h b/Src/DasherCore/Parameters.h
index c6d9224..a6b3a3d 100644
--- a/Src/DasherCore/Parameters.h
+++ b/Src/DasherCore/Parameters.h
@@ -65,7 +65,7 @@ enum {
LP_DYNAMIC_BUTTON_LAG, LP_STATIC1B_TIME, LP_STATIC1B_ZOOM,
LP_DEMO_SPRING, LP_DEMO_NOISE_MEM, LP_DEMO_NOISE_MAG, LP_MAXZOOM,
LP_DYNAMIC_SPEED_INC, LP_DYNAMIC_SPEED_FREQ, LP_DYNAMIC_SPEED_DEC,
- LP_TAP_TIME, END_OF_LPS
+ LP_TAP_TIME, LP_MARGIN_WIDTH, END_OF_LPS
};
enum {
@@ -237,6 +237,7 @@ static lp_table longparamtable[] = {
{LP_DYNAMIC_SPEED_FREQ, "DynamicSpeedFreq", PERS, 10, "Seconds after which dynamic mode auto speed control increases speed"},
{LP_DYNAMIC_SPEED_DEC, "DynamicSpeedDec", PERS, 8, "%age by which dynamic mode auto speed control decreases speed on reverse"},
{LP_TAP_TIME, "TapTime", PERS, 200, "Max length of a stylus 'tap' rather than hold (ms)"},
+ {LP_MARGIN_WIDTH, "MarginWidth", PERS, 300, "Width of RHS margin (in Dasher co-ords)"},
};
static sp_table stringparamtable[] = {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]