From b87b6078ada0773a333ff269b68902052cb64463 Mon Sep 17 00:00:00 2001 From: "Michael R. Fisher" Date: Sun, 23 Oct 2011 00:20:48 -0500 Subject: [PATCH] Adding TimeSpan param to SelectionListener's signal --- src/gui/widgets/timeline/timeline-ibeam-tool.cpp | 13 ++++++------- src/gui/widgets/timeline/timeline-state.cpp | 7 +++++-- src/gui/widgets/timeline/timeline-state.hpp | 12 +++++++----- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/gui/widgets/timeline/timeline-ibeam-tool.cpp b/src/gui/widgets/timeline/timeline-ibeam-tool.cpp index cd397bf3f..6f20997e7 100644 --- a/src/gui/widgets/timeline/timeline-ibeam-tool.cpp +++ b/src/gui/widgets/timeline/timeline-ibeam-tool.cpp @@ -49,8 +49,7 @@ IBeamTool::IBeamTool(TimelineBody &timeline_body) : scrollSlideRate(0) { // Connect the timlinebody selection to the selectionControl - // TODO: Create a virtual initialize function in the base class - get_state()->set_selection_control(selectionControl); + get_state()->set_selection_control (selectionControl); } IBeamTool::~IBeamTool() @@ -122,8 +121,7 @@ IBeamTool::on_button_press_event(GdkEventButton* event) // User began the drag in clear space, begin a Select drag dragType = Selection; pinnedDragTime = time; - selectionControl (TimeSpan(time, Duration::NIL)); //TODO: TimelineState Needs a listener for selection changes - state->selection_changed_signal().emit(); + selectionControl (TimeSpan(time, Duration::NIL)); } } } @@ -194,16 +192,17 @@ IBeamTool::set_leading_x(const int x) { shared_ptr state = get_state(); - const bool set_playback_period = dragType == Selection; + // The line below needs handled differently now; + // + //const bool set_playback_period = dragType == Selection; + TimeVar newStartPoint (state->get_view_window().x_to_time(x)); Offset selectionLength (pinnedDragTime, newStartPoint); if (newStartPoint > pinnedDragTime) newStartPoint=pinnedDragTime; // use the smaller one as selection start - //TODO: TimelineState Needs a listener for selection changes selectionControl (TimeSpan (newStartPoint, Duration(selectionLength))); - state->selection_changed_signal().emit(); } void diff --git a/src/gui/widgets/timeline/timeline-state.cpp b/src/gui/widgets/timeline/timeline-state.cpp index 70a8521cc..3e512cc1e 100644 --- a/src/gui/widgets/timeline/timeline-state.cpp +++ b/src/gui/widgets/timeline/timeline-state.cpp @@ -51,7 +51,10 @@ TimelineState::TimelineState (shared_ptr source_sequence) , isPlayback_(false) { REQUIRE(sequence); - + + // Initialize the listener + selectionListener (TimeSpan (Time::ZERO, Duration::NIL)); + ////////////////////////////////////////////////////////////TICKET #798: how to handle GUI default state const int64_t DEFAULT_TIMELINE_SCALE =21000000; @@ -123,7 +126,7 @@ TimelineState::playback_changed_signal() const } void -TimelineState::on_selection_changed() +TimelineState::on_selection_changed (TimeSpan selection) { selectionChangedSignal.emit(); } diff --git a/src/gui/widgets/timeline/timeline-state.hpp b/src/gui/widgets/timeline/timeline-state.hpp index 2033665db..f4bc57e75 100644 --- a/src/gui/widgets/timeline/timeline-state.hpp +++ b/src/gui/widgets/timeline/timeline-state.hpp @@ -48,27 +48,29 @@ typedef Control 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 */ + template class SelectionListener : boost::noncopyable { - sigc::signal valueChangedSignal; + sigc::signal valueChangedSignal; public: SelectionListener() { } - void operator() (TI const& changeValue) const { - valueChangedSignal.emit(); + valueChangedSignal.emit(changeValue); } - void connect (const sigc::slot &connection) + void connect (const sigc::slot &connection) { valueChangedSignal.connect (connection); } @@ -160,7 +162,7 @@ private: /** * Event handler for when the selection is changed */ - void on_selection_changed(); + void on_selection_changed (TimeSpan selection); private: