diff --git a/source/MRViewer/MRRibbonMenu.cpp b/source/MRViewer/MRRibbonMenu.cpp index cf652d652058..135b5f91a596 100644 --- a/source/MRViewer/MRRibbonMenu.cpp +++ b/source/MRViewer/MRRibbonMenu.cpp @@ -2383,20 +2383,33 @@ void RibbonMenu::endTopPanel_() ImGui::PopStyleVar( 3 ); } -void RibbonMenu::drawTopPanel_( bool drawTabs, bool centerItems ) +void RibbonMenu::updateTopPanelSize_( bool drawTabs ) { + constexpr int cTabSize = int( cTabHeight + cTabYOffset + 1 ); + constexpr int cSumPanelSizeSize = cTabSize + 80; + if ( drawTabs && topPanelHiddenHeight_ == cTabSize ) + return; + if ( !drawTabs && topPanelHiddenHeight_ == 0 ) + return; if ( drawTabs ) { - currentTopPanelHeight_ = 113; - topPanelOpenedHeight_ = 113; - topPanelHiddenHeight_ = 33; + topPanelOpenedHeight_ = cSumPanelSizeSize; + topPanelHiddenHeight_ = cTabSize; } else { - currentTopPanelHeight_ = 113 - 33; - topPanelOpenedHeight_ = 113 - 33; - topPanelHiddenHeight_ = 33 - 33; + topPanelOpenedHeight_ = cSumPanelSizeSize - cTabSize; + topPanelHiddenHeight_ = 0; + collapseState_ = CollapseState::Pinned; } + currentTopPanelHeight_ = collapseState_ == CollapseState::Closed ? topPanelHiddenHeight_ : topPanelOpenedHeight_; + + fixViewportsSize_( getViewerInstance().framebufferSize.x, getViewerInstance().framebufferSize.y ); +} + +void RibbonMenu::drawTopPanel_( bool drawTabs, bool centerItems ) +{ + updateTopPanelSize_( drawTabs ); switch ( collapseState_ ) { diff --git a/source/MRViewer/MRRibbonMenu.h b/source/MRViewer/MRRibbonMenu.h index aaf4ffee4df7..2897b0510d11 100644 --- a/source/MRViewer/MRRibbonMenu.h +++ b/source/MRViewer/MRRibbonMenu.h @@ -228,6 +228,9 @@ class MRVIEWER_CLASS RibbonMenu : public ImGuiMenu // call this to draw RibbonNotifier with respect of scene size and ribbon top panel MRVIEWER_API virtual void drawNotifications_(); + // this function changes internal sizes of topPanel when it is enabled or disabled + MRVIEWER_API virtual void updateTopPanelSize_( bool drawTabs ); + RibbonLayoutMode layoutMode_{ RibbonLayoutMode::All }; RibbonMenuSearch searcher_;