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

[XaraXtreme-commits] Commit Complete



Commit by  : phil
Repository : xara
Revision   : 1236
Date       : Thu Jun  1 15:35:00 BST 2006

Changed paths:
   M /Trunk/XaraLX/wxOil/camview.cpp
   M /Trunk/XaraLX/wxOil/camview.h
   M /Trunk/XaraLX/wxOil/scrvw.cpp

Removed old partial checks of ScrollOffset validity and replaced by a full check within CCamView::SetScrollOffset since Scrollers themselves no longer seem to check. Prevents scrollbar overruns and ERROR3 reports in various situations.


Diff:
Index: Trunk/XaraLX/wxOil/scrvw.cpp
===================================================================
--- Trunk/XaraLX/wxOil/scrvw.cpp	(revision 1235)
+++ Trunk/XaraLX/wxOil/scrvw.cpp	(revision 1236)
@@ -3260,18 +3260,6 @@
 		offset.x += dx * PixelWidth;
 		offset.y -= dy * PixelHeight;
 			
-		// Check that we are not attempting to scroll past the bounds of the
-		// work area.
-		if (offset.x < Status->WorkAreaExtent.lo.x)
-			offset.x = Status->WorkAreaExtent.lo.x;
-		else if (offset.x > Status->WorkAreaExtent.hi.x)
-			offset.x = Status->WorkAreaExtent.hi.x;
-			
-		if (offset.y < Status->WorkAreaExtent.lo.y)
-			offset.y = Status->WorkAreaExtent.lo.y;
-		else if (offset.y > Status->WorkAreaExtent.hi.y)
-			offset.y = Status->WorkAreaExtent.hi.y;
-			
 		// By calling DocView to do the scroll we give it a chance to remove
 		// any blobbies it might have put on the screen.  Note that the scrollers
 		// will prevent any overscroll.
Index: Trunk/XaraLX/wxOil/camview.h
===================================================================
--- Trunk/XaraLX/wxOil/camview.h	(revision 1235)
+++ Trunk/XaraLX/wxOil/camview.h	(revision 1236)
@@ -267,6 +267,7 @@
 	void SetScrollOffset(const WorkCoord& pos, BOOL redraw = TRUE);
 	void ShowScrollers(BOOL Show); 
 	void ShowRulers(BOOL Show);
+	WorkRect GetMaxScrollRect() const;
 
 	BOOL AreRulersVisible();
 	BOOL AreScrollersVisible();
Index: Trunk/XaraLX/wxOil/camview.cpp
===================================================================
--- Trunk/XaraLX/wxOil/camview.cpp	(revision 1235)
+++ Trunk/XaraLX/wxOil/camview.cpp	(revision 1236)
@@ -1185,8 +1185,16 @@
 	FIXED16 PixelWidth,PixelHeight;
 	pDocView->GetPixelSize(&PixelWidth,&PixelHeight);
 
-	INT32 sx = INT32((pos.x-WorkArea.lo.x)/PixelWidth .MakeDouble());
-	INT32 sy = INT32((WorkArea.hi.y-pos.y)/PixelHeight.MakeDouble());
+	// Validate suggested ScrollOffset...
+	WorkCoord tpos = pos;
+	WorkRect wrScrollRect = GetMaxScrollRect();
+	if (tpos.x < wrScrollRect.lo.x)	tpos.x = wrScrollRect.lo.x;
+	if (tpos.y < wrScrollRect.lo.y)	tpos.y = wrScrollRect.lo.y;
+	if (tpos.x > wrScrollRect.hi.x)	tpos.x = wrScrollRect.hi.x;
+	if (tpos.y > wrScrollRect.hi.y)	tpos.y = wrScrollRect.hi.y;
+
+	INT32 sx = INT32((tpos.x-WorkArea.lo.x)/PixelWidth .MakeDouble());
+	INT32 sy = INT32((WorkArea.hi.y-tpos.y)/PixelHeight.MakeDouble());
 //	TRACEUSER("Gerry", _T("Scrolling to (%d, %d)
