MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / drawCollapseButton_

Method drawCollapseButton_

source/MRViewer/MRRibbonMenu.cpp:295–372  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

293}
294
295void RibbonMenu::drawCollapseButton_()
296{
297 float btnSize = UI::scale() * cTopPanelAditionalButtonSize;
298
299 ImGui::PushStyleVar( ImGuiStyleVar_FrameRounding, cHeaderQuickAccessFrameRounding * UI::scale() );
300 ImGui::PushStyleVar( ImGuiStyleVar_FrameBorderSize, 0.0f );
301 ImGui::PushStyleColor( ImGuiCol_Button, ImVec4( 0, 0, 0, 0 ) );
302 ImGui::PushStyleColor( ImGuiCol_ButtonHovered, ImGui::GetStyleColorVec4( ImGuiCol_ScrollbarGrabHovered ) );
303 ImGui::PushStyleColor( ImGuiCol_ButtonActive, ImGui::GetStyleColorVec4( ImGuiCol_ScrollbarGrabActive ) );
304
305 if ( collapseState_ == CollapseState::Pinned )
306 {
307 ImGui::PushStyleColor( ImGuiCol_Text, ColorTheme::getRibbonColor( ColorTheme::RibbonColorsType::TabText ).getUInt32() );
308 RibbonFontHolder font( RibbonFontManager::FontType::Icons, 0.7f );
309 if ( ImGui::Button( "\xef\x81\x93", ImVec2( btnSize, btnSize ) ) )
310 {
311 collapseState_ = CollapseState::Opened;
312 fixViewportsSize_( getViewerInstance().framebufferSize.x, getViewerInstance().framebufferSize.y );
313 openedTimer_ = openedMaxSecs_;
314#ifndef __EMSCRIPTEN__
315 asyncRequest_.reset();
316#endif
317 }
318 font.popFont();
319 ImGui::PopStyleColor();
320 UI::setTooltipIfHovered( _tr( "Unpin" ) );
321 }
322 else
323 {
324 ImGui::PushStyleColor( ImGuiCol_Text, ColorTheme::getRibbonColor( ColorTheme::RibbonColorsType::TabText ).getUInt32() );
325 RibbonFontHolder font( RibbonFontManager::FontType::Icons, 0.7f );
326 if ( ImGui::Button( "\xef\x81\xb7", ImVec2( btnSize, btnSize ) ) )
327 {
328 collapseState_ = CollapseState::Pinned;
329 fixViewportsSize_( getViewerInstance().framebufferSize.x, getViewerInstance().framebufferSize.y );
330 }
331 font.popFont();
332 ImGui::PopStyleColor();
333 UI::setTooltipIfHovered( _tr( "Pin" ) );
334 }
335
336 ImGui::PopStyleColor( 3 );
337 ImGui::PopStyleVar( 2 );
338
339 if ( collapseState_ == CollapseState::Opened )
340 {
341 bool hovered = ImGui::IsWindowHovered(
342 ImGuiHoveredFlags_ChildWindows |
343 ImGuiHoveredFlags_AllowWhenBlockedByActiveItem );
344 if ( hovered && openedTimer_ <= openedMaxSecs_ )
345 {
346 openedTimer_ = openedMaxSecs_;
347 collapseState_ = CollapseState::Opened;
348 }
349 else
350 {
351 openedTimer_ -= ImGui::GetIO().DeltaTime;
352#ifdef __EMSCRIPTEN__

Callers

nothing calls this directly

Calls 10

ImVec4Class · 0.85
ImVec2Class · 0.85
setTooltipIfHoveredFunction · 0.85
postEmptyEventFunction · 0.85
getUInt32Method · 0.80
popFontMethod · 0.80
requestIfNotSetMethod · 0.80
scaleFunction · 0.70
resetMethod · 0.45

Tested by

no test coverage detected