diff options
| author | Carl Hetherington <cth@carlh.net> | 2018-07-04 00:51:31 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2018-07-04 00:51:31 +0100 |
| commit | aaaa51f6d9eda60ab3b3d182c6d2a7a5bda375aa (patch) | |
| tree | 9a8a1ec74936fb47c4700d34da6e63cd82fe0f84 /src | |
| parent | beddaeab9011e745dcac9732f4e8de3f91bd81a5 (diff) | |
Add zoom-all button.
Diffstat (limited to 'src')
| -rw-r--r-- | src/wx/timeline.cc | 65 | ||||
| -rw-r--r-- | src/wx/timeline.h | 17 | ||||
| -rw-r--r-- | src/wx/timeline_content_view.cc | 6 | ||||
| -rw-r--r-- | src/wx/timeline_dialog.cc | 19 | ||||
| -rw-r--r-- | src/wx/timeline_dialog.h | 2 | ||||
| -rw-r--r-- | src/wx/timeline_labels_view.cc | 4 | ||||
| -rw-r--r-- | src/wx/timeline_time_axis_view.cc | 2 |
7 files changed, 78 insertions, 37 deletions
diff --git a/src/wx/timeline.cc b/src/wx/timeline.cc index 6fac62727..a0bf50f05 100644 --- a/src/wx/timeline.cc +++ b/src/wx/timeline.cc @@ -55,7 +55,7 @@ using boost::optional; /* 3 hours in 640 pixels */ double const Timeline::_minimum_pixels_per_second = 640.0 / (60 * 60 * 3); -int const Timeline::_minimum_track_height = 16; +int const Timeline::_minimum_pixels_per_track = 16; Timeline::Timeline (wxWindow* parent, ContentPanel* cp, shared_ptr<Film> film) : wxPanel (parent, wxID_ANY) @@ -75,7 +75,7 @@ Timeline::Timeline (wxWindow* parent, ContentPanel* cp, shared_ptr<Film> film) , _tool (SELECT) , _x_scroll_rate (16) , _y_scroll_rate (16) - , _track_height (48) + , _pixels_per_track (48) { #ifndef __WXOSX__ _labels_canvas->SetDoubleBuffered (true); @@ -99,18 +99,24 @@ Timeline::Timeline (wxWindow* parent, ContentPanel* cp, shared_ptr<Film> film) film_changed (Film::CONTENT); - SetMinSize (wxSize (640, 4 * track_height() + 96)); + SetMinSize (wxSize (640, 4 * pixels_per_track() + 96)); _film_changed_connection = film->Changed.connect (bind (&Timeline::film_changed, this, _1)); _film_content_changed_connection = film->ContentChanged.connect (bind (&Timeline::film_content_changed, this, _2, _3)); - _pixels_per_second = max (_minimum_pixels_per_second, static_cast<double>(640) / film->length().seconds ()); + set_pixels_per_second (static_cast<double>(640) / film->length().seconds ()); setup_scrollbars (); _labels_canvas->ShowScrollbars (wxSHOW_SB_NEVER, wxSHOW_SB_NEVER); } void +Timeline::set_pixels_per_second (double pps) +{ + _pixels_per_second = max (_minimum_pixels_per_second, pps); +} + +void Timeline::paint_labels () { wxPaintDC dc (_labels_canvas); @@ -387,9 +393,9 @@ Timeline::setup_scrollbars () if (!film || !_pixels_per_second) { return; } - _labels_canvas->SetVirtualSize (_labels_view->bbox().width, tracks() * track_height() + 96); + _labels_canvas->SetVirtualSize (_labels_view->bbox().width, tracks() * pixels_per_track() + 96); _labels_canvas->SetScrollRate (_x_scroll_rate, _y_scroll_rate); - _main_canvas->SetVirtualSize (*_pixels_per_second * film->length().seconds(), tracks() * track_height() + 96); + _main_canvas->SetVirtualSize (*_pixels_per_second * film->length().seconds(), tracks() * pixels_per_track() + 96); _main_canvas->SetScrollRate (_x_scroll_rate, _y_scroll_rate); } @@ -422,6 +428,7 @@ Timeline::left_down (wxMouseEvent& ev) left_down_select (ev); break; case ZOOM: + case ZOOM_ALL: /* Nothing to do */ break; } @@ -492,6 +499,8 @@ Timeline::left_up (wxMouseEvent& ev) case ZOOM: left_up_zoom (ev); break; + case ZOOM_ALL: + break; } } @@ -532,21 +541,27 @@ Timeline::left_up_zoom (wxMouseEvent& ev) DCPTime const time_left = DCPTime::from_seconds((top_left.x + vsx) / *_pixels_per_second); DCPTime const time_right = DCPTime::from_seconds((bottom_right.x + vsx) / *_pixels_per_second); - _pixels_per_second = max (_minimum_pixels_per_second, double(GetSize().GetWidth()) / (time_right.seconds() - time_left.seconds())); + set_pixels_per_second (double(GetSize().GetWidth()) / (time_right.seconds() - time_left.seconds())); - double const tracks_top = double(top_left.y) / _track_height; - double const tracks_bottom = double(bottom_right.y) / _track_height; - _track_height = max(_minimum_track_height, int(lrint(GetSize().GetHeight() / (tracks_bottom - tracks_top)))); + double const tracks_top = double(top_left.y) / _pixels_per_track; + double const tracks_bottom = double(bottom_right.y) / _pixels_per_track; + set_pixels_per_track (lrint(GetSize().GetHeight() / (tracks_bottom - tracks_top))); setup_scrollbars (); - _main_canvas->Scroll (time_left.seconds() * *_pixels_per_second / _x_scroll_rate, tracks_top * _track_height / _y_scroll_rate); - _labels_canvas->Scroll (0, tracks_top * _track_height / _y_scroll_rate); + _main_canvas->Scroll (time_left.seconds() * *_pixels_per_second / _x_scroll_rate, tracks_top * _pixels_per_track / _y_scroll_rate); + _labels_canvas->Scroll (0, tracks_top * _pixels_per_track / _y_scroll_rate); _zoom_point = optional<wxPoint> (); Refresh (); } void +Timeline::set_pixels_per_track (int h) +{ + _pixels_per_track = max(_minimum_pixels_per_track, h); +} + +void Timeline::mouse_moved (wxMouseEvent& ev) { switch (_tool) { @@ -556,6 +571,8 @@ Timeline::mouse_moved (wxMouseEvent& ev) case ZOOM: mouse_moved_zoom (ev); break; + case ZOOM_ALL: + break; } } @@ -589,11 +606,13 @@ Timeline::right_down (wxMouseEvent& ev) break; case ZOOM: /* Zoom out */ - _pixels_per_second = max (_minimum_pixels_per_second, *_pixels_per_second / 2); - _track_height = max (_minimum_track_height, _track_height / 2); + set_pixels_per_second (*_pixels_per_second / 2); + set_pixels_per_track (_pixels_per_track / 2); setup_scrollbars (); Refresh (); break; + case ZOOM_ALL: + break; } } @@ -776,3 +795,21 @@ Timeline::scrolled (wxScrollWinEvent& ev) } ev.Skip (); } + +void +Timeline::tool_clicked (Tool t) +{ + switch (t) { + case ZOOM: + case SELECT: + _tool = t; + break; + case ZOOM_ALL: + shared_ptr<Film> film = _film.lock (); + DCPOMATIC_ASSERT (film); + set_pixels_per_second ((_main_canvas->GetSize().GetWidth() - 32) / film->length().seconds()); + set_pixels_per_track ((_main_canvas->GetSize().GetHeight() - tracks_y_offset() - _time_axis_view->bbox().height - 32) / _tracks); + Refresh (); + break; + } +} diff --git a/src/wx/timeline.h b/src/wx/timeline.h index 7af770b5f..30f7061d4 100644 --- a/src/wx/timeline.h +++ b/src/wx/timeline.h @@ -46,8 +46,8 @@ public: int width () const; - int track_height () const { - return _track_height; + int pixels_per_track () const { + return _pixels_per_track; } boost::optional<double> pixels_per_second () const { @@ -68,12 +68,11 @@ public: enum Tool { SELECT, - ZOOM + ZOOM, + ZOOM_ALL }; - void set_tool (Tool t) { - _tool = t; - } + void tool_clicked (Tool t); int tracks_y_offset () const; @@ -99,6 +98,8 @@ private: void recreate_views (); void setup_scrollbars (); void scrolled (wxScrollWinEvent& ev); + void set_pixels_per_second (double pps); + void set_pixels_per_track (int h); boost::shared_ptr<TimelineView> event_to_view (wxMouseEvent &); TimelineContentViewList selected_views () const; @@ -128,10 +129,10 @@ private: Tool _tool; int _x_scroll_rate; int _y_scroll_rate; - int _track_height; + int _pixels_per_track; static double const _minimum_pixels_per_second; - static int const _minimum_track_height; + static int const _minimum_pixels_per_track; boost::signals2::scoped_connection _film_changed_connection; boost::signals2::scoped_connection _film_content_changed_connection; diff --git a/src/wx/timeline_content_view.cc b/src/wx/timeline_content_view.cc index 1d0c1668f..88b50076a 100644 --- a/src/wx/timeline_content_view.cc +++ b/src/wx/timeline_content_view.cc @@ -51,7 +51,7 @@ TimelineContentView::bbox () const time_x (content->position ()), y_pos (_track.get()), content->length_after_trim().seconds() * _timeline.pixels_per_second().get_value_or(0), - _timeline.track_height() + _timeline.pixels_per_track() ); } @@ -148,7 +148,7 @@ TimelineContentView::do_paint (wxGraphicsContext* gc, list<dcpomatic::Rect<int> wxDouble name_leading; gc->SetFont (gc->CreateFont (*wxNORMAL_FONT, foreground_colour ())); gc->GetTextExtent (name, &name_width, &name_height, &name_descent, &name_leading); - gc->Clip (wxRegion (time_x (position), y_pos (_track.get()), len.seconds() * _timeline.pixels_per_second().get_value_or(0), _timeline.track_height())); + gc->Clip (wxRegion (time_x (position), y_pos (_track.get()), len.seconds() * _timeline.pixels_per_second().get_value_or(0), _timeline.pixels_per_track())); gc->DrawText (name, time_x (position) + 12, y_pos (_track.get() + 1) - name_height - 4); gc->ResetClip (); } @@ -156,7 +156,7 @@ TimelineContentView::do_paint (wxGraphicsContext* gc, list<dcpomatic::Rect<int> int TimelineContentView::y_pos (int t) const { - return t * _timeline.track_height() + _timeline.tracks_y_offset(); + return t * _timeline.pixels_per_track() + _timeline.tracks_y_offset(); } void diff --git a/src/wx/timeline_dialog.cc b/src/wx/timeline_dialog.cc index dd28f9c23..34706d620 100644 --- a/src/wx/timeline_dialog.cc +++ b/src/wx/timeline_dialog.cc @@ -54,20 +54,23 @@ TimelineDialog::TimelineDialog (ContentPanel* cp, shared_ptr<Film> film) wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL); wxBoxSizer* controls = new wxBoxSizer (wxHORIZONTAL); - _snap = new wxCheckBox (this, wxID_ANY, _("Snap")); - controls->Add (_snap); - _sequence = new wxCheckBox (this, wxID_ANY, _("Keep video and subtitles in sequence")); - controls->Add (_sequence, 1, wxLEFT, 12); - wxToolBar* toolbar = new wxToolBar (this, wxID_ANY); #ifdef DCPOMATIC_LINUX wxBitmap select (wxString::Format (wxT ("%s/select.png"), std_to_wx (shared_path().string())), wxBITMAP_TYPE_PNG); wxBitmap zoom (wxString::Format (wxT ("%s/zoom.png"), std_to_wx (shared_path().string())), wxBITMAP_TYPE_PNG); + wxBitmap zoom_all (wxString::Format (wxT ("%s/zoom_all.png"), std_to_wx (shared_path().string())), wxBITMAP_TYPE_PNG); #endif + wxToolBar* toolbar = new wxToolBar (this, wxID_ANY); toolbar->AddRadioTool ((int) Timeline::SELECT, _("Select"), select); toolbar->AddRadioTool ((int) Timeline::ZOOM, _("Zoom"), zoom); + toolbar->AddTool ((int) Timeline::ZOOM_ALL, _("Zoom to whole project"), zoom_all); controls->Add (toolbar); - toolbar->Bind (wxEVT_TOOL, bind (&TimelineDialog::tool_changed, this, _1)); + toolbar->Bind (wxEVT_TOOL, bind (&TimelineDialog::tool_clicked, this, _1)); + + _snap = new wxCheckBox (this, wxID_ANY, _("Snap")); + controls->Add (_snap); + _sequence = new wxCheckBox (this, wxID_ANY, _("Keep video and subtitles in sequence")); + controls->Add (_sequence, 1, wxLEFT, 12); sizer->Add (controls, 0, wxALL, 12); sizer->Add (&_timeline, 1, wxEXPAND | wxALL, 12); @@ -128,7 +131,7 @@ TimelineDialog::set_selection (ContentList selection) } void -TimelineDialog::tool_changed (wxCommandEvent& ev) +TimelineDialog::tool_clicked (wxCommandEvent& ev) { - _timeline.set_tool ((Timeline::Tool) ev.GetId()); + _timeline.tool_clicked ((Timeline::Tool) ev.GetId()); } diff --git a/src/wx/timeline_dialog.h b/src/wx/timeline_dialog.h index dc583a9f0..0d91baf22 100644 --- a/src/wx/timeline_dialog.h +++ b/src/wx/timeline_dialog.h @@ -36,7 +36,7 @@ private: void snap_toggled (); void sequence_toggled (); void film_changed (Film::Property); - void tool_changed (wxCommandEvent& id); + void tool_clicked (wxCommandEvent& id); boost::weak_ptr<Film> _film; Timeline _timeline; diff --git a/src/wx/timeline_labels_view.cc b/src/wx/timeline_labels_view.cc index 3fe315aaf..3d0b42651 100644 --- a/src/wx/timeline_labels_view.cc +++ b/src/wx/timeline_labels_view.cc @@ -55,13 +55,13 @@ TimelineLabelsView::TimelineLabelsView (Timeline& tl) dcpomatic::Rect<int> TimelineLabelsView::bbox () const { - return dcpomatic::Rect<int> (0, 0, _width, _timeline.tracks() * _timeline.track_height()); + return dcpomatic::Rect<int> (0, 0, _width, _timeline.tracks() * _timeline.pixels_per_track()); } void TimelineLabelsView::do_paint (wxGraphicsContext* gc, list<dcpomatic::Rect<int> >) { - int const h = _timeline.track_height (); + int const h = _timeline.pixels_per_track (); gc->SetFont (gc->CreateFont(wxNORMAL_FONT->Bold(), wxColour (0, 0, 0))); int fy = 0; diff --git a/src/wx/timeline_time_axis_view.cc b/src/wx/timeline_time_axis_view.cc index 48157c9c5..a31ed5ced 100644 --- a/src/wx/timeline_time_axis_view.cc +++ b/src/wx/timeline_time_axis_view.cc @@ -61,7 +61,7 @@ TimelineTimeAxisView::do_paint (wxGraphicsContext* gc, list<dcpomatic::Rect<int> double const mark_interval = calculate_mark_interval (rint (128 / pps)); - int y = _y * _timeline.track_height() + 32; + int y = _y * _timeline.pixels_per_track() + 32; wxGraphicsPath path = gc->CreatePath (); path.MoveToPoint (0, y); |
