From fa7194b129a9fc3236943ee1febf231337ad1101 Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Sun, 20 Feb 2011 18:03:14 +0000 Subject: [PATCH] Make game list tooltips work on linux. The HitTest subitem parameter is not implemented on non wxMSW so just use the entire item. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7210 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/DolphinWX/Src/GameListCtrl.cpp | 34 +++++++++++++++++----- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/Source/Core/DolphinWX/Src/GameListCtrl.cpp b/Source/Core/DolphinWX/Src/GameListCtrl.cpp index a145903f52..1e24c19c07 100644 --- a/Source/Core/DolphinWX/Src/GameListCtrl.cpp +++ b/Source/Core/DolphinWX/Src/GameListCtrl.cpp @@ -882,10 +882,15 @@ void CGameListCtrl::OnMouseMotion(wxMouseEvent& event) if (item != wxNOT_FOUND) { +#ifndef __WXGTK__ + // The subitem parameter of HitTest is only implemented for wxMSW. On + // all other platforms it will always be -1. if (subitem == COLUMN_EMULATION_STATE) +#endif { if (toolTip || lastItem == item || this != FindFocus()) { + if (!toolTip) lastItem = -1; event.Skip(); return; } @@ -910,13 +915,6 @@ void CGameListCtrl::OnMouseMotion(wxMouseEvent& event) ini.Get("EmuState", "EmulationStateId", &nState); ini.Get("EmuState", "EmulationIssues", &issues, ""); - // Get item Coords then convert from wxWindow coord to Screen coord - wxRect Rect; - this->GetItemRect(item, Rect); - int mx = Rect.GetWidth(); - int my = Rect.GetY(); - this->ClientToScreen(&mx, &my); - // Show a tooltip containing the EmuState and the state description if (nState > 0 && nState < 6) { @@ -928,14 +926,36 @@ void CGameListCtrl::OnMouseMotion(wxMouseEvent& event) else toolTip = new wxEmuStateTip(this, _("Not Set"), &toolTip); + // Get item Coords + wxRect Rect; + GetItemRect(item, Rect); +#ifdef _WIN32 + int mx = Rect.GetWidth(); + int my = Rect.GetY(); + ClientToScreen(&mx, &my); toolTip->SetBoundingRect(wxRect(mx - GetColumnWidth(subitem), my, GetColumnWidth(subitem), Rect.GetHeight())); toolTip->SetPosition(wxPoint(mx - GetColumnWidth(subitem), my - 5 + Rect.GetHeight())); +#elif defined __WXGTK__ + // TODO: This works on OSX too, but something weird happens + // when the mouse is over the header row. + int x = Rect.GetX(), y = Rect.GetY(), + w = Rect.GetWidth(), h = Rect.GetHeight(); + // For some reason the y position does not account for the header + // row, so subtract the y position of the first visible item. + GetItemRect(GetTopItem(), Rect); + y -= Rect.GetY(); + ClientToScreen(&x, &y); + toolTip->SetBoundingRect(wxRect(x, y, w, h)); + toolTip->SetPosition(wxPoint(x + w, y + h / 2)); +#endif lastItem = item; } } + else + lastItem = -1; event.Skip(); }