Adding TimeSpan param to SelectionListener's signal

This commit is contained in:
Michael R. Fisher 2011-10-23 00:20:48 -05:00
parent 3811183546
commit b87b6078ad
3 changed files with 18 additions and 14 deletions

View file

@ -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<TimelineState> 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

View file

@ -51,7 +51,10 @@ TimelineState::TimelineState (shared_ptr<model::Sequence> 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();
}

View file

@ -48,27 +48,29 @@ 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
*/
template<class TI>
class SelectionListener
: boost::noncopyable
{
sigc::signal<void> valueChangedSignal;
sigc::signal<void, TI> valueChangedSignal;
public:
SelectionListener()
{
}
void
operator() (TI const& changeValue) const
{
valueChangedSignal.emit();
valueChangedSignal.emit(changeValue);
}
void connect (const sigc::slot<void> &connection)
void connect (const sigc::slot<void, TI> &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: