diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-07-19 19:54:35 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-07-19 19:54:35 +0100 |
| commit | a2fd8a4e3750cfa3ff7be305b4052a0699a3ffee (patch) | |
| tree | 6e7b84167711d7623d48779e7af83cdbe8a4fbcb /src/wx | |
| parent | 114912df4be84f7d8b82833b93d739b117ec8705 (diff) | |
Give content menu on both main control and timeline. Fix silly bug on updating editor panels.
Diffstat (limited to 'src/wx')
| -rw-r--r-- | src/wx/content_menu.cc | 95 | ||||
| -rw-r--r-- | src/wx/content_menu.h | 48 | ||||
| -rw-r--r-- | src/wx/film_editor.cc | 14 | ||||
| -rw-r--r-- | src/wx/film_editor.h | 4 | ||||
| -rw-r--r-- | src/wx/timeline.cc | 56 | ||||
| -rw-r--r-- | src/wx/timeline.h | 6 | ||||
| -rw-r--r-- | src/wx/wscript | 1 |
7 files changed, 166 insertions, 58 deletions
diff --git a/src/wx/content_menu.cc b/src/wx/content_menu.cc new file mode 100644 index 000000000..6f1050302 --- /dev/null +++ b/src/wx/content_menu.cc @@ -0,0 +1,95 @@ +/* + Copyright (C) 2013 Carl Hetherington <cth@carlh.net> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include <wx/wx.h> +#include "lib/film.h" +#include "content_menu.h" +#include "repeat_dialog.h" + +using std::cout; +using boost::shared_ptr; + +enum { + ID_repeat, + ID_remove +}; + +ContentMenu::ContentMenu (shared_ptr<Film> f, wxWindow* p) + : _menu (new wxMenu) + , _film (f) + , _parent (p) +{ + _menu->Append (ID_repeat, _("Repeat...")); + _menu->AppendSeparator (); + _menu->Append (ID_remove, _("Remove")); + + _parent->Bind (wxEVT_COMMAND_MENU_SELECTED, &ContentMenu::repeat, this, ID_repeat); + _parent->Bind (wxEVT_COMMAND_MENU_SELECTED, &ContentMenu::remove, this, ID_remove); +} + +ContentMenu::~ContentMenu () +{ + delete _menu; +} + +void +ContentMenu::popup (ContentList c, wxPoint p) +{ + _content = c; + _parent->PopupMenu (_menu, p); +} + +void +ContentMenu::repeat (wxCommandEvent &) +{ + if (_content.empty ()) { + return; + } + + RepeatDialog d (_parent); + d.ShowModal (); + + shared_ptr<const Film> film = _film.lock (); + if (!film) { + return; + } + + film->playlist()->repeat (_content, d.number ()); + d.Destroy (); + + _content.clear (); +} + +void +ContentMenu::remove (wxCommandEvent &) +{ + if (_content.empty ()) { + return; + } + + shared_ptr<const Film> film = _film.lock (); + if (!film) { + return; + } + + film->playlist()->remove (_content); + + _content.clear (); +} + diff --git a/src/wx/content_menu.h b/src/wx/content_menu.h new file mode 100644 index 000000000..127fbea1a --- /dev/null +++ b/src/wx/content_menu.h @@ -0,0 +1,48 @@ +/* + Copyright (C) 2013 Carl Hetherington <cth@carlh.net> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef DCPOMATIC_CONTENT_MENU_H +#define DCPOMATIC_CONTENT_MENU_H + +#include <wx/wx.h> +#include <boost/shared_ptr.hpp> +#include <boost/weak_ptr.hpp> +#include "lib/types.h" + +class Film; + +class ContentMenu +{ +public: + ContentMenu (boost::shared_ptr<Film>, wxWindow *); + ~ContentMenu (); + + void popup (ContentList, wxPoint); + +private: + void repeat (wxCommandEvent &); + void remove (wxCommandEvent &); + + wxMenu* _menu; + boost::weak_ptr<Film> _film; + wxWindow* _parent; + ContentList _content; +}; + +#endif diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc index 33f5603a4..c2351ed25 100644 --- a/src/wx/film_editor.cc +++ b/src/wx/film_editor.cc @@ -69,6 +69,7 @@ using boost::lexical_cast; /** @param f Film to edit */ FilmEditor::FilmEditor (shared_ptr<Film> f, wxWindow* parent) : wxPanel (parent) + , _menu (f, this) , _generally_sensitive (true) , _audio_dialog (0) , _timeline_dialog (0) @@ -211,6 +212,7 @@ FilmEditor::connect_to_widgets () _ratio->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (FilmEditor::ratio_changed), 0, this); _content->Connect (wxID_ANY, wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler (FilmEditor::content_selection_changed), 0, this); _content->Connect (wxID_ANY, wxEVT_COMMAND_LIST_ITEM_DESELECTED, wxListEventHandler (FilmEditor::content_selection_changed), 0, this); + _content->Connect (wxID_ANY, wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK,wxListEventHandler (FilmEditor::content_right_click), 0, this); _content_add->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::content_add_clicked), 0, this); _content_remove->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::content_remove_clicked), 0, this); _content_timeline->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::content_timeline_clicked), 0, this); @@ -689,6 +691,10 @@ FilmEditor::film_content_changed (weak_ptr<Content> weak_content, int property) } shared_ptr<Content> content = weak_content.lock (); + if (content != selected_content ()) { + return; + } + shared_ptr<VideoContent> video_content; shared_ptr<AudioContent> audio_content; shared_ptr<SubtitleContent> subtitle_content; @@ -1516,3 +1522,11 @@ FilmEditor::sequence_video_changed (wxCommandEvent &) { _film->set_sequence_video (_sequence_video->GetValue ()); } + +void +FilmEditor::content_right_click (wxListEvent& ev) +{ + ContentList cl; + cl.push_back (selected_content ()); + _menu.popup (cl, ev.GetPoint ()); +} diff --git a/src/wx/film_editor.h b/src/wx/film_editor.h index 7347ab1a6..9501bbd7c 100644 --- a/src/wx/film_editor.h +++ b/src/wx/film_editor.h @@ -27,6 +27,7 @@ #include <wx/collpane.h> #include <boost/signals2.hpp> #include "lib/film.h" +#include "content_menu.h" class wxNotebook; class wxListCtrl; @@ -97,6 +98,7 @@ private: void dcp_audio_channels_changed (wxCommandEvent &); void dcp_resolution_changed (wxCommandEvent &); void sequence_video_changed (wxCommandEvent &); + void content_right_click (wxListEvent &); /* Handle changes to the model */ void film_changed (Film::Property); @@ -173,6 +175,8 @@ private: Timecode* _length; wxChoice* _dcp_resolution; + ContentMenu _menu; + std::vector<Ratio const *> _ratios; bool _generally_sensitive; diff --git a/src/wx/timeline.cc b/src/wx/timeline.cc index c7276a081..7227fcffc 100644 --- a/src/wx/timeline.cc +++ b/src/wx/timeline.cc @@ -25,7 +25,6 @@ #include "film_editor.h" #include "timeline.h" #include "wx_util.h" -#include "repeat_dialog.h" using std::list; using std::cout; @@ -320,11 +319,6 @@ private: int _y; }; -enum { - ID_repeat, - ID_remove -}; - Timeline::Timeline (wxWindow* parent, FilmEditor* ed, shared_ptr<Film> film) : wxPanel (parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE) , _film_editor (ed) @@ -335,7 +329,7 @@ Timeline::Timeline (wxWindow* parent, FilmEditor* ed, shared_ptr<Film> film) , _left_down (false) , _down_view_start (0) , _first_move (false) - , _menu (0) + , _menu (film, this) { #ifndef __WXOSX__ SetDoubleBuffered (true); @@ -348,9 +342,6 @@ Timeline::Timeline (wxWindow* parent, FilmEditor* ed, shared_ptr<Film> film) Connect (wxID_ANY, wxEVT_MOTION, wxMouseEventHandler (Timeline::mouse_moved), 0, this); Connect (wxID_ANY, wxEVT_SIZE, wxSizeEventHandler (Timeline::resized), 0, this); - Connect (ID_repeat, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Timeline::repeat), 0, this); - Connect (ID_remove, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Timeline::remove), 0, this); - playlist_changed (); SetMinSize (wxSize (640, tracks() * track_height() + 96)); @@ -572,14 +563,7 @@ Timeline::right_down (wxMouseEvent& ev) cv->set_selected (true); } - if (!_menu) { - _menu = new wxMenu; - _menu->Append (ID_repeat, _("Repeat...")); - _menu->AppendSeparator (); - _menu->Append (ID_remove, _("Remove")); - } - - PopupMenu (_menu, ev.GetPosition ()); + _menu.popup (selected_content (), ev.GetPosition ()); } void @@ -634,42 +618,6 @@ Timeline::clear_selection () } } -void -Timeline::repeat (wxCommandEvent &) -{ - ContentList sel = selected_content (); - if (sel.empty ()) { - return; - } - - RepeatDialog d (this); - d.ShowModal (); - - shared_ptr<const Film> film = _film.lock (); - if (!film) { - return; - } - - film->playlist()->repeat (sel, d.number ()); - d.Destroy (); -} - -void -Timeline::remove (wxCommandEvent &) -{ - ContentList sel = selected_content (); - if (sel.empty ()) { - return; - } - - shared_ptr<const Film> film = _film.lock (); - if (!film) { - return; - } - - film->playlist()->remove (sel); -} - Timeline::ContentViewList Timeline::selected_views () const { diff --git a/src/wx/timeline.h b/src/wx/timeline.h index 48eaa9d76..6f5c2ef3b 100644 --- a/src/wx/timeline.h +++ b/src/wx/timeline.h @@ -23,6 +23,7 @@ #include <wx/wx.h> #include "lib/util.h" #include "lib/rect.h" +#include "content_menu.h" class Film; class View; @@ -75,9 +76,6 @@ private: void set_start_from_event (wxMouseEvent &); void clear_selection (); - void repeat (wxCommandEvent &); - void remove (wxCommandEvent &); - typedef std::vector<boost::shared_ptr<View> > ViewList; typedef std::vector<boost::shared_ptr<ContentView> > ContentViewList; @@ -96,7 +94,7 @@ private: boost::shared_ptr<ContentView> _down_view; Time _down_view_start; bool _first_move; - wxMenu* _menu; + ContentMenu _menu; boost::signals2::scoped_connection _playlist_connection; }; diff --git a/src/wx/wscript b/src/wx/wscript index 09ce0218d..a6af05bc4 100644 --- a/src/wx/wscript +++ b/src/wx/wscript @@ -9,6 +9,7 @@ sources = """ audio_mapping_view.cc audio_plot.cc config_dialog.cc + content_menu.cc dci_metadata_dialog.cc dir_picker_ctrl.cc film_editor.cc |
