summaryrefslogtreecommitdiff
path: root/src/wx/content_timeline.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2026-02-02 18:54:03 +0100
committerCarl Hetherington <cth@carlh.net>2026-02-02 18:54:03 +0100
commit6816f69ad62b05ef6b2857c526db69a4adb52c36 (patch)
tree5c0d3b188b7ce2c0c373e47e62d5ecaaf63ef8d6 /src/wx/content_timeline.cc
parenteeb11e3600b58dc6bfb778a11c6d96ceae4d808e (diff)
Don't draw the playhead so often.
Diffstat (limited to 'src/wx/content_timeline.cc')
-rw-r--r--src/wx/content_timeline.cc17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/wx/content_timeline.cc b/src/wx/content_timeline.cc
index bba2b433c..537877635 100644
--- a/src/wx/content_timeline.cc
+++ b/src/wx/content_timeline.cc
@@ -179,7 +179,9 @@ ContentTimeline::mouse_wheel_turned(wxMouseEvent& event)
void
ContentTimeline::update_playhead()
{
- Refresh();
+ if (!_last_drawn_playhead || playhead_position() != *_last_drawn_playhead) {
+ Refresh();
+ }
}
@@ -265,13 +267,20 @@ ContentTimeline::paint_main()
gc->SetPen(*wxRED_PEN);
auto path = gc->CreatePath();
- double const ph = _viewer.position().seconds() * pixels_per_second().get_value_or(0);
- path.MoveToPoint(ph, 0);
- path.AddLineToPoint(ph, pixels_per_track() * _tracks + 32);
+ _last_drawn_playhead = playhead_position();
+ path.MoveToPoint(*_last_drawn_playhead, 0);
+ path.AddLineToPoint(*_last_drawn_playhead, pixels_per_track() * _tracks + 32);
gc->StrokePath(path);
}
+int
+ContentTimeline::playhead_position() const
+{
+ return std::round(_viewer.position().seconds() * pixels_per_second().get_value_or(0));
+}
+
+
void
ContentTimeline::film_change(ChangeType type, FilmProperty p)
{