2009-03-23 23:22:14 +01:00
|
|
|
/*
|
2015-05-29 04:44:58 +02:00
|
|
|
TimelineState - timeline presentation state holder
|
2010-12-17 23:28:49 +01:00
|
|
|
|
2009-03-23 23:22:14 +01:00
|
|
|
Copyright (C) Lumiera.org
|
|
|
|
|
2008, Joel Holdsworth <joel@airwebreathe.org.uk>
|
2010-12-17 23:28:49 +01:00
|
|
|
|
2009-03-23 23:22:14 +01:00
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU General Public License as
|
2010-12-17 23:28:49 +01:00
|
|
|
published by the Free Software Foundation; either version 2 of
|
|
|
|
|
the License, or (at your option) any later version.
|
|
|
|
|
|
2009-03-23 23:22:14 +01:00
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
2010-12-17 23:28:49 +01:00
|
|
|
|
2009-03-23 23:22:14 +01:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
2010-12-17 23:28:49 +01:00
|
|
|
|
2009-03-23 23:22:14 +01:00
|
|
|
* *****************************************************/
|
|
|
|
|
|
|
|
|
|
|
2015-05-29 04:44:58 +02:00
|
|
|
#include "gui/widget/timeline/timeline-state.hpp"
|
2011-05-16 08:38:01 +02:00
|
|
|
#include "lib/time/timevalue.hpp"
|
|
|
|
|
#include "lib/time/mutation.hpp"
|
2011-10-23 04:53:23 +02:00
|
|
|
#include "lib/time/control.hpp"
|
2011-05-16 08:38:01 +02:00
|
|
|
|
2009-03-23 23:22:14 +01:00
|
|
|
using namespace Gtk;
|
|
|
|
|
using namespace sigc;
|
|
|
|
|
|
|
|
|
|
namespace gui {
|
2015-05-29 04:44:58 +02:00
|
|
|
namespace widget {
|
2009-03-23 23:22:14 +01:00
|
|
|
namespace timeline {
|
2011-10-21 00:58:15 +02:00
|
|
|
|
2015-05-29 04:44:58 +02:00
|
|
|
using lib::time::FSecs;
|
|
|
|
|
using lib::time::Offset;
|
|
|
|
|
using lib::time::Duration;
|
|
|
|
|
using lib::time::Mutation;
|
|
|
|
|
using lib::time::Control;
|
|
|
|
|
using std::shared_ptr;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TimelineState::TimelineState (shared_ptr<model::Sequence> sourceSequence)
|
|
|
|
|
: sequence_(sourceSequence)
|
|
|
|
|
, viewWindow_(Offset(Time::ZERO), 1)
|
|
|
|
|
, selection_(Time::ZERO, Duration::NIL)
|
|
|
|
|
, selectionListener_()
|
|
|
|
|
, playbackPeriod_(Time::ZERO, Duration::NIL)
|
|
|
|
|
, playbackPoint_(Time::ZERO)
|
|
|
|
|
, isPlayback_(false)
|
|
|
|
|
{
|
|
|
|
|
REQUIRE(sequence_);
|
|
|
|
|
|
|
|
|
|
// Initialise the selection listener
|
|
|
|
|
selectionListener_ (TimeSpan (Time::ZERO, Duration::NIL));
|
|
|
|
|
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))));
|
|
|
|
|
//////////////////////////////////////////////////////TICKET #797 : this looks cheesy. Should provide a single Mutation to change all
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
shared_ptr<model::Sequence>
|
|
|
|
|
TimelineState::getSequence() const
|
|
|
|
|
{
|
|
|
|
|
return sequence_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TimelineViewWindow&
|
|
|
|
|
TimelineState::getViewWindow()
|
|
|
|
|
{
|
|
|
|
|
return viewWindow_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
TimelineState::setSelection (Mutation const& change,
|
|
|
|
|
bool resetPlaybackPeriod)
|
|
|
|
|
{
|
|
|
|
|
selection_.accept (change);
|
|
|
|
|
if (resetPlaybackPeriod)
|
|
|
|
|
setPlaybackPeriod(change);
|
|
|
|
|
|
|
|
|
|
selectionChangedSignal_.emit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
TimelineState::setPlaybackPeriod (Mutation const& change)
|
|
|
|
|
{
|
|
|
|
|
playbackPeriod_.accept (change);
|
|
|
|
|
playbackChangedSignal_.emit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
TimelineState::setPlaybackPoint (Time newPosition)
|
|
|
|
|
{
|
|
|
|
|
playbackPoint_ = newPosition;
|
|
|
|
|
playbackChangedSignal_.emit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
TimelineState::setSelectionControl (SelectionControl &control)
|
|
|
|
|
{
|
|
|
|
|
control.disconnect();
|
|
|
|
|
selection_.accept (control);
|
|
|
|
|
control.connectChangeNotification (selectionListener_);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sigc::signal<void>
|
|
|
|
|
TimelineState::selectionChangedSignal() const
|
|
|
|
|
{
|
|
|
|
|
return selectionChangedSignal_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sigc::signal<void>
|
|
|
|
|
TimelineState::playbackChangedSignal() const
|
|
|
|
|
{
|
|
|
|
|
return playbackChangedSignal_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
TimelineState::on_selection_changed (TimeSpan)
|
|
|
|
|
{
|
|
|
|
|
selectionChangedSignal_.emit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}}}// namespace gui::widget::timeline
|