From 8dfea16fe399a8496a0dcdaf60d01f6c9c35b009 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Wed, 19 May 2010 13:59:36 +0000 Subject: [PATCH] The transformation of the gradient used by the GradientControl is always set to the current transformation of the style's gradient, in order to never accidentally change that transformation while using assignment and comparison operators for convenience. However when resetting the transformation in the notification hook, it could lead to reentering the hook unnecessarily and even busy looping (thanks to Mark Erben for providing such an icon). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36865 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/icon-o-matic/gui/StyleView.cpp | 34 +++++++++++++++---------- src/apps/icon-o-matic/gui/StyleView.h | 1 + 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/apps/icon-o-matic/gui/StyleView.cpp b/src/apps/icon-o-matic/gui/StyleView.cpp index d79781b266..08704a5820 100644 --- a/src/apps/icon-o-matic/gui/StyleView.cpp +++ b/src/apps/icon-o-matic/gui/StyleView.cpp @@ -31,6 +31,7 @@ #include "SetGradientCommand.h" #include "Style.h" + using std::nothrow; enum { @@ -47,17 +48,19 @@ enum { // constructor StyleView::StyleView(BRect frame) + : #ifdef __HAIKU__ - : BView("style view", 0), + BView("style view", 0), #else - : BView(frame, "style view", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_FRAME_EVENTS), + BView(frame, "style view", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_FRAME_EVENTS), #endif - fCommandStack(NULL), - fCurrentColor(NULL), - fStyle(NULL), - fGradient(NULL), - fIgnoreCurrentColorNotifications(false), - fPreviousBounds(frame.OffsetToCopy(B_ORIGIN)) + fCommandStack(NULL), + fCurrentColor(NULL), + fStyle(NULL), + fGradient(NULL), + fIgnoreCurrentColorNotifications(false), + fIgnoreControlGradientNotifications(false), + fPreviousBounds(frame.OffsetToCopy(B_ORIGIN)) { SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); @@ -261,13 +264,16 @@ StyleView::ObjectChanged(const Observable* object) if (object == controlGradient) { if (!fGradient) return; - - // make sure we don't fall for changes of the - // transformation - // TODO: is this really necessary? - controlGradient->SetTransform(*fGradient); + if (fIgnoreControlGradientNotifications) + return; + fIgnoreControlGradientNotifications = true; if (!fGradient->ColorStepsAreEqual(*controlGradient)) { + // Make sure we never apply the transformation from the control + // gradient to the style gradient. Setting this here would cause to + // re-enter ObjectChanged(), which is prevented to cause harm via + // fIgnoreControlGradientNotifications. + controlGradient->SetTransform(*fGradient); if (fCommandStack) { fCommandStack->Perform( new (nothrow) SetGradientCommand( @@ -278,6 +284,8 @@ StyleView::ObjectChanged(const Observable* object) // transfer the current gradient color to the current color _TransferGradientStopColor(); } + + fIgnoreControlGradientNotifications = false; } else if (object == fGradient) { if (!fGradient->ColorStepsAreEqual(*controlGradient)) { fGradientControl->SetGradient(fGradient); diff --git a/src/apps/icon-o-matic/gui/StyleView.h b/src/apps/icon-o-matic/gui/StyleView.h index 96f5b04b0b..d22813f08a 100644 --- a/src/apps/icon-o-matic/gui/StyleView.h +++ b/src/apps/icon-o-matic/gui/StyleView.h @@ -75,6 +75,7 @@ class StyleView : public BView, Style* fStyle; Gradient* fGradient; bool fIgnoreCurrentColorNotifications; + bool fIgnoreControlGradientNotifications; GradientControl* fGradientControl; BMenuField* fStyleType;