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

Method drawTooltip_

source/MRViewer/MRRibbonButtonDrawer.cpp:628–683  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

626}
627
628void RibbonButtonDrawer::drawTooltip_( const MenuItemInfo& item, const std::string& requirements ) const
629{
630 RibbonFontHolder smallFont( RibbonFontManager::FontType::Small );
631 ImGui::PushStyleVar( ImGuiStyleVar_ItemSpacing, ImVec2( 0, 0 ) );
632 ImGui::PushStyleVar( ImGuiStyleVar_WindowPadding, ImVec2( cRibbonButtonWindowPaddingX * UI::scale(), cRibbonButtonWindowPaddingY * UI::scale() ) );
633 std::string tooltip = item.item->getDynamicTooltip();
634 if ( tooltip.empty() )
635 tooltip = Locale::translate( item.tooltip.c_str(), item.localeDomainId );
636
637 std::string caption = Locale::translate( item.getCaption().c_str(), item.localeDomainId );
638
639 std::string fullText;
640 fullText = caption;
641 std::string shortcutStr;
642
643 if ( shortcutManager_ )
644 {
645 auto shortcut = shortcutManager_->findShortcutByName( item.item->name() );
646 if ( shortcut )
647 {
648 shortcutStr = " (" + ShortcutManager::getKeyFullString( *shortcut ) + ")";
649 fullText += shortcutStr;
650 }
651 }
652
653 if ( !tooltip.empty() )
654 {
655 fullText += '\n';
656 fullText += tooltip;
657 }
658 if ( !requirements.empty() )
659 {
660 fullText += '\n';
661 fullText += requirements;
662 }
663 auto textSize = ImGui::CalcTextSize( fullText.c_str(), NULL, false, 400.f );
664
665 ImGui::SetNextWindowContentSize( textSize );
666 ImGui::BeginTooltip();
667 ImGui::Text( "%s%s", caption.c_str(), shortcutStr.c_str() );
668 if ( !tooltip.empty() )
669 {
670 ImGui::PushStyleColor( ImGuiCol_Text, ImGui::GetStyleColorVec4( ImGuiCol_TextDisabled ) );
671 ImGui::TextWrapped( "%s", tooltip.c_str() );
672 ImGui::PopStyleColor();
673 }
674 if ( !requirements.empty() )
675 {
676 ImGui::PushStyleColor( ImGuiCol_Text, Color::red().getUInt32() );
677 ImGui::TextWrapped( "%s", requirements.c_str() );
678 ImGui::PopStyleColor();
679 }
680 ImGui::EndTooltip();
681 ImGui::PopStyleVar( 2 );
682 smallFont.popFont();
683}
684
685

Callers

nothing calls this directly

Calls 10

ImVec2Class · 0.85
TextClass · 0.85
getDynamicTooltipMethod · 0.80
findShortcutByNameMethod · 0.80
getUInt32Method · 0.80
popFontMethod · 0.80
scaleFunction · 0.70
translateFunction · 0.70
emptyMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected