Review the new TimelineZoomScale widget code

This commit is contained in:
Fischlurch 2011-10-07 03:49:51 +02:00
parent e0463da204
commit caace00dd5
5 changed files with 25 additions and 19 deletions

View file

@ -124,6 +124,7 @@ TimelinePanel::TimelinePanel (workspace::PanelManager &panel_manager,
zoomIn .set_tooltip_text(_("Zoom in"));
zoomOut .set_tooltip_text(_("Zoom out"));
zoomScale .set_tooltip_text(_("Adjust timeline zoom scale"));
// Setup the timeline widget
shared_ptr<Sequence> sequence ///////////////////////////////TICKET #796

View file

@ -264,7 +264,7 @@ TimelineBody::on_motion_notify_event(GdkEventMotion *event)
{
TimelineViewWindow &window = view_window();
/////////////////////////////TICKET# 795 : don't reach in from outside and manipulate internals of the timeline view!
/////////////////////////////TICKET #795 : don't reach in from outside and manipulate internals of the timeline view!
///////////////////////////// : either encapsulate this entirely here, or leave it to the timeline view!
const int64_t scale = window.get_time_scale();
window.set_time_offset(beginShiftTimeOffset

View file

@ -38,20 +38,20 @@ TimelineViewWindow::TimelineViewWindow (Offset offset, int64_t scale)
}
Offset
TimelineViewWindow::get_time_offset() const /////////////////////TODO: this function shouldn't be accessible from outside
TimelineViewWindow::get_time_offset() const /////////////////////TICKET #795: this function shouldn't be accessible from outside
{
return Offset (timeOffset);
}
void
TimelineViewWindow::set_time_offset(TimeValue const& offset) /////////TODO: this function shouldn't be accessible from outside
TimelineViewWindow::set_time_offset(TimeValue const& offset) /////////TICKET #795: this function shouldn't be accessible from outside
{
timeOffset = offset;
changedSignal.emit();
}
int64_t
TimelineViewWindow::get_time_scale() const /////////////////////TODO: this function shouldn't be accessible from outside
TimelineViewWindow::get_time_scale() const /////////////////////TICKET #795: this function shouldn't be accessible from outside
{
return timeScale;
}
@ -64,21 +64,11 @@ TimelineViewWindow::set_time_scale(int64_t scale)
}
void
TimelineViewWindow::zoom_view(int point, int64_t zoom_scale)
TimelineViewWindow::zoom_view(int point, int64_t new_time_scale)
{
int64_t new_time_scale = zoom_scale;
// Limit zooming in too close
if(new_time_scale < 1) new_time_scale = 1;
/* Not sure if this is still needed. MRF
* // Nudge zoom problems caused by integer rounding
if(new_time_scale == timeScale && zoom_size < 0)
new_time_scale++;
*/
// Limit to Min and Max scale code moved to timeline-zoom-scale.cpp
// The view must be shifted so that the zoom is centred on the cursor
TimeVar newStartPoint = get_time_offset();
newStartPoint += TimeValue(point * (timeScale - new_time_scale));

View file

@ -98,10 +98,10 @@ public:
/**
* Zooms the view in or out as by a number of steps while keeping a
* given point on the timeline still.
* @param zoom_size The number of steps to zoom by. The scale factor
* is 1.25^(-zoom_size).
* @param new_time_scale The number of steps to zoom by. The scale factor
* is 1.25^(-new_time_scale).
*/
void zoom_view(int point, int64_t zoom_size);
void zoom_view(int point, int64_t new_time_scale);
/**
* Scrolls the view horizontally as a proportion of the view area.

View file

@ -33,12 +33,27 @@ class TimelineWidget;
namespace timeline {
/**
* TODO: The initial adjustment value needs to
* @todo The initial adjustment value needs to
* match what the TimelineViewWindow's actual timeScale
* Value is. TimelineViewWindow::get_time_scale() is
* currently a public method, but will soon be private.
* Maybe TimelineViewWindow can have a zoom_adjustment
* that gets passed to this widget's Constructor?
*
* @todo actually there is a more involved problem.
* The TimelineWidget maintains a TimelineState, which in turn
* owns the TimelineViewWindow. Now, the problem is: when we
* switch to another Sequence (View), then this TimelineState
* gets switched too, causing also a entirely different TimelineViewWindow
* to become effective. Thus
* - how can we managed to be notified from that switch?
* - problem is: TimelineZoomScale widget is owned by the TimelinePannel.
* Likewise, TimelineWidget is owned by the TimelinePannel. But the
* state handling/switching logic is embedded within TimelineWidget
* - and finally: how can we translate the actual scale (in time units),
* as maintained within TimelineViewWindow, back into the adjustment
* used here (which uses a relative scale 0...1.0 )
*
*/
TimelineZoomScale::TimelineZoomScale()