MCPcopy Create free account
hub / github.com/TypesettingTools/Aegisub / PaintLabels

Method PaintLabels

src/audio_display.cpp:912–942  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

910}
911
912void AudioDisplay::PaintLabels(wxDC &dc, TimeRange updtime)
913{
914 std::vector<AudioLabelProvider::AudioLabel> labels;
915 controller->GetTimingController()->GetLabels(updtime, labels);
916 if (labels.empty()) return;
917
918 wxDCFontChanger fc(dc);
919 wxFont font = dc.GetFont();
920 font.SetWeight(wxFONTWEIGHT_BOLD);
921 fc.Set(font);
922 dc.SetTextForeground(*wxWHITE);
923 for (auto const& label : labels)
924 {
925 wxSize extent = dc.GetTextExtent(label.text);
926 int left = RelativeXFromTime(label.range.begin());
927 int width = AbsoluteXFromTime(label.range.length());
928
929 // If it doesn't fit, truncate
930 if (width < extent.GetWidth())
931 {
932 dc.SetClippingRegion(left, audio_top + 4, width, extent.GetHeight());
933 dc.DrawText(label.text, left, audio_top + 4);
934 dc.DestroyClippingRegion();
935 }
936 // Otherwise center in the range
937 else
938 {
939 dc.DrawText(label.text, left + (width - extent.GetWidth()) / 2, audio_top + 4);
940 }
941 }
942}
943
944void AudioDisplay::PaintTrackCursor(wxDC &dc) {
945 wxDCPenChanger penchanger(dc, wxPen(*wxWHITE));

Callers

nothing calls this directly

Calls 8

GetTimingControllerMethod · 0.80
GetFontMethod · 0.80
lengthMethod · 0.80
GetLabelsMethod · 0.45
SetMethod · 0.45
beginMethod · 0.45
GetWidthMethod · 0.45
GetHeightMethod · 0.45

Tested by

no test coverage detected