From 62fe7a015ab68b09edcdfe7299ec00e26ac77c77 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 7 Oct 2013 09:59:03 +0000 Subject: [PATCH] Fix unwanted ribbon expansion on focus loss. The ribbon unexpectedly showed itself on focus loss when it was minimized. Fix this and also use switch statement on m_ribbon_state to ensure that the compiler warns us if we forget to add the code for handling any new elements of wxRibbonDisplayMode enum. Closes #15381. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74953 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/ribbon/bar.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/ribbon/bar.cpp b/src/ribbon/bar.cpp index 8edae51014..1bad16a18b 100644 --- a/src/ribbon/bar.cpp +++ b/src/ribbon/bar.cpp @@ -1269,15 +1269,19 @@ void wxRibbonBar::HitTestRibbonButton(const wxRect& rect, const wxPoint& positio void wxRibbonBar::HideIfExpanded() { - if ( m_ribbon_state == wxRIBBON_BAR_EXPANDED ) + switch ( m_ribbon_state ) { - HidePanels(); - m_ribbon_state = wxRIBBON_BAR_MINIMIZED; - } - else - { - ShowPanels(); - m_ribbon_state = wxRIBBON_BAR_PINNED; + case wxRIBBON_BAR_EXPANDED: + m_ribbon_state = wxRIBBON_BAR_MINIMIZED; + // Fall through + + case wxRIBBON_BAR_MINIMIZED: + HidePanels(); + break; + + case wxRIBBON_BAR_PINNED: + ShowPanels(); + break; } }