From: Carl Hetherington Date: Wed, 4 Jul 2018 00:15:05 +0000 (+0100) Subject: Fix icons on Windows; zoom to all on initial open. X-Git-Tag: v2.13.33~17 X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=7bcf60f8ad3acd4dcae77a120216839b665c4335 Fix icons on Windows; zoom to all on initial open. --- diff --git a/src/wx/timeline.cc b/src/wx/timeline.cc index a0bf50f05..c60568e3a 100644 --- a/src/wx/timeline.cc +++ b/src/wx/timeline.cc @@ -76,6 +76,7 @@ Timeline::Timeline (wxWindow* parent, ContentPanel* cp, shared_ptr film) , _x_scroll_rate (16) , _y_scroll_rate (16) , _pixels_per_track (48) + , _first_resize (true) { #ifndef __WXOSX__ _labels_canvas->SetDoubleBuffered (true); @@ -104,8 +105,6 @@ Timeline::Timeline (wxWindow* parent, ContentPanel* cp, shared_ptr film) _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)); - set_pixels_per_second (static_cast(640) / film->length().seconds ()); - setup_scrollbars (); _labels_canvas->ShowScrollbars (wxSHOW_SB_NEVER, wxSHOW_SB_NEVER); } @@ -395,7 +394,7 @@ Timeline::setup_scrollbars () } _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() * pixels_per_track() + 96); + _main_canvas->SetVirtualSize (*_pixels_per_second * film->length().seconds(), tracks() * pixels_per_track() + tracks_y_offset() + _time_axis_view->bbox().height); _main_canvas->SetScrollRate (_x_scroll_rate, _y_scroll_rate); } @@ -722,6 +721,10 @@ Timeline::film () const void Timeline::resized () { + if (_main_canvas->GetSize().GetWidth() > 0 && _first_resize) { + zoom_all (); + _first_resize = false; + } setup_scrollbars (); } @@ -805,11 +808,20 @@ Timeline::tool_clicked (Tool t) _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 (); + zoom_all (); break; } } + +void +Timeline::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); + setup_scrollbars (); + _main_canvas->Scroll (0, 0); + _labels_canvas->Scroll (0, 0); + Refresh (); +} diff --git a/src/wx/timeline.h b/src/wx/timeline.h index 30f7061d4..2133a537d 100644 --- a/src/wx/timeline.h +++ b/src/wx/timeline.h @@ -100,6 +100,7 @@ private: void scrolled (wxScrollWinEvent& ev); void set_pixels_per_second (double pps); void set_pixels_per_track (int h); + void zoom_all (); boost::shared_ptr event_to_view (wxMouseEvent &); TimelineContentViewList selected_views () const; @@ -130,6 +131,7 @@ private: int _x_scroll_rate; int _y_scroll_rate; int _pixels_per_track; + bool _first_resize; static double const _minimum_pixels_per_second; static int const _minimum_pixels_per_track; diff --git a/src/wx/timeline_dialog.cc b/src/wx/timeline_dialog.cc index 34706d620..d20f89db9 100644 --- a/src/wx/timeline_dialog.cc +++ b/src/wx/timeline_dialog.cc @@ -55,15 +55,14 @@ TimelineDialog::TimelineDialog (ContentPanel* cp, shared_ptr film) wxBoxSizer* controls = new wxBoxSizer (wxHORIZONTAL); -#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); + toolbar->AddRadioTool ((int) Timeline::SELECT, _("Select"), select, wxNullBitmap, _("Select and move content")); + toolbar->AddRadioTool ((int) Timeline::ZOOM, _("Zoom"), zoom, wxNullBitmap, _("Zoom in / out")); + toolbar->AddTool ((int) Timeline::ZOOM_ALL, _("Zoom all"), zoom_all, _("Zoom out to whole film")); controls->Add (toolbar); toolbar->Bind (wxEVT_TOOL, bind (&TimelineDialog::tool_clicked, this, _1));