"), sx, sy);
 
 	HScrollBar->SetThumbPosition(sx);
@@ -3980,31 +3988,48 @@
 	offset.y -= dy * PixelHeight;
 //	TRACEUSER("Gerry", _T("NewOffset = (%d, %d)
"), (INT32)offset.x, (INT32)offset.y);
 
+	// By calling DocView to do the scroll we give it a chance to remove
+	// any blobbies it might have put on the screen.  Note that the scrollers
+	// will prevent any overscroll.
+	pDocView->SetScrollOffsets(offset, TRUE);
+}
+
+
+/********************************************************************************************
+>	WorkRect CCamView::GetMaxScrollRect() const
+
+	Author:		Phil_Martin (Xara Group Ltd) <camelotdev@xxxxxxxx>
+	Created:	31/May/2006
+	Inputs:		-
+	Outputs:	-
+	Returns:	WorkRect describing legal area for scroll offsets
+	Purpose:	Find the legal area in which scroll offsets can exist
+	Errors:		-
+	SeeAlso:	-
+********************************************************************************************/
+
+WorkRect CCamView::GetMaxScrollRect() const
+{
+	WorkRect wrScrollRect = Status->WorkAreaExtent;
+
+	FIXED16 PixelWidth, PixelHeight;
+	pDocView->GetPixelSize(&PixelWidth, &PixelHeight);
+
 	WorkCoord WindowSize;
 	WindowSize.x = CurrentSize.GetWidth() * PixelWidth;
 	WindowSize.y = CurrentSize.GetHeight() * PixelHeight;
 
-//	TRACEUSER("Gerry", _T("WorkArea = (%d, %d)
"), (INT32)Status->WorkAreaExtent.hi.x, (INT32)Status->WorkAreaExtent.lo.y);
-//	TRACEUSER("Gerry", _T("WindowSize = (%d, %d)
"), (INT32)WindowSize.x, (INT32)WindowSize.y);
+	if (WindowSize.x > wrScrollRect.hi.x)		// If window wider than document
+		wrScrollRect.hi.x = wrScrollRect.lo.x;	// no horz scrolling is possible
+	else
+		wrScrollRect.hi.x -= WindowSize.x;		// Restrict scrollable area to ensure view never sees outside workarea
 
-	// Check that we are not attempting to scroll past the bounds of the
-	// work area.
-	if (offset.x < Status->WorkAreaExtent.lo.x)
-		offset.x = Status->WorkAreaExtent.lo.x;
-	else if (offset.x > (Status->WorkAreaExtent.hi.x - WindowSize.x))
-		offset.x = Status->WorkAreaExtent.hi.x - WindowSize.x;
+	if (WindowSize.y < wrScrollRect.lo.y)		// If window wider than document
+		wrScrollRect.lo.y = wrScrollRect.hi.y;	// no vert scrolling is possible
+	else
+		wrScrollRect.lo.y += WindowSize.y;		// Restrict scrollable area to ensure view never sees outside workarea
 
-	if (offset.y < (Status->WorkAreaExtent.lo.y + WindowSize.y))
-		offset.y = Status->WorkAreaExtent.lo.y + WindowSize.y;
-	else if (offset.y > Status->WorkAreaExtent.hi.y)
-		offset.y = Status->WorkAreaExtent.hi.y;
-
-//	TRACEUSER("Gerry", _T("SetOffset = (%d, %d)
"), (INT32)offset.x, (INT32)offset.y);
-
-	// By calling DocView to do the scroll we give it a chance to remove
-	// any blobbies it might have put on the screen.  Note that the scrollers
-	// will prevent any overscroll.
-	pDocView->SetScrollOffsets(offset, TRUE);
+	return wrScrollRect;
 }
 
 


Xara