[Haiku-commits] r31316 - in haiku/trunk: headers/os/interface src/kits/interface

bonefish at mail.berlios.de bonefish at mail.berlios.de
Mon Jun 29 16:18:14 CEST 2009


Author: bonefish
Date: 2009-06-29 16:18:12 +0200 (Mon, 29 Jun 2009)
New Revision: 31316
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31316&view=rev

Modified:
   haiku/trunk/headers/os/interface/View.h
   haiku/trunk/src/kits/interface/CardLayout.cpp
   haiku/trunk/src/kits/interface/SplitLayout.cpp
   haiku/trunk/src/kits/interface/TwoDimensionalLayout.cpp
   haiku/trunk/src/kits/interface/View.cpp
Log:
After the first call to BView::InvalidateLayout() further invocations don't
invoke the layout's InvalidateLayout() anymore. This could cause problems when
the layout caches layout related information and also updates those on calls
other than LayoutView(). A call to such a method after an InvalidateLayout()
would mark the cached info valid and the layout would use the cached info
until the first InvalidateLayout() after the next LayoutView(), even if
BView::InvalidateLayout() had been called again in the meantime.

* Introduced a new method BView::ResetLayoutInvalidation(), which must be
  called by layout implementations whenever they have updated their cached
  information and need further InvalidateLayout() notifications.
* Adjusted the existing layout implementations to use the method.

Fixes bug #4047.


Modified: haiku/trunk/headers/os/interface/View.h
===================================================================
--- haiku/trunk/headers/os/interface/View.h	2009-06-29 11:49:57 UTC (rev 31315)
+++ haiku/trunk/headers/os/interface/View.h	2009-06-29 14:18:12 UTC (rev 31316)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2001-2006, Haiku.
+ * Copyright 2001-2009, Haiku.
  * Distributed under the terms of the MIT License.
  *
  * Authors:
@@ -532,6 +532,7 @@
 			void			EnableLayoutInvalidation();
 			void			DisableLayoutInvalidation();
 			bool			IsLayoutValid() const;
+			void			ResetLayoutInvalidation();
 
 			BLayoutContext*	LayoutContext() const;
 

Modified: haiku/trunk/src/kits/interface/CardLayout.cpp
===================================================================
--- haiku/trunk/src/kits/interface/CardLayout.cpp	2009-06-29 11:49:57 UTC (rev 31315)
+++ haiku/trunk/src/kits/interface/CardLayout.cpp	2009-06-29 14:18:12 UTC (rev 31316)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2006, Ingo Weinhold <bonefish at cs.tu-berlin.de>.
+ * Copyright 2006-2009, Ingo Weinhold <ingo_weinhold at gmx.de>.
  * All rights reserved. Distributed under the terms of the MIT License.
  */
 
@@ -54,7 +54,7 @@
 
 	if (item != NULL && IndexOfItem(item) < 0)
 		return;
-	
+
 	if (fVisibleItem != NULL)
 		fVisibleItem->SetVisible(false);
 
@@ -107,7 +107,7 @@
 		if (ItemAt(i)->HasHeightForWidth())
 			return true;
 	}
-	
+
 	return false;
 }
 
@@ -157,7 +157,7 @@
 BCardLayout::InvalidateLayout()
 {
 	BLayout::InvalidateLayout();
-	
+
 	fMinMaxValid = false;
 }
 
@@ -231,6 +231,9 @@
 	fPreferred.height = max_c(fPreferred.height, fMin.height);
 	fPreferred.width = min_c(fPreferred.width, fMax.width);
 	fPreferred.height = min_c(fPreferred.height, fMax.height);
-	
+
 	fMinMaxValid = true;
+
+	if (BView* view = View())
+		view->ResetLayoutInvalidation();
 }

Modified: haiku/trunk/src/kits/interface/SplitLayout.cpp
===================================================================
--- haiku/trunk/src/kits/interface/SplitLayout.cpp	2009-06-29 11:49:57 UTC (rev 31315)
+++ haiku/trunk/src/kits/interface/SplitLayout.cpp	2009-06-29 14:18:12 UTC (rev 31316)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2006, Ingo Weinhold <bonefish at cs.tu-berlin.de>.
+ * Copyright 2006-2009, Ingo Weinhold <ingo_weinhold at gmx.de>.
  * All rights reserved. Distributed under the terms of the MIT License.
  */
 
@@ -1147,6 +1147,9 @@
 	fHorizontalLayoutInfo = fHorizontalLayouter->CreateLayoutInfo();
 	if (fHeightForWidthItems.IsEmpty())
 		fVerticalLayoutInfo = fVerticalLayouter->CreateLayoutInfo();
