Timeline is no longer zoomed in to far on startup. See timline-view-window.hpp int64_t timeScale for explanation

This commit is contained in:
Michael R. Fisher 2011-10-23 04:20:39 -05:00
parent b87b6078ad
commit 6c17d06e66
7 changed files with 52 additions and 40 deletions

View file

@ -138,12 +138,13 @@ TimelinePanel::TimelinePanel (workspace::PanelManager &panel_manager,
// wire the zoom slider to react on timeline state changes
zoomScale.wireTimelineState (timelineWidget->get_state(),
timelineWidget->state_changed_signal());
// Set the initial UI state
update_sequence_chooser();
update_tool_buttons();
update_zoom_buttons();
show_time (Time::ZERO);
std::cout << timelineWidget->get_state()->get_view_window().get_time_scale() << "\n";
}
const char*
@ -335,17 +336,17 @@ TimelinePanel::update_zoom_buttons()
{
REQUIRE(timelineWidget);
const shared_ptr<timeline::TimelineState> state =
timelineWidget->get_state();
if(state)
{
timeline::TimelineViewWindow &viewWindow =
state->get_view_window();
zoomIn.set_sensitive(viewWindow.get_time_scale() != 1);
zoomOut.set_sensitive(viewWindow.get_time_scale()
!= TimelineWidget::MaxScale);
}
int64_t current_scale =
timelineWidget->get_state()->get_view_window().get_time_scale();
double linear_scale =
(double) current_scale / (double) TimelineWidget::MaxScale;
/* We have to Revese the Smoothing */
double new_relative_scale =
pow(linear_scale,(1.0/9.0));
timelineWidget->zoom_view (new_relative_scale);
}
void

View file

@ -180,8 +180,8 @@ IBeamTool::on_motion_notify_event(GdkEventMotion *event)
bool
IBeamTool::on_scroll_slide_timer()
{
const Gdk::Rectangle body_rect(get_body_rectangle());
view_window().shift_view(body_rect.get_width(), scrollSlideRate);
const Gdk::Rectangle body_rect (get_body_rectangle());
view_window().shift_view (body_rect.get_width(), scrollSlideRate);
// Return true to keep the timer going
return true;

View file

@ -52,19 +52,18 @@ TimelineState::TimelineState (shared_ptr<model::Sequence> source_sequence)
{
REQUIRE(sequence);
// Initialize the listener
// Initialize the selection listener
selectionListener (TimeSpan (Time::ZERO, Duration::NIL));
////////////////////////////////////////////////////////////TICKET #798: how to handle GUI default state
const int64_t DEFAULT_TIMELINE_SCALE =21000000;
viewWindow.set_time_scale(DEFAULT_TIMELINE_SCALE);
selectionListener.connect(
mem_fun(*this, &TimelineState::on_selection_changed));
////////////////////////////////////////////////////////////TICKET #798: how to handle GUI default state
const int64_t DEFAULT_TIMELINE_SCALE =6400;
viewWindow.set_time_scale(DEFAULT_TIMELINE_SCALE);
setSelection (Mutation::changeTime (Time(FSecs(2))));
setSelection (Mutation::changeDuration(Duration(FSecs(2))));
setSelection (Mutation::changeDuration (Duration(FSecs(2))));
//////////////////////////////////////////////////////TICKET #797 : this is cheesy. Should provide a single Mutation to change all
}

View file

@ -49,7 +49,9 @@ typedef Control<TimeSpan> SelectionControl;
* SelectionListener is a template class which emits a signal when
* the value is changed by it's associated time::Control object.
* SelectionListener wraps a sigc::signal that emits every time
* the selection is changed
* the selection is changed by the time::Control object.
* SelectionListener does NOT emit the signal if a change to the
* selection is made outside of the Control/Listener partnership.
*/
template<class TI>
@ -66,7 +68,7 @@ class SelectionListener
void
operator() (TI const& changeValue) const
{
valueChangedSignal.emit(changeValue);
valueChangedSignal.emit (changeValue);
}

View file

@ -138,6 +138,13 @@ public:
private:
TimeVar timeOffset;
/**
* The scale of the Timline Body.
* @remarks This value represents the time span that is visible in
* the TimelineBodyWidget. Smaller numbers here will "zoom in"
* while larger numbers will "zoom out"
*/
int64_t timeScale;
sigc::signal<void> changedSignal;

View file

@ -65,26 +65,27 @@ TimelineZoomScale::TimelineZoomScale()
, button_step_size(0.03)
{
/* Setup the Slider Control */
slider.set_adjustment(adjustment);
slider.set_size_request(123,10);
slider.set_digits(6);
slider.set_inverted(true);
slider.set_draw_value(false);
slider.set_adjustment (adjustment);
slider.set_size_request (123,10);
slider.set_digits (6);
/* Inverted because smaller values "zoom in" */
slider.set_inverted (true);
slider.set_draw_value (false);
/* Make our connections */
zoomIn.signal_clicked().
connect(sigc::mem_fun(this, &TimelineZoomScale::on_zoom_in_clicked));
connect (sigc::mem_fun(this, &TimelineZoomScale::on_zoom_in_clicked));
zoomOut.signal_clicked().
connect(sigc::mem_fun(this, &TimelineZoomScale::on_zoom_out_clicked));
connect (sigc::mem_fun(this, &TimelineZoomScale::on_zoom_out_clicked));
adjustment.signal_value_changed().
connect(sigc::mem_fun(this, &TimelineZoomScale::on_zoom));
connect (sigc::mem_fun(this, &TimelineZoomScale::on_zoom));
/* Add Our Widgets and show them */
pack_start(zoomOut,PACK_SHRINK);
pack_start(slider,PACK_SHRINK);
pack_start(zoomIn,PACK_SHRINK);
pack_start (zoomOut,PACK_SHRINK);
pack_start (slider,PACK_SHRINK);
pack_start (zoomIn,PACK_SHRINK);
show_all();
}
@ -94,7 +95,8 @@ TimelineZoomScale::wireTimelineState (shared_ptr<TimelineState> currentState,
TimelineWidget::TimelineStateChangeSignal stateChangeSignal)
{
on_timeline_state_changed (currentState);
stateChangeSignal.connect (sigc::mem_fun(this, &TimelineZoomScale::on_timeline_state_changed));
stateChangeSignal.connect (
sigc::mem_fun(this, &TimelineZoomScale::on_timeline_state_changed));
}
void
@ -110,7 +112,6 @@ TimelineZoomScale::on_timeline_state_changed (shared_ptr<TimelineState> newState
(double) current_scale / (double) TimelineWidget::MaxScale;
/* We have to Revese the Smoothing */
TODO("Find a central place for ZoomSmoothingFactor Variable. right now it is 9.0");
double new_relative_scale =
pow(linear_scale,(1.0/9.0));
@ -134,7 +135,7 @@ TimelineZoomScale::on_zoom_out_clicked()
void
TimelineZoomScale::on_zoom()
{
zoomSignal.emit(adjustment.get_value()) ;
zoomSignal.emit (adjustment.get_value()) ;
}
sigc::signal<void, double>

View file

@ -51,6 +51,8 @@ public:
*/
sigc::signal<void, double> signal_zoom();
void set_value(double val) { adjustment.set_value(val); }
void wireTimelineState (shared_ptr<TimelineState> currentState,
TimelineWidget::TimelineStateChangeSignal);