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

Method drawMeasurementUnitsTab_

source/MRViewer/MRViewerSettingsPlugin.cpp:602–766  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

600}
601
602void ViewerSettingsPlugin::drawMeasurementUnitsTab_()
603{
604 static constexpr int cMaxPrecision = 9;
605
606 { // Common.
607 drawSeparator_( _t( "Common" ) );
608
609 // --- Leading zero
610 const auto& style = ImGui::GetStyle();
611 ImGui::PushStyleVar( ImGuiStyleVar_ItemSpacing, { style.ItemSpacing.x, style.ItemSpacing.y * 1.5f } );
612 bool value = UnitSettings::getShowLeadingZero();
613 if ( UI::checkbox( _tr( "Leading zero" ), &value ) )
614 UnitSettings::setShowLeadingZero( value );
615 UI::setTooltipIfHovered( _tr( "If disabled, remove the lone zeroes before the decimal point." ) );
616 ImGui::PopStyleVar();
617
618 // --- Thousands separator
619
620 ImGui::PushItemWidth( 170.0f * UI::scale() );
621 MR_FINALLY{ ImGui::PopItemWidth(); };
622
623 char thouSep[2] = { UnitSettings::getThousandsSeparator(), '\0' };
624 ImGui::PushStyleVar( ImGuiStyleVar_FramePadding, ImVec2( std::floor( ( ImGui::CalcItemWidth() - ImGui::CalcTextSize( thouSep ).x ) / 2 ), cButtonPadding * UI::scale() ) );
625 MR_FINALLY{ ImGui::PopStyleVar(); };
626
627 if ( UI::inputTextIntoArray( _tr( "Thousands Separator" ), thouSep, sizeof thouSep, ImGuiInputTextFlags_AutoSelectAll ) )
628 UnitSettings::setThousandsSeparator( thouSep[0] );
629 UI::setTooltipIfHovered( _tr( "A symbol used to separate groups of thousands in large numbers to make them easier to read." ) );
630
631 // If the separator is empty or a space, display a string explaining that on top of the textbox.
632 if ( !ImGui::IsItemActive() )
633 {
634 std::string label;
635 if ( thouSep[0] == 0 )
636 label = s_tr( "None" );
637 else if ( thouSep[0] == ' ' )
638 label = s_tr( "Space" );
639
640 if ( !label.empty() )
641 {
642 ImVec2 textSize = ImGui::CalcTextSize( label.c_str() );
643 ImGui::GetWindowDrawList()->AddText( ImGui::GetItemRectMin() + ( ImVec2( ImGui::CalcItemWidth(), ImGui::GetItemRectSize().y ) - textSize ) / 2, ImGui::GetColorU32( ImGuiCol_TextDisabled ), label.c_str() );
644 }
645 }
646 }
647
648
649 { // Length.
650 ImGui::PushItemWidth( 170.0f * UI::scale() );
651 drawSeparator_( _t( "Linear" ) );
652
653 ImGui::PushID( "length" );
654 MR_FINALLY{ ImGui::PopID(); };
655
656 // --- Units
657
658 auto makeLengthUnitsVec = []( const char * lastOption )
659 {

Callers

nothing calls this directly

Calls 15

getShowLeadingZeroFunction · 0.85
setShowLeadingZeroFunction · 0.85
setTooltipIfHoveredFunction · 0.85
getThousandsSeparatorFunction · 0.85
ImVec2Class · 0.85
floorFunction · 0.85
inputTextIntoArrayFunction · 0.85
setThousandsSeparatorFunction · 0.85
LengthUnitEnum · 0.85
getUiLengthUnitFunction · 0.85
comboFunction · 0.85
translateAllFunction · 0.85

Tested by

no test coverage detected