void SectorViewLabelSet::UpdateTooltip() { if (!m_tooltipEnabled || Pi::MouseButtonState(SDL_BUTTON_LEFT) || Pi::MouseButtonState(SDL_BUTTON_RIGHT)) { HideTooltip(); return; } int mouse_pos[2]; float mouse_coords[2]; SDL_GetMouseState(&mouse_pos[0], &mouse_pos[1]); Screen::SDLEventCoordToScreenCoord(mouse_pos[0], mouse_pos[1], &mouse_coords[0], &mouse_coords[1]); bool tooltip_shown = false; for(unsigned int i = 0; i < m_items.size(); ++i) { if (!m_items[i].name.empty() && (fabs(mouse_coords[0] - m_items[i].screenx) < 10.0f) && (fabs(mouse_coords[1] - m_items[i].screeny) < 10.0f)) { ShowTooltip(m_items[i].name, m_items[i].type, m_items[i].desc, m_items[i].screenx, m_items[i].screeny); tooltip_shown = true; break; } } if (m_tooltipDesc && !tooltip_shown) { HideTooltip(); } }
void CParamTooltipCtrl::ShowPrevParam() { if( 0 == m_nCurParam ) return; ShowWindow(SW_HIDE); m_nCurParam--; ShowTooltip(m_ptOldClient); }
void CParamTooltipCtrl::ShowNextParam() { if( m_nCurParam == m_setMethods[m_nCurMethod].m_setParams.size()-1 ) return; ShowWindow(SW_HIDE); m_nCurParam++; ShowTooltip(m_ptOldClient); }
void CParamTooltipCtrl::ShowPrevMethod() { ShowWindow(SW_HIDE); m_nCurMethod--; if( m_nCurMethod < 0 ) m_nCurMethod = (int)(m_setMethods.size())-1; m_nCurParam = 0; ShowTooltip(m_ptOldClient); }
void CParamTooltipCtrl::ShowNextMethod() { ShowWindow(SW_HIDE); m_nCurMethod++; if( m_nCurMethod == m_setMethods.size() ) m_nCurMethod = 0; m_nCurParam = 0; ShowTooltip(m_ptOldClient); }
bool ctrlImage::Msg_MouseMove(const MouseCoords& mc) { // gültiges Bild? if(GetImage()) { // Jeweils Tooltip ein- und ausblenden, wenn die Maus über dem Bild ist if(IsPointInRect(mc.GetPos(), Rect::move(GetImageRect(), GetDrawPos()))) ShowTooltip(); else HideTooltip(); } return false; }
void ctrlBaseTooltip::ShowTooltip() const { ShowTooltip(tooltip_); }
void GUITooltip::Update(IGUIObject* Nearest, CPos MousePos, CGUI* GUI) { // Called once per frame, so efficiency isn't vital double now = timer_Time(); CStr style; int nextstate = -1; switch (m_State) { case ST_IN_MOTION: if (MousePos == m_PreviousMousePos) { if (GetTooltip(Nearest, style)) nextstate = ST_STATIONARY_TOOLTIP; else nextstate = ST_STATIONARY_NO_TOOLTIP; } else { // Check for movement onto a zero-delayed tooltip if (GetTooltip(Nearest, style) && GetTooltipDelay(style, GUI)==0) { // Reset any previous tooltips completely //m_Time = now + (double)GetTooltipDelay(style, GUI) / 1000.; HideTooltip(m_PreviousTooltipName, GUI); nextstate = ST_SHOWING; } } break; case ST_STATIONARY_NO_TOOLTIP: if (MousePos != m_PreviousMousePos) nextstate = ST_IN_MOTION; break; case ST_STATIONARY_TOOLTIP: if (MousePos != m_PreviousMousePos) nextstate = ST_IN_MOTION; else if (now >= m_Time) { // Make sure the tooltip still exists if (GetTooltip(Nearest, style)) nextstate = ST_SHOWING; else { // Failed to retrieve style - the object has probably been // altered, so just restart the process nextstate = ST_IN_MOTION; } } break; case ST_SHOWING: // Handle special case of icon tooltips if (Nearest == m_PreviousObject && (!m_IsIconTooltip || Nearest->MouseOverIcon())) { // Still showing the same object's tooltip, but the text might have changed if (GetTooltip(Nearest, style)) ShowTooltip(Nearest, MousePos, style, GUI); } else { // Mouse moved onto a new object if (GetTooltip(Nearest, style)) { CStr style_old; // If we're displaying a tooltip with no delay, then we want to // reset so that other object that should have delay can't // "ride this tail", it have to wait. // Notice that this doesn't apply to when you go from one delay=0 // to another delay=0 if (GetTooltip(m_PreviousObject, style_old) && GetTooltipDelay(style_old, GUI)==0 && GetTooltipDelay(style, GUI)!=0) { HideTooltip(m_PreviousTooltipName, GUI); nextstate = ST_IN_MOTION; } else { // Hide old scrollbar HideTooltip(m_PreviousTooltipName, GUI); nextstate = ST_SHOWING; } } else { nextstate = ST_COOLING; } } break; case ST_COOLING: if (GetTooltip(Nearest, style)) nextstate = ST_SHOWING; else if (now >= m_Time) nextstate = ST_IN_MOTION; break; } // Handle state-entry code: if (nextstate != -1) { switch (nextstate) { case ST_STATIONARY_TOOLTIP: m_Time = now + (double)GetTooltipDelay(style, GUI) / 1000.; break; case ST_SHOWING: ShowTooltip(Nearest, MousePos, style, GUI); m_PreviousTooltipName = style; break; case ST_COOLING: HideTooltip(m_PreviousTooltipName, GUI); m_Time = now + CooldownTime; break; } m_State = nextstate; } m_PreviousMousePos = MousePos; m_PreviousObject = Nearest; }