Skip to content

Commit

Permalink
Optimized speed of adding hotspots
Browse files Browse the repository at this point in the history
  • Loading branch information
nickgammon committed Jun 25, 2016
1 parent 94ff377 commit bd54a9d
Showing 1 changed file with 31 additions and 19 deletions.
50 changes: 31 additions & 19 deletions scripting/methods/methods_miniwindows.cpp
Expand Up @@ -546,6 +546,8 @@ long CMUSHclientDoc::WindowAddHotspot(LPCTSTR Name,
if (it == m_MiniWindows.end ())
return eNoSuchWindow;

CMiniWindow * mw = it->second;

static bool bInWindowAddHotspot = false;

// don't recurse into infinite loops
Expand All @@ -561,29 +563,39 @@ static bool bInWindowAddHotspot = false;

long status;

status = it->second->AddHotspot (this,
HotspotId,
sPluginID,
Left, Top, Right, Bottom,
MouseOver,
CancelMouseOver,
MouseDown,
CancelMouseDown,
MouseUp,
TooltipText,
Cursor,
Flags);
status = mw->AddHotspot (this,
HotspotId,
sPluginID,
Left, Top, Right, Bottom,
MouseOver,
CancelMouseOver,
MouseDown,
CancelMouseDown,
MouseUp,
TooltipText,
Cursor,
Flags);

// in mouse was over hotspot when it was created, do a "mouse move" to detect this
if (status == eOK)
{
for(POSITION pos=GetFirstViewPosition();pos!=NULL;)
{
CView* pView = GetNextView(pos);

if (pView->IsKindOf(RUNTIME_CLASS(CMUSHView)))
((CMUSHView*)pView)->Mouse_Move_MiniWindow (this, m_lastMousePosition);
} // end of looping through views

// only check the current hotspot, not all of them
HotspotMapIterator it = mw->m_Hotspots.find (HotspotId);
if (it != mw->m_Hotspots.end ())
{
CHotspot * pHotspot = it->second;
if ( pHotspot->m_rect.PtInRect(mw->m_last_mouseposition) )
{
for(POSITION pos=GetFirstViewPosition();pos!=NULL;)
{
CView* pView = GetNextView(pos);

if (pView->IsKindOf(RUNTIME_CLASS(CMUSHView)))
((CMUSHView*)pView)->Mouse_Move_MiniWindow (this, m_lastMousePosition);
} // end of looping through views
}
} // end of hotspot found
} // end of added hotspot OK


Expand Down

0 comments on commit bd54a9d

Please sign in to comment.