| 1942 | } |
| 1943 | |
| 1944 | bool 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 | |
| 1960 | void 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 | { |
no test coverage detected