MCPcopy Create free account
hub / github.com/audacity/audacity / UpdateStatusWidths

Method UpdateStatusWidths

src/ProjectWindow.cpp:922–977  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

920}
921
922void ProjectWindow::UpdateStatusWidths()
923{
924 auto pProject = FindProject();
925 if (!pProject)
926 return;
927
928 const auto fieldsCount =
929 ProjectStatusFieldsRegistry::Count(pProject.get()) + 1;
930 auto statusBar = GetStatusBar();
931
932 bool statusBarRecreated = false;
933
934 if (!statusBar || fieldsCount != statusBar->GetFieldsCount())
935 {
936 statusBar = CreateProjectStatusBar();
937 statusBarRecreated = true;
938 }
939
940 const auto& functions = ProjectStatus::GetStatusWidthFunctions();
941
942 auto& project = *pProject;
943
944 std::vector<int> widths(fieldsCount, 0);
945
946 // The old behavior with zero-width first field is kept
947 int index = 1;
948
949 ProjectStatusFieldsRegistry::Visit(
950 [&](const StatusBarFieldItem& field, const auto&)
951 {
952 if (!field.IsVisible(project))
953 return;
954
955 auto width = field.GetDefaultWidth(project);
956
957 // Negative width indicates that the field is expandable
958 if (width >= 0)
959 {
960 for (const auto& function : functions)
961 {
962 auto results = function(project, field.name);
963 for (const auto& string : results.first)
964 {
965 int w;
966 statusBar->GetTextExtent(string.Translation(), &w, nullptr);
967 width = std::max<int>(width, w + results.second);
968 }
969 }
970 }
971
972 widths[index++] = width;
973 });
974
975 statusBar->SetStatusWidths(fieldsCount, widths.data());
976 ProjectStatusFieldsRegistry::OnSize(project);
977}
978
979void ProjectWindow::MacShowUndockedToolbars(bool show)

Callers 2

InitProjectWindowFunction · 0.80
OnStatusChangeMethod · 0.80

Calls 8

OnSizeFunction · 0.85
TranslationMethod · 0.80
CountFunction · 0.50
VisitFunction · 0.50
getMethod · 0.45
IsVisibleMethod · 0.45
GetDefaultWidthMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected