From e8af431bd9bfc5f1d6aa33246bdd082bc8b2d17e Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 5 Feb 2023 13:50:52 +0100 Subject: Delete in timeline removes content (#2370). --- src/wx/timeline.cc | 11 +++++++++++ src/wx/timeline.h | 2 ++ src/wx/timeline_dialog.cc | 9 +++++++++ src/wx/timeline_dialog.h | 1 + 4 files changed, 23 insertions(+) (limited to 'src') diff --git a/src/wx/timeline.cc b/src/wx/timeline.cc index 604a00f39..d2443c8a9 100644 --- a/src/wx/timeline.cc +++ b/src/wx/timeline.cc @@ -950,3 +950,14 @@ Timeline::zoom_all () _labels_canvas->Scroll (0, 0); Refresh (); } + + +void +Timeline::keypress(wxKeyEvent const& event) +{ + if (event.GetKeyCode() == WXK_DELETE) { + auto film = _film.lock(); + film->remove_content(selected_content()); + } +} + diff --git a/src/wx/timeline.h b/src/wx/timeline.h index a2c4f0f2f..184a5d9ee 100644 --- a/src/wx/timeline.h +++ b/src/wx/timeline.h @@ -82,6 +82,8 @@ public: int tracks_y_offset () const; + void keypress(wxKeyEvent const &); + private: void paint_labels (); void paint_main (); diff --git a/src/wx/timeline_dialog.cc b/src/wx/timeline_dialog.cc index 0d05e66d6..d6c784387 100644 --- a/src/wx/timeline_dialog.cc +++ b/src/wx/timeline_dialog.cc @@ -95,6 +95,8 @@ TimelineDialog::TimelineDialog(ContentPanel* cp, shared_ptr film, FilmView sizer->Layout (); sizer->SetSizeHints (this); + Bind(wxEVT_CHAR_HOOK, boost::bind(&TimelineDialog::keypress, this, _1)); + _toolbar->ToggleTool ((int) Timeline::SNAP, _timeline.snap ()); film_change (ChangeType::DONE, Film::Property::SEQUENCE); @@ -141,3 +143,10 @@ TimelineDialog::tool_clicked (wxCommandEvent& ev) } } } + + +void +TimelineDialog::keypress(wxKeyEvent const& event) +{ + _timeline.keypress(event); +} diff --git a/src/wx/timeline_dialog.h b/src/wx/timeline_dialog.h index f5dea4eef..155d51fac 100644 --- a/src/wx/timeline_dialog.h +++ b/src/wx/timeline_dialog.h @@ -39,6 +39,7 @@ public: private: void film_change (ChangeType type, Film::Property); void tool_clicked (wxCommandEvent& id); + void keypress(wxKeyEvent const& event); std::weak_ptr _film; Timeline _timeline; -- cgit v1.2.3