+
+	if (BView* view = View())
+		view->ResetLayoutInvalidation();
 }
 
 // _InternalGetHeightForWidth

Modified: haiku/trunk/src/kits/interface/TwoDimensionalLayout.cpp
===================================================================
--- haiku/trunk/src/kits/interface/TwoDimensionalLayout.cpp	2009-06-29 11:49:57 UTC (rev 31315)
+++ haiku/trunk/src/kits/interface/TwoDimensionalLayout.cpp	2009-06-29 14:18:12 UTC (rev 31316)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2006, Ingo Weinhold <bonefish at cs.tu-berlin.de>.
+ * Copyright 2006-2009, Ingo Weinhold <ingo_weinhold at gmx.de>.
  * All rights reserved. Distributed under the terms of the MIT License.
  */
 
@@ -448,6 +448,9 @@
 BTwoDimensionalLayout::_ValidateMinMax()
 {
 	fLocalLayouter->ValidateMinMax();
+
+	if (BView* view = View())
+		view->ResetLayoutInvalidation();
 }
 
 // _CurrentLayoutContext

Modified: haiku/trunk/src/kits/interface/View.cpp
===================================================================
--- haiku/trunk/src/kits/interface/View.cpp	2009-06-29 11:49:57 UTC (rev 31315)
+++ haiku/trunk/src/kits/interface/View.cpp	2009-06-29 14:18:12 UTC (rev 31316)
@@ -6,7 +6,7 @@
  *		Adrian Oanca <adioanca at cotty.iren.ro>
  *		Axel Dörfler, axeld at pinc-software.de
  *		Stephan Aßmus <superstippi at gmx.de>
- *		Ingo Weinhold <bonefish at cs.tu-berlin.de>
+ *		Ingo Weinhold <ingo_weinhold at gmx.de>
  */
 
 #include <View.h>
@@ -323,7 +323,8 @@
 		fLayoutInvalidationDisabled(0),
 		fLayout(NULL),
 		fLayoutContext(NULL),
-		fLayoutValid(true),		// <- TODO: Rethink this!
+		fLayoutValid(true),		// TODO: Rethink these initial values!
+		fMinMaxValid(true),		//
 		fLayoutInProgress(false),
 		fNeedsRelayout(true)
 	{
@@ -337,6 +338,7 @@
 	BLayout*		fLayout;
 	BLayoutContext*	fLayoutContext;
 	bool			fLayoutValid;
+	bool			fMinMaxValid;
 	bool			fLayoutInProgress;
 	bool			fNeedsRelayout;
 };
@@ -4489,12 +4491,13 @@
 void
 BView::InvalidateLayout(bool descendants)
 {
-	if (fLayoutData->fLayoutValid && !fLayoutData->fLayoutInProgress
+	if (fLayoutData->fMinMaxValid && !fLayoutData->fLayoutInProgress
 		&& fLayoutData->fLayoutInvalidationDisabled == 0) {
-		if (fParent && fParent->fLayoutData->fLayoutValid)
+		if (fParent && fParent->fLayoutData->fMinMaxValid)
 			fParent->InvalidateLayout(false);
 
 		fLayoutData->fLayoutValid = false;
+		fLayoutData->fMinMaxValid = false;
 
 		if (fLayoutData->fLayout)
 			fLayoutData->fLayout->InvalidateLayout();
@@ -4536,6 +4539,25 @@
 }
 
 
+/*!	\brief Service call for BLayout derived classes reenabling
+	InvalidateLayout() notifications.
+	BView::InvalidateLayout() invokes InvalidateLayout() on its layout the first
+	time, but suppresses further calls until Layout()/Relayout() has been
+	invoked. This method will reenable the notification for the next call of
+	BView::InvalidateLayout().
+
+	If the layout caches internal layout information and updates those
+	information also in methods other than LayoutView(), it has to invoke this
+	method, when it has done so, since otherwise the information might become
+	obsolete without the layout noticing.
+*/
+void
+BView::ResetLayoutInvalidation()
+{
+	fLayoutData->fMinMaxValid = true;
+}
+
+
 BLayoutContext*
 BView::LayoutContext() const
 {
@@ -4594,6 +4616,7 @@
 		fLayoutData->fLayoutInProgress = false;
 
 		fLayoutData->fLayoutValid = true;
+		fLayoutData->fMinMaxValid = true;
 		fLayoutData->fNeedsRelayout = false;
 
 		// layout children




More information about the Haiku-commits mailing list