, _x_scroll_rate (16)
, _y_scroll_rate (16)
, _pixels_per_track (48)
+ , _first_resize (true)
{
#ifndef __WXOSX__
_labels_canvas->SetDoubleBuffered (true);
_main_canvas->Bind (wxEVT_RIGHT_DOWN, boost::bind (&Timeline::right_down, this, _1));
_main_canvas->Bind (wxEVT_MOTION, boost::bind (&Timeline::mouse_moved, this, _1));
_main_canvas->Bind (wxEVT_SIZE, boost::bind (&Timeline::resized, this));
- _main_canvas->Bind (wxEVT_SCROLLWIN_THUMBTRACK, boost::bind (&Timeline::scrolled, this, _1));
+ _main_canvas->Bind (wxEVT_SCROLLWIN_TOP, boost::bind (&Timeline::scrolled, this, _1));
+ _main_canvas->Bind (wxEVT_SCROLLWIN_BOTTOM, boost::bind (&Timeline::scrolled, this, _1));
+ _main_canvas->Bind (wxEVT_SCROLLWIN_LINEUP, boost::bind (&Timeline::scrolled, this, _1));
+ _main_canvas->Bind (wxEVT_SCROLLWIN_LINEDOWN, boost::bind (&Timeline::scrolled, this, _1));
+ _main_canvas->Bind (wxEVT_SCROLLWIN_PAGEUP, boost::bind (&Timeline::scrolled, this, _1));
+ _main_canvas->Bind (wxEVT_SCROLLWIN_PAGEDOWN, boost::bind (&Timeline::scrolled, this, _1));
+ _main_canvas->Bind (wxEVT_SCROLLWIN_THUMBTRACK, boost::bind (&Timeline::scrolled, this, _1));
film_changed (Film::CONTENT);
_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<double>(640) / film->length().seconds ());
-
setup_scrollbars ();
_labels_canvas->ShowScrollbars (wxSHOW_SB_NEVER, wxSHOW_SB_NEVER);
}
/* Audio */
- place<TimelineAudioContentView> (_views, _tracks);
+ int const audio_tracks = place<TimelineAudioContentView> (_views, _tracks);
_labels_view->set_3d (have_3d);
+ _labels_view->set_audio_tracks (audio_tracks);
_labels_view->set_subtitle_tracks (subtitle_tracks);
_labels_view->set_atmos (have_atmos);
if (!film || !_pixels_per_second) {
return;
}
- _labels_canvas->SetVirtualSize (_labels_view->bbox().width, tracks() * pixels_per_track() + 96);
+
+ int const h = tracks() * pixels_per_track() + tracks_y_offset() + _time_axis_view->bbox().height;
+
+ _labels_canvas->SetVirtualSize (_labels_view->bbox().width, h);
_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(), h);
_main_canvas->SetScrollRate (_x_scroll_rate, _y_scroll_rate);
}
break;
case ZOOM:
case ZOOM_ALL:
+ case SNAP:
+ case SEQUENCE:
/* Nothing to do */
break;
}
left_up_zoom (ev);
break;
case ZOOM_ALL:
+ case SNAP:
+ case SEQUENCE:
break;
}
}
DCPTime const time_right = DCPTime::from_seconds((bottom_right.x + vsx) / *_pixels_per_second);
set_pixels_per_second (double(GetSize().GetWidth()) / (time_right.seconds() - time_left.seconds()));
- double const tracks_top = double(top_left.y) / _pixels_per_track;
- double const tracks_bottom = double(bottom_right.y) / _pixels_per_track;
+ double const tracks_top = double(top_left.y - tracks_y_offset()) / _pixels_per_track;
+ double const tracks_bottom = double(bottom_right.y - tracks_y_offset()) / _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 * _pixels_per_track / _y_scroll_rate);
- _labels_canvas->Scroll (0, tracks_top * _pixels_per_track / _y_scroll_rate);
+ int const y = (tracks_top * _pixels_per_track + tracks_y_offset()) / _y_scroll_rate;
+ _main_canvas->Scroll (time_left.seconds() * *_pixels_per_second / _x_scroll_rate, y);
+ _labels_canvas->Scroll (0, y);
_zoom_point = optional<wxPoint> ();
Refresh ();
mouse_moved_zoom (ev);
break;
case ZOOM_ALL:
+ case SNAP:
+ case SEQUENCE:
break;
}
}
Refresh ();
break;
case ZOOM_ALL:
+ case SNAP:
+ case SEQUENCE:
break;
}
}
void
Timeline::resized ()
{
+ if (_main_canvas->GetSize().GetWidth() > 0 && _first_resize) {
+ zoom_all ();
+ _first_resize = false;
+ }
setup_scrollbars ();
}
Timeline::scrolled (wxScrollWinEvent& ev)
{
if (ev.GetOrientation() == wxVERTICAL) {
- _labels_canvas->Scroll (0, ev.GetPosition ());
+ int x, y;
+ _main_canvas->GetViewStart (&x, &y);
+ _labels_canvas->Scroll (0, y);
}
ev.Skip ();
}
_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 ();
+ zoom_all ();
+ break;
+ case SNAP:
+ case SEQUENCE:
break;
}
}
+
+void
+Timeline::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);
+ setup_scrollbars ();
+ _main_canvas->Scroll (0, 0);
+ _labels_canvas->Scroll (0, 0);
+ Refresh ();
+}