[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]
[XaraXtreme-commits] Commit Complete
Commit by : alex
Repository : xara
Revision : 960
Date : Fri May 5 15:29:14 BST 2006
Changed paths:
M /Trunk/XaraLX/Kernel/main3.cpp
A /Trunk/XaraLX/testfiles/testsmooth.xar
M /Trunk/XaraLX/wxOil/camview.cpp
M /Trunk/XaraLX/wxOil/camview.h
M /Trunk/XaraLX/wxOil/rendwnd.cpp
M /Trunk/XaraLX/wxOil/rendwnd.h
M /Trunk/XaraLX/wxOil/xpoilflt.cpp
Added mouse movement elimination code. This does NOT fix the freehand tool. It is turned off by default, but can be turned on with an (invisible) preference.
Diff:
Index: Trunk/XaraLX/Kernel/main3.cpp
===================================================================
--- Trunk/XaraLX/Kernel/main3.cpp (revision 959)
+++ Trunk/XaraLX/Kernel/main3.cpp (revision 960)
@@ -236,8 +236,9 @@
ColourDragInformation::Init() &&
BitmapDragInformation::Init() &&
InitDiagnosticPrefs() && // Get the diagnostic preferences
-
+#endif
CCamView::ReadViewPrefs() &&
+#ifndef EXCLUDE_FROM_XARALX
PrintMonitor::InitPrefs() &&
BaseBar::DeclarePreferences() &&
Index: Trunk/XaraLX/testfiles/testsmooth.xar
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: Trunk/XaraLX/testfiles/testsmooth.xar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Index: Trunk/XaraLX/wxOil/rendwnd.cpp
===================================================================
--- Trunk/XaraLX/wxOil/rendwnd.cpp (revision 959)
+++ Trunk/XaraLX/wxOil/rendwnd.cpp (revision 960)
@@ -139,6 +139,8 @@
EVT_MOUSEWHEEL( CRenderWnd::OnMouseWheel )
EVT_SIZE( CRenderWnd::OnSize)
EVT_SET_CURSOR( CRenderWnd::OnSetCursor )
+ EVT_KEY_DOWN( CRenderWnd::OnKey)
+ EVT_KEY_UP( CRenderWnd::OnKey)
#if defined(__WXGTK__)
EVT_ENTER_WINDOW( CRenderWnd::OnEnter )
@@ -368,8 +370,31 @@
#endif
}
+/*********************************************************************************************
+> void CRenderWnd::OnKey( wxKeyEvent & event )
+ Author: Alex Bligh <alex@xxxxxxxxxxx>
+ Created: 4 May 2006
+ Inputs: pointer to the event
+ Outputs: -
+ Returns: -
+ Purpose: THIS DOES NOT PROCESS KEYS. It merely notes a key has been pressed and
+ stops the mouse motion mangler eating the next mouse move
+ Errors: -
+ Scope: Protected
+ SeeAlso: -
+**********************************************************************************************/
+
+void CRenderWnd::OnKey( wxKeyEvent & event )
+{
+ if (m_pView)
+ m_pView->DontSkipNextMouse();
+
+ event.Skip(); // Pass the key event on to someone who really wants it.
+}
+
+
/*********************************************************************************************
> afx_msg void CRenderWnd::OnRButtonDown(UINT32, CPoint)
Index: Trunk/XaraLX/wxOil/xpoilflt.cpp
===================================================================
--- Trunk/XaraLX/wxOil/xpoilflt.cpp (revision 959)
+++ Trunk/XaraLX/wxOil/xpoilflt.cpp (revision 960)
@@ -1001,8 +1001,8 @@
m_pXarStream.p->AddRef();
*ppNewFile = pStreamFile; // Return the new file pointer
+
#endif
-
return(TRUE);
}
Index: Trunk/XaraLX/wxOil/rendwnd.h
===================================================================
--- Trunk/XaraLX/wxOil/rendwnd.h (revision 959)
+++ Trunk/XaraLX/wxOil/rendwnd.h (revision 960)
@@ -170,6 +170,8 @@
void OnLeave( wxMouseEvent &event );
#endif
+ void OnKey ( wxKeyEvent & event);
+
protected:
CCamView* m_pView;
Index: Trunk/XaraLX/wxOil/camview.h
===================================================================
--- Trunk/XaraLX/wxOil/camview.h (revision 959)
+++ Trunk/XaraLX/wxOil/camview.h (revision 960)
@@ -182,6 +182,8 @@
return m_pFrame;
}
+ static BOOL ReadViewPrefs();
+
////////////////////////////////////////////////////////////////////////////////
// Interface to the kernel's view onto a document and MFC's CDocument-derived
// object.
@@ -401,7 +403,14 @@
BOOL OLERecaptureMouse; // Used when OLE drags return to the view window - we resume our
// drag, and we have to recapture the mouse to recover properly.
+ // Mouse move elimination code
+ INT32 m_LastMouseState;
+ wxPoint m_LastMousePosition;
+ INT32 m_LastMouseUsedTimestamp;
+ BOOL m_CouldSkipNextMouse;
+public:
+ void DontSkipNextMouse() {m_CouldSkipNextMouse=FALSE;}
// Static functions
protected:
@@ -435,6 +444,9 @@
static MonotonicTime DragTimer; // Used to time the drag delay above.
static INT32 ScrollBarSize; // Width of the wider of the scroll bars
+
+public:
+ static INT32 s_MouseMoveEliminationPeriod;
};
Index: Trunk/XaraLX/wxOil/camview.cpp
===================================================================
--- Trunk/XaraLX/wxOil/camview.cpp (revision 959)
+++ Trunk/XaraLX/wxOil/camview.cpp (revision 960)
@@ -129,6 +129,8 @@
// drag is initiated.
INT32 CCamView::DragLatency = 3;
+INT32 CCamView::s_MouseMoveEliminationPeriod = 0;
+
// Used to start drags after user has clicked but not moved mouse for n milliseconds.
INT32 CCamView::DragDelay = 500;
MonotonicTime CCamView::DragTimer;
@@ -232,6 +234,13 @@
// Set this flag until we have been through OnActivateView once, after which we can
// include this view in the eat-activating-click system.
fJustCreated = TRUE;
+
+ // Mouse move handling
+ m_LastMouseState=0;
+ m_LastMousePosition=wxDefaultPosition;
+ m_LastMouseUsedTimestamp=0;
+ m_CouldSkipNextMouse=FALSE;
+
}
/*********************************************************************************************
@@ -438,6 +447,53 @@
return true;
}
+/********************************************************************************************
+> static BOOL CCamView::ReadViewPrefs()
+
+ Author: Justin_Flude (Xara Group Ltd) <camelotdev@xxxxxxxx>
+ Created: 26/11/93
+ Inputs: -
+ Outputs: -
+ Returns: TRUE if the .INI file settings were loaded (or created) successfully.
+ Purpose: Tries to load preferences for CCamView, creating them with default values
+ if they don't exist.
+ Errors: -
+ SeeAlso: Application::DeclareSection; Application::DeclarePref
+********************************************************************************************/
+
+BOOL CCamView::ReadViewPrefs()
+{
+ // Declare and load the .INI file settings.
+ BOOL ok = Camelot.DeclareSection(TEXT("Mouse"), 10) &&
+ Camelot.DeclarePref(TEXT("Mouse"), TEXT("DragLatency"),
+ &CCamView::DragLatency, 1, 10) &&
+ Camelot.DeclarePref(TEXT("Mouse"), TEXT("DragDelay"),
+ &CCamView::DragDelay, 100, 2000) &&
+ Camelot.DeclarePref(TEXT("Mouse"), TEXT("MoveEliminationPeriod"),
+ &CCamView::s_MouseMoveEliminationPeriod, 0, 1000) &&
+
+ Camelot.DeclareSection(TEXT("WindowFurniture"), 10) &&
+#ifndef EXCLUDE_FROM_XARALX
+ Camelot.DeclarePref(TEXT("WindowFurniture"), TEXT("PropScrollers"),
+ &CCamView::PropScrollersOn, FALSE, TRUE) &&
+#endif
+ Camelot.DeclarePref(TEXT("WindowFurniture"), TEXT("ScrollersVisibiltyState"),
+ &CCamView::DefaultScrollersState, FALSE, TRUE)&&
+ Camelot.DeclarePref(TEXT("WindowFurniture"), TEXT("RulersVisibiltyState"),
+ &CCamView::DefaultRulersState, FALSE, TRUE) &&
+
+#ifndef EXCLUDE_FROM_XARALX
+ Camelot.DeclareSection(TEXT("Windows"), 10) &&
+ Camelot.DeclarePref(TEXT("Windows"), TEXT("UnzoomOnNewView"),
+ &CCamView::UnzoomOnNewView, FALSE, TRUE) &&
+ Camelot.DeclarePref(TEXT("Windows"), TEXT("ZoomSingleView"),
+ &CCamView::ZoomSingleView, FALSE, TRUE) &&
+#endif
+ TRUE ;
+
+ return ok;
+}
+
///////////////////////////////////////////////////////////////////////////////////////////
// Interface to the kernel's DocView and Document.
@@ -1862,6 +1918,7 @@
void CCamView::OnLButtonDown( wxMouseEvent &event )
{
+ DontSkipNextMouse();
// If the event is not from the RenderWindow then skip it
//TRACEUSER("Phil", _T("OnLButtonDown
"));
INT32 nID = event.GetId();
@@ -1928,6 +1985,7 @@
void CCamView::OnMButtonDown( wxMouseEvent &event )
{
+ DontSkipNextMouse();
// If the event is not from the RenderWindow then skip it
INT32 nID = event.GetId();
if (nID != WID_RENDERWINDOW)
@@ -1969,6 +2027,7 @@
void CCamView::OnRButtonDown( wxMouseEvent &event )
{
+ DontSkipNextMouse();
// If the event is not from the RenderWindow then skip it
INT32 nID = event.GetId();
if (nID != WID_RENDERWINDOW)
@@ -2012,6 +2071,7 @@
void CCamView::OnLButtonUp(wxMouseEvent &event)
{
+ DontSkipNextMouse();
// If the event is not from the RenderWindow then skip it
//TRACEUSER("Phil", _T("OnLButtonUp
"));
INT32 nID = event.GetId();
@@ -2047,6 +2107,7 @@
void CCamView::OnMButtonUp(wxMouseEvent &event)
{
+ DontSkipNextMouse();
// If the event is not from the RenderWindow then skip it
INT32 nID = event.GetId();
if (nID != WID_RENDERWINDOW)
@@ -2081,6 +2142,7 @@
void CCamView::OnRButtonUp( wxMouseEvent &event )
{
+ DontSkipNextMouse();
// If the event is not from the RenderWindow then skip it
INT32 nID = event.GetId();
if (nID != WID_RENDERWINDOW)
@@ -2114,6 +2176,7 @@
void CCamView::OnLButtonDblClk(wxMouseEvent &event)
{
+ DontSkipNextMouse();
// If the event is not from the RenderWindow then skip it
INT32 nID = event.GetId();
if (nID != WID_RENDERWINDOW)
@@ -2167,6 +2230,7 @@
void CCamView::OnMButtonDblClk(wxMouseEvent &event)
{
+ DontSkipNextMouse();
// If the event is not from the RenderWindow then skip it
INT32 nID = event.GetId();
if (nID != WID_RENDERWINDOW)
@@ -2203,6 +2267,7 @@
void CCamView::OnRButtonDblClk( wxMouseEvent &event )
{
+ DontSkipNextMouse();
// If the event is not from the RenderWindow then skip it
INT32 nID = event.GetId();
if (nID != WID_RENDERWINDOW)
@@ -2231,6 +2296,7 @@
void CCamView::OnMouseWheel( wxMouseEvent &event )
{
+ DontSkipNextMouse();
HandleMouseWheelEvent( event );
}
@@ -2289,6 +2355,79 @@
SetCurrentStates();
+ wxMouseState WXCMS = ::wxGetMouseState();
+ wxPoint CurrentMousePosition(WXCMS.GetX(), WXCMS.GetY());
+ // Make a number representing the current button and control key state - we don't use this for anything
+ // other than seeing whether it has changed
+ INT32 CurrentMouseState =
+ (WXCMS.LeftDown() ?1:0) |
+ (WXCMS.MiddleDown() ?2:0) |
+ (WXCMS.RightDown() ?4:0) |
+ (WXCMS.ControlDown()?8:0) |
+ (WXCMS.ShiftDown() ?16:0) |
+ (WXCMS.AltDown() ?32:0) |
+ (WXCMS.MetaDown() ?64:0);
+#if 0
+ TRACEUSER("amb", _T("CCamView:OnMouseMove XY (%d,%d) was (%d,%d) State %2x was %2x"),
+ CurrentMousePosition.x,
+ CurrentMousePosition.y,
+ m_LastMousePosition.x,
+ m_LastMousePosition.y,
+ CurrentMouseState,
+ m_LastMouseState);
+#endif
+ INT32 CurrentTimestamp = event.GetTimestamp();
+
+ BOOL SkipThis = FALSE;
+ // wxWidgets compliant version of the PeekMessage code
+ if (!DragKeepAccuracy && s_MouseMoveEliminationPeriod)
+ {
+ // What the windows version did was look ahead in the message queue for further
+ // mouse moves. We don't have the luxury of that, so we do something slightly
+ // different, which is that we look at where the mouse pointer has gone.
+ // If it's moved, we know another mouse move event will be generated. So there
+ // is the possibility of ignoring this one. We do this if the mouse BUTTON
+ // state has not changed, the new mouse position is over the current window,
+ // and some external event hasn't happened (normally a keypress)
+
+ // If this isn't a motion event or the button state has changed, don't skip this
+ // event, or the next pure move
+ if ((event.GetEventType() != wxEVT_MOTION) || (CurrentMouseState != m_LastMouseState))
+ {
+ // Don't skip the next mouse event and don't skip this one
+ m_CouldSkipNextMouse = FALSE;
+ }
+ else
+ {
+ m_CouldSkipNextMouse = TRUE; // next mouse move is a candidate for skipping
+
+ // we know the buttons are in the same position as before (and the modifiers)
+ // and this is solely a motion event - a candidate to be skipped
+ if (m_CouldSkipNextMouse && (CurrentMousePosition != m_LastMousePosition) /*&& (CurrentMousePosition != event.GetPosition())*/)
+ {
+ // OK, we know the mouse is moving. Insert a point every 20ms regardless
+ if ((CurrentTimestamp - m_LastMouseUsedTimestamp) < s_MouseMoveEliminationPeriod)
+ {
+ SkipThis = TRUE;
+ }
+ }
+ }
+ }
+ else
+ {
+ m_CouldSkipNextMouse = FALSE;
+ }
+
+ m_LastMouseState = CurrentMouseState;
+ m_LastMousePosition = CurrentMousePosition;
+
+ if (SkipThis)
+ {
+ return;
+ }
+
+ m_LastMouseUsedTimestamp = CurrentTimestamp;
+
PORTNOTE("other","Remove PeekMessage related code")
#ifndef EXCLUDE_FROM_XARALX
// Only discard mouse move messages if the initiator of the drag has requested this.
@@ -2773,6 +2912,7 @@
void CCamView::OnDragIdle(wxTimerEvent& event)
{
+ DontSkipNextMouse();
// Ignore if system is disabled
if (CCamApp::IsDisabled())
return; // If the system is disabled, ignore
@@ -4205,3 +4345,4 @@
}
return FALSE;
}
+
Xara