From cc1d9fb0feaa85a03bb7cf61484990114955b36a Mon Sep 17 00:00:00 2001 From: Zardshard <0azrune6@zard.anonaddy.com> Date: Tue, 7 Mar 2023 13:57:54 -0500 Subject: [PATCH] Icon-O-Matic: Refactor code slightly * The condition in TransformBox::MouseOver is always true (hint: _DragStateFor never returns a null value) * The code sometimes calls fCurrentState->UpdateViewCursor twice Change-Id: I073203278fc103f5ee720dfbe06bf1f04f48c99f Reviewed-on: https://review.haiku-os.org/c/haiku/+/6179 Tested-by: Automation Reviewed-by: Adrien Destugues --- .../transformable/TransformBox.cpp | 24 ++++--------------- .../icon-o-matic/transformable/TransformBox.h | 2 -- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/src/apps/icon-o-matic/transformable/TransformBox.cpp b/src/apps/icon-o-matic/transformable/TransformBox.cpp index c3e96f07dc..1f0925fc8e 100644 --- a/src/apps/icon-o-matic/transformable/TransformBox.cpp +++ b/src/apps/icon-o-matic/transformable/TransformBox.cpp @@ -201,13 +201,11 @@ TransformBox::MouseOver(BPoint where) { TransformToCanvas(where); - _SetState(_DragStateFor(where, ZoomLevel())); fMousePos = where; - if (fCurrentState) { - fCurrentState->UpdateViewCursor(fView, fMousePos); - return true; - } - return false; + fCurrentState = _DragStateFor(where, ZoomLevel()); + fCurrentState->UpdateViewCursor(fView, fMousePos); + + return true; } @@ -725,17 +723,3 @@ TransformBox::_NotifyDeleted() const } } - -// #pragma mark - - - -// _SetState -void -TransformBox::_SetState(DragState* state) -{ - if (state != fCurrentState) { - fCurrentState = state; - fCurrentState->UpdateViewCursor(fView, fMousePos); - } -} - diff --git a/src/apps/icon-o-matic/transformable/TransformBox.h b/src/apps/icon-o-matic/transformable/TransformBox.h index 140c3c9a49..3af867be45 100644 --- a/src/apps/icon-o-matic/transformable/TransformBox.h +++ b/src/apps/icon-o-matic/transformable/TransformBox.h @@ -125,8 +125,6 @@ class TransformBox : public ChannelTransform, void _NotifyDeleted() const; // "static" state objects - void _SetState(DragState* state); - StateView* fView; DragState* fDragLTState;