Skip to content

Commit

Permalink
Better update top panel sizes (#3918)
Browse files Browse the repository at this point in the history
* Better update top panel sizes

* update
  • Loading branch information
Grantim authored Dec 24, 2024
1 parent 6e4b7b2 commit 8a0546d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
27 changes: 20 additions & 7 deletions source/MRViewer/MRRibbonMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_ )
{
Expand Down
3 changes: 3 additions & 0 deletions source/MRViewer/MRRibbonMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
Expand Down

0 comments on commit 8a0546d

Please sign in to comment.