Added SelectionListener handling selection changing events
This commit is contained in:
parent
8ff36fc209
commit
3811183546
3 changed files with 75 additions and 4 deletions
|
|
@ -49,7 +49,8 @@ IBeamTool::IBeamTool(TimelineBody &timeline_body) :
|
|||
scrollSlideRate(0)
|
||||
{
|
||||
// Connect the timlinebody selection to the selectionControl
|
||||
this->get_state()->setSelection (selectionControl, false);
|
||||
// TODO: Create a virtual initialize function in the base class
|
||||
get_state()->set_selection_control(selectionControl);
|
||||
}
|
||||
|
||||
IBeamTool::~IBeamTool()
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#include "gui/widgets/timeline/timeline-state.hpp"
|
||||
#include "lib/time/timevalue.hpp"
|
||||
#include "lib/time/mutation.hpp"
|
||||
#include "lib/time/control.hpp"
|
||||
|
||||
using namespace Gtk;
|
||||
using namespace sigc;
|
||||
|
|
@ -36,14 +37,15 @@ using lib::time::FSecs;
|
|||
using lib::time::Offset;
|
||||
using lib::time::Duration;
|
||||
using lib::time::Mutation;
|
||||
using lib::time::Control;
|
||||
using std::tr1::shared_ptr;
|
||||
|
||||
|
||||
|
||||
TimelineState::TimelineState (shared_ptr<model::Sequence> source_sequence)
|
||||
: sequence(source_sequence)
|
||||
, viewWindow(Offset(Time::ZERO), 1)
|
||||
, selection_(Time::ZERO, Duration::NIL)
|
||||
, selectionListener()
|
||||
, playbackPeriod_(Time::ZERO, Duration::NIL)
|
||||
, playbackPoint_(Time::ZERO)
|
||||
, isPlayback_(false)
|
||||
|
|
@ -55,6 +57,9 @@ TimelineState::TimelineState (shared_ptr<model::Sequence> source_sequence)
|
|||
|
||||
viewWindow.set_time_scale(DEFAULT_TIMELINE_SCALE);
|
||||
|
||||
selectionListener.connect(
|
||||
mem_fun(*this, &TimelineState::on_selection_changed));
|
||||
|
||||
setSelection (Mutation::changeTime (Time(FSecs(2))));
|
||||
setSelection (Mutation::changeDuration(Duration(FSecs(2))));
|
||||
//////////////////////////////////////////////////////TICKET #797 : this is cheesy. Should provide a single Mutation to change all
|
||||
|
|
@ -97,6 +102,14 @@ TimelineState::setPlaybackPoint (Time newPosition)
|
|||
playbackChangedSignal.emit();
|
||||
}
|
||||
|
||||
void
|
||||
TimelineState::set_selection_control (SelectionControl &control)
|
||||
{
|
||||
control.disconnect();
|
||||
selection_.accept (control);
|
||||
control.connectChangeNotification (selectionListener);
|
||||
}
|
||||
|
||||
sigc::signal<void>
|
||||
TimelineState::selection_changed_signal() const
|
||||
{
|
||||
|
|
@ -109,6 +122,12 @@ TimelineState::playback_changed_signal() const
|
|||
return playbackChangedSignal;
|
||||
}
|
||||
|
||||
void
|
||||
TimelineState::on_selection_changed()
|
||||
{
|
||||
selectionChangedSignal.emit();
|
||||
}
|
||||
|
||||
} // namespace timeline
|
||||
} // namespace widgets
|
||||
} // namespace gui
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include "gui/widgets/timeline/timeline-view-window.hpp"
|
||||
#include "lib/time/mutation.hpp"
|
||||
#include "lib/time/control.hpp"
|
||||
|
||||
|
||||
namespace gui {
|
||||
|
|
@ -38,9 +39,42 @@ class Sequence;
|
|||
|
||||
namespace widgets {
|
||||
namespace timeline {
|
||||
|
||||
|
||||
using lib::time::Control;
|
||||
using lib::time::Mutation;
|
||||
|
||||
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.
|
||||
*/
|
||||
template<class TI>
|
||||
class SelectionListener
|
||||
: boost::noncopyable
|
||||
{
|
||||
sigc::signal<void> valueChangedSignal;
|
||||
public:
|
||||
SelectionListener()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
operator() (TI const& changeValue) const
|
||||
{
|
||||
valueChangedSignal.emit();
|
||||
}
|
||||
|
||||
|
||||
void connect (const sigc::slot<void> &connection)
|
||||
{
|
||||
valueChangedSignal.connect (connection);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* TimelineState is a container for the state data for TimelineWidget.
|
||||
* @remarks TimelineState s can be swapped out so that TimelineWidget
|
||||
|
|
@ -70,7 +104,11 @@ public:
|
|||
*/
|
||||
timeline::TimelineViewWindow& get_view_window();
|
||||
|
||||
TimeSpan get_selection() const { return selection_; }
|
||||
TimeSpan& get_selection() { return selection_; }
|
||||
|
||||
SelectionListener<TimeSpan>&
|
||||
get_selection_listener() { return selectionListener; }
|
||||
|
||||
Time getSelectionStart() const { return selection_.start();}
|
||||
Time getSelectionEnd() const { return selection_.end(); }
|
||||
Time getPlaybackPeriodStart() const { return selection_.start();}
|
||||
|
|
@ -83,6 +121,7 @@ public:
|
|||
* Otherwise the #getPlaybackPoint is meaningless */
|
||||
bool isPlaying() const { return isPlayback_; }
|
||||
|
||||
void set_selection_control (SelectionControl &control);
|
||||
|
||||
/**
|
||||
* Sets the period of the selection.
|
||||
|
|
@ -113,6 +152,15 @@ public:
|
|||
* changed.
|
||||
*/
|
||||
sigc::signal<void> playback_changed_signal() const;
|
||||
|
||||
private:
|
||||
|
||||
/* ========= Event Handlers ========== */
|
||||
|
||||
/**
|
||||
* Event handler for when the selection is changed
|
||||
*/
|
||||
void on_selection_changed();
|
||||
|
||||
private:
|
||||
|
||||
|
|
@ -134,6 +182,9 @@ private:
|
|||
/** currently selected time period. */
|
||||
TimeSpan selection_;
|
||||
|
||||
/** listens for a selection change */
|
||||
SelectionListener<TimeSpan> selectionListener;
|
||||
|
||||
/** current playback period. */
|
||||
TimeSpan playbackPeriod_;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue