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.
This commit is contained in:
John Scipione 2012-05-02 23:51:49 -04:00
parent dc05c262ac
commit 7f7f5eac6e
2 changed files with 16 additions and 7 deletions

View File

@ -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();

View File

@ -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);