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

Function inputTextCentered

source/MRViewer/MRUIStyle.cpp:1944–1958  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1942}
1943
1944bool inputTextCentered( const char* label, std::string& str, float width /*= 0.0f*/,
1945 ImGuiInputTextFlags flags /*= 0*/, ImGuiInputTextCallback callback /*= nullptr*/, void* user_data /*= nullptr */ )
1946{
1947 const auto& style = ImGui::GetStyle();
1948 const auto estimatedSize = ImGui::CalcTextSize( str.c_str() );
1949 const ImVec2 padding{ 2 * style.FramePadding.x * UI::scale() , 2 * style.FramePadding.y * UI::scale() };
1950 const auto actualWidth = ( width == 0.0f ) ? estimatedSize.x + padding.x : width;
1951
1952 ImGui::SetNextItemWidth( actualWidth );
1953 StyleParamHolder sh;
1954 if ( actualWidth > estimatedSize.x )
1955 sh.addVar( ImGuiStyleVar_FramePadding, { ( actualWidth - estimatedSize.x ) * 0.5f, style.FramePadding.y } );
1956
1957 return inputText( label, str, flags, callback, user_data );
1958}
1959
1960void inputTextCenteredReadOnly( const char* label, const std::string& str, float width /*= 0.0f*/, const std::optional<ImVec4>& textColor /*= {} */, const std::optional<ImVec4>& labelColor /*= {}*/, bool selectable /*= true*/ )
1961{

Callers 3

drawCreateToolDialogMethod · 0.85
drawTagInformation_Method · 0.85

Calls 3

inputTextFunction · 0.85
addVarMethod · 0.80
scaleFunction · 0.70

Tested by

no test coverage detected