From 69961956bfae1529e6c451c57804b0d2aa93f422 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Fri, 7 Jun 2013 20:13:18 -0400 Subject: [PATCH] fix ToolTips on split buttons not working correctly (button overrode them), fix tooltips displaying on disabled buttons --- src/gui/game/GameView.cpp | 53 ++++++++++++++++-------------------- src/gui/interface/Button.cpp | 2 +- 2 files changed, 25 insertions(+), 30 deletions(-) diff --git a/src/gui/game/GameView.cpp b/src/gui/game/GameView.cpp index ca4272cc4..08387e757 100644 --- a/src/gui/game/GameView.cpp +++ b/src/gui/game/GameView.cpp @@ -51,6 +51,23 @@ public: void SetShowSplit(bool split) { showSplit = split; } SplitButtonAction * GetSplitActionCallback() { return splitActionCallback; } void SetSplitActionCallback(SplitButtonAction * newAction) { splitActionCallback = newAction; } + void SetToolTip(int x, int y) + { + if(x >= splitPosition || !showSplit) + { + if(toolTip2.length()>0 && GetParentWindow()) + { + GetParentWindow()->ToolTip(this, ui::Point(x, y), toolTip2); + } + } + else if(x < splitPosition) + { + if(toolTip.length()>0 && GetParentWindow()) + { + GetParentWindow()->ToolTip(this, ui::Point(x, y), toolTip); + } + } + } virtual void OnMouseUnclick(int x, int y, unsigned int button) { if(isButtonDown) @@ -63,42 +80,20 @@ public: ui::Button::OnMouseUnclick(x, y, button); } - virtual void OnMouseMovedInside(int x, int y, int dx, int dy) + virtual void OnMouseHover(int x, int y, int dx, int dy) { - if(x >= splitPosition || !showSplit) - { - if(toolTip.length()>0 && GetParentWindow()) - { - GetParentWindow()->ToolTip(this, ui::Point(x, y), toolTip2); - } - } - else if(x < splitPosition) - { - if(toolTip2.length()>0 && GetParentWindow()) - { - GetParentWindow()->ToolTip(this, ui::Point(x, y), toolTip); - } - } + SetToolTip(x, y); + } + virtual void OnMouseHover(int x, int y) + { + SetToolTip(x, y); } virtual void OnMouseEnter(int x, int y) { isMouseInside = true; if(!Enabled) return; - if(x >= splitPosition || !showSplit) - { - if(toolTip.length()>0 && GetParentWindow()) - { - GetParentWindow()->ToolTip(this, ui::Point(x, y), toolTip2); - } - } - else if(x < splitPosition) - { - if(toolTip2.length()>0 && GetParentWindow()) - { - GetParentWindow()->ToolTip(this, ui::Point(x, y), toolTip); - } - } + SetToolTip(x, y); } virtual void TextPosition() { diff --git a/src/gui/interface/Button.cpp b/src/gui/interface/Button.cpp index 71ec4991f..dd58c1fd5 100644 --- a/src/gui/interface/Button.cpp +++ b/src/gui/interface/Button.cpp @@ -196,7 +196,7 @@ void Button::OnMouseEnter(int x, int y) void Button::OnMouseHover(int x, int y) { - if(toolTip.length()>0 && GetParentWindow()) + if(Enabled && toolTip.length()>0 && GetParentWindow()) { GetParentWindow()->ToolTip(this, ui::Point(x, y), toolTip); }