diff options
| author | Carl Hetherington <cth@carlh.net> | 2026-02-02 18:54:03 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2026-02-02 18:54:03 +0100 |
| commit | 6816f69ad62b05ef6b2857c526db69a4adb52c36 (patch) | |
| tree | 5c0d3b188b7ce2c0c373e47e62d5ecaaf63ef8d6 | |
| parent | eeb11e3600b58dc6bfb778a11c6d96ceae4d808e (diff) | |
Don't draw the playhead so often.
| -rw-r--r-- | src/wx/content_timeline.cc | 17 | ||||
| -rw-r--r-- | src/wx/content_timeline.h | 2 |
2 files changed, 15 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) { diff --git a/src/wx/content_timeline.h b/src/wx/content_timeline.h index 5e8c658db..48dd986cc 100644 --- a/src/wx/content_timeline.h +++ b/src/wx/content_timeline.h @@ -111,6 +111,7 @@ private: void zoom_all(); void update_playhead(); void mouse_wheel_turned(wxMouseEvent& event); + int playhead_position() const; std::shared_ptr<ContentTimelineView> event_to_view(wxMouseEvent &); TimelineContentViewList selected_views() const; @@ -144,6 +145,7 @@ private: wxTimer _timer; boost::optional<int> _last_mouse_wheel_x; boost::optional<double> _last_mouse_wheel_time; + boost::optional<int> _last_drawn_playhead; static int const _minimum_pixels_per_track; |
