From aaaa51f6d9eda60ab3b3d182c6d2a7a5bda375aa Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 4 Jul 2018 00:51:31 +0100 Subject: [PATCH] Add zoom-all button. --- graphics/src/zoom_all.svg | 81 ++++++++++++++++++++++++++++++ graphics/update | 5 +- graphics/web/favicon-128x128.png | Bin 25054 -> 25054 bytes graphics/web/favicon-16x16.png | Bin 1977 -> 1977 bytes graphics/web/favicon-32x32.png | Bin 3755 -> 3755 bytes graphics/web/favicon-64x64.png | Bin 9595 -> 9595 bytes graphics/wscript | 1 + graphics/zoom_all.png | Bin 0 -> 796 bytes src/wx/timeline.cc | 65 ++++++++++++++++++------ src/wx/timeline.h | 17 ++++--- src/wx/timeline_content_view.cc | 6 +-- src/wx/timeline_dialog.cc | 19 ++++--- src/wx/timeline_dialog.h | 2 +- src/wx/timeline_labels_view.cc | 4 +- src/wx/timeline_time_axis_view.cc | 2 +- 15 files changed, 163 insertions(+), 39 deletions(-) create mode 100644 graphics/src/zoom_all.svg create mode 100644 graphics/zoom_all.png diff --git a/graphics/src/zoom_all.svg b/graphics/src/zoom_all.svg new file mode 100644 index 000000000..a1b253a77 --- /dev/null +++ b/graphics/src/zoom_all.svg @@ -0,0 +1,81 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/graphics/update b/graphics/update index 9c14f2157..50923fc69 100755 --- a/graphics/update +++ b/graphics/update @@ -66,8 +66,9 @@ else $INKSCAPE splash.png src/splash.svg -w 400 -h 300 # Timeline toolbar icons (all platforms) - $INKSCAPE select.png src/select.svg -w 24 -h 24 - $INKSCAPE zoom.png src/zoom.svg -w 24 -h 24 + for i in select zoom zoom_all; do + $INKSCAPE $i.png src/$i.svg -w 24 -h 24 + done # favicon mkdir -p web diff --git a/graphics/web/favicon-128x128.png b/graphics/web/favicon-128x128.png index bc58be5941951f8110c57238c136fee765a36547..415c7f7647f16f8fcaacc0ca421e6f54a91b5b22 100644 GIT binary patch delta 73 zcmcb2nDO3W#tm;6IanBY*k_z>Jh=G_O|49ftqhH|4GgUe40gt}OrLy$O%_Aq M1fz}iwTocx;i002L%7Nr0H delta 71 zcmZ22yIOX`8%7RBer?`)k-1wpe_`CjEn*mAXli9*Y-MPyZD43+V6Zc$W%}e@ys{V) NCm3zCC%@)B001ew73Kf{ diff --git a/graphics/web/favicon-64x64.png b/graphics/web/favicon-64x64.png index 7537c82203f2074d58ca8e26e889e076112dd9d3..8d968b9f7a509a60679e84e4ddc1ac8933ea9f22 100644 GIT binary patch delta 71 zcmezE_1kO18%7Qm1|IeqryCD${=(R#Bw`X`U|?lvWMyEkZD43+VDL2bh3Moi6GJSHFiY$i2 N2}T?3$-7k!003oO7L@=1 diff --git a/graphics/wscript b/graphics/wscript index 1be119783..7f88cd069 100644 --- a/graphics/wscript +++ b/graphics/wscript @@ -31,4 +31,5 @@ def build(bld): bld.install_as('${PREFIX}/share/dcpomatic2/dcpomatic2_server_small.png', 'linux/16/dcpomatic2.png') bld.install_files('${PREFIX}/share/dcpomatic2', 'splash.png') bld.install_files('${PREFIX}/share/dcpomatic2', 'zoom.png') + bld.install_files('${PREFIX}/share/dcpomatic2', 'zoom_all.png') bld.install_files('${PREFIX}/share/dcpomatic2', 'select.png') diff --git a/graphics/zoom_all.png b/graphics/zoom_all.png new file mode 100644 index 0000000000000000000000000000000000000000..74c719f82ae415309456fe5412b7d4ed6ac776e8 GIT binary patch literal 796 zcmV+%1LOROP)Eoz z(9x+lRnV!pb&^6i*C2w@Aub&%B26#`3bwekXrVNcVv9issU$iiUVg8GrijLPieI?l zc<(-+-{Z$U;qo*C{Xh#)1N;THfF)q3%y(C&8(0Pmpd}syd;r>S0v{6*S44DRU_j^R z=XG;)Q`70RZftDm?Ch+DLLmiIMDoCk>%d|rRsNpM$589L~bPT`FzyZ*8^CW2@bQ_?1js@ zPO{l7K;|;R@BRIKIXF1D5qx)dm!qR20sfS#R{&9C%=1JdK|Y^ndwbh6{P_5oSS(h2 z{aC6;fJPDd)!Es3cVuMbS{I?Jgu`J?CXCn)S_V)H_ZEdaLWL3MsjAdC{ zD=RC7OeUjqb8|V%vOGxu9sqAeG%G7R6QZ5a) zZT~zc`Fz`wM%%WNiA2I=G8vtop3eFG{;As({Ff{)E}B>@rp?XG?{8ZG(BL@EJI8V2 aK+8Y-Sj4Syv@}Bi0000 film) : wxPanel (parent, wxID_ANY) @@ -75,7 +75,7 @@ Timeline::Timeline (wxWindow* parent, ContentPanel* cp, shared_ptr 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,17 +99,23 @@ Timeline::Timeline (wxWindow* parent, ContentPanel* cp, shared_ptr 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(640) / film->length().seconds ()); + set_pixels_per_second (static_cast(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 () { @@ -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,20 +541,26 @@ 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 (); Refresh (); } +void +Timeline::set_pixels_per_track (int h) +{ + _pixels_per_track = max(_minimum_pixels_per_track, h); +} + void Timeline::mouse_moved (wxMouseEvent& ev) { @@ -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.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 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 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 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 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) 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; 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 TimelineLabelsView::bbox () const { - return dcpomatic::Rect (0, 0, _width, _timeline.tracks() * _timeline.track_height()); + return dcpomatic::Rect (0, 0, _width, _timeline.tracks() * _timeline.pixels_per_track()); } void TimelineLabelsView::do_paint (wxGraphicsContext* gc, list >) { - 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 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); -- 2.30.2