From 7f7f5eac6ea9054b982e22e261121921b640b60f Mon Sep 17 00:00:00 2001 From: John Scipione Date: Wed, 2 May 2012 23:51:49 -0400 Subject: [PATCH] Refactor ToolTipManager a bit. * Change ShowTip() point parameter name to where. * Add a parameterless ResetWindowFrame() overload that get's the current where and calls ResetWindowFrame(BPoint where) which does the actual work. FrameResized() calls this parameterless ResetWindowFrame() method instead of doing the work in that method. This is functionaly the same but allows me to call the parameterless ResetWindowFrame() elsewhere. --- headers/private/interface/ToolTipManager.h | 2 +- src/kits/interface/ToolTipManager.cpp | 21 +++++++++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/headers/private/interface/ToolTipManager.h b/headers/private/interface/ToolTipManager.h index bfd863fb48..7eca0fc51b 100644 --- a/headers/private/interface/ToolTipManager.h +++ b/headers/private/interface/ToolTipManager.h @@ -18,7 +18,7 @@ class BToolTipManager { public: static BToolTipManager* Manager(); - void ShowTip(BToolTip* tip, BPoint point, + void ShowTip(BToolTip* tip, BPoint where, void* owner); void HideTip(); diff --git a/src/kits/interface/ToolTipManager.cpp b/src/kits/interface/ToolTipManager.cpp index 6a57bfeb28..918ad0ac23 100644 --- a/src/kits/interface/ToolTipManager.cpp +++ b/src/kits/interface/ToolTipManager.cpp @@ -46,6 +46,8 @@ public: void HideTip(); void ShowTip(); + + void ResetWindowFrame(); void ResetWindowFrame(BPoint where); BToolTip* Tip() const { return fToolTip; } @@ -105,10 +107,7 @@ ToolTipView::DetachedFromWindow() void ToolTipView::FrameResized(float width, float height) { - BPoint where; - GetMouse(&where, NULL, false); - - ResetWindowFrame(ConvertToScreen(where)); + ResetWindowFrame(); } @@ -156,6 +155,16 @@ ToolTipView::ShowTip() } +void +ToolTipView::ResetWindowFrame() +{ + BPoint where; + GetMouse(&where, NULL, false); + + ResetWindowFrame(ConvertToScreen(where)); +} + + /*! Tries to find the right frame to show the tool tip in, trying to use the alignment that the tool tip specifies. Makes sure the tool tip can be shown on screen in its entirety, ie. it will @@ -366,7 +375,7 @@ BToolTipManager::Manager() void -BToolTipManager::ShowTip(BToolTip* tip, BPoint point, void* owner) +BToolTipManager::ShowTip(BToolTip* tip, BPoint where, void* owner) { BToolTip* current = NULL; void* currentOwner = NULL; @@ -388,7 +397,7 @@ BToolTipManager::ShowTip(BToolTip* tip, BPoint point, void* owner) fWindow.SendMessage(kMsgHideToolTip); if (tip != NULL) { - BWindow* window = new BPrivate::ToolTipWindow(tip, point, owner); + BWindow* window = new BPrivate::ToolTipWindow(tip, where, owner); window->Show(); fWindow = BMessenger(window);