X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/10effff8320196145fe96a32535d03ec7a453e70..7d6a4d96961eac84d05db8bb24c64d39003f6e54:/src/aui/auibar.cpp?ds=sidebyside diff --git a/src/aui/auibar.cpp b/src/aui/auibar.cpp index 9d933d93d6..9cb1b9ab0a 100644 --- a/src/aui/auibar.cpp +++ b/src/aui/auibar.cpp @@ -1284,9 +1284,7 @@ void wxAuiToolBar::SetToolSticky(int tool_id, bool sticky) item->m_sticky = sticky; Refresh(false); -#ifdef TODO_REMOVE_IF_NO_PROBLEMS Update(); -#endif } bool wxAuiToolBar::GetToolSticky(int tool_id) const @@ -1408,6 +1406,9 @@ bool wxAuiToolBar::SetFont(const wxFont& font) void wxAuiToolBar::SetHoverItem(wxAuiToolBarItem* pitem) { + if (pitem && (pitem->m_state & wxAUI_BUTTON_STATE_DISABLED)) + pitem = NULL; + wxAuiToolBarItem* former_hover = NULL; size_t i, count; @@ -1427,9 +1428,7 @@ void wxAuiToolBar::SetHoverItem(wxAuiToolBarItem* pitem) if (former_hover != pitem) { Refresh(false); -#ifdef TODO_REMOVE_IF_NO_PROBLEMS Update(); -#endif } } @@ -1455,9 +1454,7 @@ void wxAuiToolBar::SetPressedItem(wxAuiToolBarItem* pitem) if (former_item != pitem) { Refresh(false); -#ifdef TODO_REMOVE_IF_NO_PROBLEMS Update(); -#endif } } @@ -1491,9 +1488,7 @@ void wxAuiToolBar::RefreshOverflowState() { m_overflowState = overflow_state; Refresh(false); -#ifdef TODO_REMOVE_IF_NO_PROBLEMS Update(); -#endif } m_overflowState = overflow_state; @@ -2249,9 +2244,7 @@ void wxAuiToolBar::OnSize(wxSizeEvent& WXUNUSED(evt)) m_sizer->SetDimension(0, 0, x, y); Refresh(false); -#ifdef TODO_REMOVE_IF_NO_PROBLEMS Update(); -#endif // idle events aren't sent while user is resizing frame (why?), // but resizing toolbar here causes havoc, @@ -2590,6 +2583,11 @@ void wxAuiToolBar::OnLeftDown(wxMouseEvent& evt) if(!GetEventHandler()->ProcessEvent(e) || e.GetSkipped()) CaptureMouse(); + // Ensure hovered item is really ok, as mouse may have moved during + // event processing + wxPoint cursor_pos_after_evt = ScreenToClient(wxGetMousePosition()); + SetHoverItem(FindToolByPosition(cursor_pos_after_evt.x, cursor_pos_after_evt.y)); + DoIdleUpdate(); } } @@ -2601,11 +2599,9 @@ void wxAuiToolBar::OnLeftUp(wxMouseEvent& evt) SetPressedItem(NULL); - wxAuiToolBarItem* hitItem = FindToolByPosition(evt.GetX(), evt.GetY()); - if (hitItem && !(hitItem->m_state & wxAUI_BUTTON_STATE_DISABLED)) - { - SetHoverItem(hitItem); - } + wxAuiToolBarItem* hitItem; + hitItem = FindToolByPosition(evt.GetX(), evt.GetY()); + SetHoverItem(hitItem); if (m_dragging) { @@ -2634,9 +2630,7 @@ void wxAuiToolBar::OnLeftUp(wxMouseEvent& evt) // repaint immediately Refresh(false); -#ifdef TODO_REMOVE_IF_NO_PROBLEMS Update(); -#endif e.SetInt(toggle); } @@ -2648,6 +2642,12 @@ void wxAuiToolBar::OnLeftUp(wxMouseEvent& evt) ReleaseMouse(); GetEventHandler()->ProcessEvent(e); + + // Ensure hovered item is really ok, as mouse may have moved during + // event processing + wxPoint cursor_pos_after_evt = ScreenToClient(wxGetMousePosition()); + SetHoverItem(FindToolByPosition(cursor_pos_after_evt.x, cursor_pos_after_evt.y)); + DoIdleUpdate(); } else @@ -2666,14 +2666,13 @@ void wxAuiToolBar::OnRightDown(wxMouseEvent& evt) return; } - if (m_overflowSizerItem) + if (m_overflowSizerItem && m_art) { int dropdown_size = m_art->GetElementSize(wxAUI_TBART_OVERFLOW_SIZE); if (dropdown_size > 0 && evt.m_x > cli_rect.width - dropdown_size && evt.m_y >= 0 && - evt.m_y < cli_rect.height && - m_art) + evt.m_y < cli_rect.height) { return; } @@ -2733,14 +2732,13 @@ void wxAuiToolBar::OnMiddleDown(wxMouseEvent& evt) return; } - if (m_overflowSizerItem) + if (m_overflowSizerItem && m_art) { int dropdown_size = m_art->GetElementSize(wxAUI_TBART_OVERFLOW_SIZE); if (dropdown_size > 0 && evt.m_x > cli_rect.width - dropdown_size && evt.m_y >= 0 && - evt.m_y < cli_rect.height && - m_art) + evt.m_y < cli_rect.height) { return; } @@ -2822,10 +2820,7 @@ void wxAuiToolBar::OnMotion(wxMouseEvent& evt) } else { - if (hitItem && (hitItem->m_state & wxAUI_BUTTON_STATE_DISABLED)) - SetHoverItem(NULL); - else - SetHoverItem(hitItem); + SetHoverItem(hitItem); // tooltips handling wxAuiToolBarItem* packingHitItem;