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

Method ScrollTimeRangeInView

src/audio_display.cpp:631–670  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

629}
630
631void AudioDisplay::ScrollTimeRangeInView(const TimeRange &range)
632{
633 int client_width = GetClientRect().GetWidth();
634 int range_begin = AbsoluteXFromTime(range.begin());
635 int range_end = AbsoluteXFromTime(range.end());
636 int range_len = range_end - range_begin;
637
638 // Remove 5 % from each side of the client area.
639 int leftadjust = client_width / 20;
640 int client_left = scroll_left + leftadjust;
641 client_width = client_width * 9 / 10;
642
643 // Is everything already in view?
644 if (range_begin >= client_left && range_end <= client_left+client_width)
645 return;
646
647 // The entire range can fit inside the view, center it
648 if (range_len < client_width)
649 {
650 ScrollPixelToLeft(range_begin - (client_width-range_len)/2 - leftadjust);
651 }
652
653 // Range doesn't fit in view and we're viewing a middle part of it, just leave it alone
654 else if (range_begin < client_left && range_end > client_left+client_width)
655 {
656 // nothing
657 }
658
659 // Right edge is in view, scroll it as far to the right as possible
660 else if (range_end >= client_left && range_end < client_left+client_width)
661 {
662 ScrollPixelToLeft(range_end - client_width - leftadjust);
663 }
664
665 // Nothing is in view or the left edge is in view, scroll left edge as far to the left as possible
666 else
667 {
668 ScrollPixelToLeft(range_begin - leftadjust);
669 }
670}
671
672void AudioDisplay::SetZoomLevel(int new_zoom_level)
673{

Callers 1

ScrollToActiveLineMethod · 0.80

Calls 3

GetWidthMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected