2008-04-19 21:31:27 +02:00
|
|
|
/*
|
2008-05-31 14:22:15 +02:00
|
|
|
timeline-widget.cpp - Implementation of the timeline widget
|
2008-04-19 21:31:27 +02:00
|
|
|
|
|
|
|
|
Copyright (C) Lumiera.org
|
|
|
|
|
2008, Joel Holdsworth <joel@airwebreathe.org.uk>
|
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU General Public License as
|
|
|
|
|
published by the Free Software Foundation; either version 2 of the
|
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
|
|
* *****************************************************/
|
|
|
|
|
|
|
|
|
|
#include "timeline-widget.hpp"
|
|
|
|
|
|
2008-06-07 14:53:17 +02:00
|
|
|
#include <boost/foreach.hpp>
|
2008-11-29 17:13:58 +01:00
|
|
|
#include <typeinfo>
|
2008-06-07 14:53:17 +02:00
|
|
|
|
2008-05-22 20:19:04 +02:00
|
|
|
using namespace Gtk;
|
2008-05-31 14:22:15 +02:00
|
|
|
using namespace std;
|
2008-12-06 15:08:03 +01:00
|
|
|
using namespace boost;
|
2008-12-06 15:52:59 +01:00
|
|
|
using namespace util;
|
2008-10-18 01:13:27 +02:00
|
|
|
using namespace gui::widgets::timeline;
|
2008-05-22 20:19:04 +02:00
|
|
|
|
2008-04-19 21:31:27 +02:00
|
|
|
namespace gui {
|
|
|
|
|
namespace widgets {
|
|
|
|
|
|
2008-05-31 19:21:05 +02:00
|
|
|
const int TimelineWidget::TrackPadding = 1;
|
2008-11-15 16:17:26 +01:00
|
|
|
const int TimelineWidget::HeaderWidth = 150;
|
2009-01-02 16:26:12 +01:00
|
|
|
const int TimelineWidget::HeaderIndentWidth = 10;
|
2008-06-23 12:17:19 +02:00
|
|
|
const double TimelineWidget::ZoomIncrement = 1.25;
|
2008-06-23 16:42:14 +02:00
|
|
|
const int64_t TimelineWidget::MaxScale = 30000000;
|
2008-05-31 19:21:05 +02:00
|
|
|
|
2008-12-05 21:17:56 +01:00
|
|
|
TimelineWidget::TimelineWidget(
|
2008-12-08 23:30:54 +01:00
|
|
|
shared_ptr<model::Sequence> source_sequence) :
|
2008-05-22 20:19:04 +02:00
|
|
|
Table(2, 2),
|
2008-11-29 17:13:58 +01:00
|
|
|
sequence(source_sequence),
|
2008-12-31 18:05:32 +01:00
|
|
|
layoutHelper(*this),
|
2008-11-19 23:42:38 +01:00
|
|
|
viewWindow(this, 0, 1),
|
2008-08-07 21:27:41 +02:00
|
|
|
selectionStart(0),
|
|
|
|
|
selectionEnd(0),
|
2008-08-30 23:34:26 +02:00
|
|
|
playbackPeriodStart(0),
|
|
|
|
|
playbackPeriodEnd(0),
|
2008-10-07 22:17:29 +02:00
|
|
|
playbackPoint(GAVL_TIME_UNDEFINED),
|
2008-12-30 13:35:58 +01:00
|
|
|
horizontalAdjustment(0, 0, 0),
|
|
|
|
|
verticalAdjustment(0, 0, 0),
|
2008-05-22 20:19:04 +02:00
|
|
|
horizontalScroll(horizontalAdjustment),
|
2008-08-07 21:27:41 +02:00
|
|
|
verticalScroll(verticalAdjustment)
|
2008-06-19 22:57:53 +02:00
|
|
|
{
|
2008-12-05 21:17:56 +01:00
|
|
|
REQUIRE(sequence);
|
2008-11-29 17:13:58 +01:00
|
|
|
|
2009-01-02 17:32:40 +01:00
|
|
|
body = new TimelineBody(*this);
|
2008-06-23 11:54:37 +02:00
|
|
|
ENSURE(body != NULL);
|
2009-01-02 17:15:42 +01:00
|
|
|
headerContainer = new TimelineHeaderContainer(*this);
|
2008-06-23 11:54:37 +02:00
|
|
|
ENSURE(headerContainer != NULL);
|
2009-01-02 17:21:52 +01:00
|
|
|
ruler = new TimelineRuler(*this);
|
2008-08-07 21:27:41 +02:00
|
|
|
ENSURE(ruler != NULL);
|
2008-06-19 22:57:53 +02:00
|
|
|
|
2008-07-17 20:07:38 +02:00
|
|
|
horizontalAdjustment.signal_value_changed().connect( sigc::mem_fun(
|
|
|
|
|
this, &TimelineWidget::on_scroll) );
|
|
|
|
|
verticalAdjustment.signal_value_changed().connect( sigc::mem_fun(
|
|
|
|
|
this, &TimelineWidget::on_scroll) );
|
|
|
|
|
body->signal_motion_notify_event().connect( sigc::mem_fun(
|
|
|
|
|
this, &TimelineWidget::on_motion_in_body_notify_event) );
|
2008-11-19 23:42:38 +01:00
|
|
|
viewWindow.changed_signal().connect( sigc::mem_fun(
|
|
|
|
|
this, &TimelineWidget::on_view_window_changed) );
|
2008-07-24 00:23:48 +02:00
|
|
|
|
2008-11-19 23:42:38 +01:00
|
|
|
viewWindow.set_time_scale(GAVL_TIME_SCALE / 200);
|
2008-08-07 21:27:41 +02:00
|
|
|
set_selection(2000000, 4000000);
|
2008-10-18 00:36:37 +02:00
|
|
|
|
|
|
|
|
update_tracks();
|
|
|
|
|
|
2008-06-19 22:57:53 +02:00
|
|
|
attach(*body, 1, 2, 1, 2, FILL|EXPAND, FILL|EXPAND);
|
2008-08-07 21:27:41 +02:00
|
|
|
attach(*ruler, 1, 2, 0, 1, FILL|EXPAND, SHRINK);
|
2008-06-19 22:57:53 +02:00
|
|
|
attach(*headerContainer, 0, 1, 1, 2, SHRINK, FILL|EXPAND);
|
|
|
|
|
attach(horizontalScroll, 1, 2, 2, 3, FILL|EXPAND, SHRINK);
|
|
|
|
|
attach(verticalScroll, 2, 3, 1, 2, SHRINK, FILL|EXPAND);
|
2008-07-30 01:12:37 +02:00
|
|
|
|
|
|
|
|
set_tool(timeline::Arrow);
|
2008-12-17 01:03:30 +01:00
|
|
|
|
|
|
|
|
// Receive notifications of changes to the tracks
|
|
|
|
|
sequence->get_child_track_list().signal_changed().connect(
|
|
|
|
|
sigc::mem_fun( this, &TimelineWidget::on_track_list_changed ) );
|
2008-06-19 22:57:53 +02:00
|
|
|
}
|
2008-05-31 14:22:15 +02:00
|
|
|
|
|
|
|
|
TimelineWidget::~TimelineWidget()
|
2008-06-19 22:57:53 +02:00
|
|
|
{
|
2008-11-29 17:40:50 +01:00
|
|
|
// Destroy child widgets
|
2008-06-23 11:54:37 +02:00
|
|
|
REQUIRE(body != NULL);
|
2008-07-30 01:12:37 +02:00
|
|
|
if(body != NULL)
|
|
|
|
|
body->unreference();
|
|
|
|
|
|
2008-06-23 11:54:37 +02:00
|
|
|
REQUIRE(headerContainer != NULL);
|
2008-07-30 01:12:37 +02:00
|
|
|
if(headerContainer != NULL)
|
|
|
|
|
headerContainer->unreference();
|
2008-08-07 21:27:41 +02:00
|
|
|
|
|
|
|
|
REQUIRE(ruler != NULL);
|
|
|
|
|
if(ruler != NULL)
|
|
|
|
|
ruler->unreference();
|
2008-06-19 22:57:53 +02:00
|
|
|
}
|
2008-05-31 14:22:15 +02:00
|
|
|
|
2008-11-15 16:17:26 +01:00
|
|
|
/* ===== Data Access ===== */
|
|
|
|
|
|
2008-11-19 23:42:38 +01:00
|
|
|
TimelineViewWindow&
|
|
|
|
|
TimelineWidget::get_view_window()
|
2008-07-30 01:12:37 +02:00
|
|
|
{
|
2008-11-19 23:42:38 +01:00
|
|
|
return viewWindow;
|
2008-07-30 01:12:37 +02:00
|
|
|
}
|
|
|
|
|
|
2008-08-07 21:27:41 +02:00
|
|
|
gavl_time_t
|
|
|
|
|
TimelineWidget::get_selection_start() const
|
2008-07-30 01:12:37 +02:00
|
|
|
{
|
2008-08-07 21:27:41 +02:00
|
|
|
return selectionStart;
|
2008-07-30 01:12:37 +02:00
|
|
|
}
|
2008-08-07 21:27:41 +02:00
|
|
|
|
|
|
|
|
gavl_time_t
|
|
|
|
|
TimelineWidget::get_selection_end() const
|
|
|
|
|
{
|
|
|
|
|
return selectionEnd;
|
|
|
|
|
}
|
|
|
|
|
|
2008-07-30 01:12:37 +02:00
|
|
|
void
|
2008-08-30 23:34:26 +02:00
|
|
|
TimelineWidget::set_selection(gavl_time_t start, gavl_time_t end,
|
|
|
|
|
bool reset_playback_period)
|
2008-07-30 01:12:37 +02:00
|
|
|
{
|
2008-08-30 23:34:26 +02:00
|
|
|
REQUIRE(ruler != NULL);
|
|
|
|
|
REQUIRE(body != NULL);
|
|
|
|
|
|
2008-08-07 21:27:41 +02:00
|
|
|
if(start < end)
|
2008-08-04 17:39:36 +02:00
|
|
|
{
|
2008-08-07 21:27:41 +02:00
|
|
|
selectionStart = start;
|
|
|
|
|
selectionEnd = end;
|
2008-08-04 17:39:36 +02:00
|
|
|
}
|
2008-08-07 21:27:41 +02:00
|
|
|
else
|
2008-07-30 01:12:37 +02:00
|
|
|
{
|
2008-08-07 21:27:41 +02:00
|
|
|
// The selection is back-to-front, flip it round
|
|
|
|
|
selectionStart = end;
|
|
|
|
|
selectionEnd = start;
|
2008-07-30 01:12:37 +02:00
|
|
|
}
|
2008-08-30 23:34:26 +02:00
|
|
|
|
|
|
|
|
if(reset_playback_period)
|
|
|
|
|
{
|
|
|
|
|
playbackPeriodStart = selectionStart;
|
|
|
|
|
playbackPeriodEnd = selectionEnd;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ruler->queue_draw();
|
|
|
|
|
body->queue_draw();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gavl_time_t
|
|
|
|
|
TimelineWidget::get_playback_period_start() const
|
|
|
|
|
{
|
|
|
|
|
return playbackPeriodStart;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gavl_time_t
|
|
|
|
|
TimelineWidget::get_playback_period_end() const
|
|
|
|
|
{
|
|
|
|
|
return playbackPeriodEnd;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
TimelineWidget::set_playback_period(gavl_time_t start, gavl_time_t end)
|
|
|
|
|
{
|
|
|
|
|
REQUIRE(ruler != NULL);
|
|
|
|
|
REQUIRE(body != NULL);
|
|
|
|
|
|
|
|
|
|
if(start < end)
|
|
|
|
|
{
|
|
|
|
|
playbackPeriodStart = start;
|
|
|
|
|
playbackPeriodEnd = end;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// The period is back-to-front, flip it round
|
|
|
|
|
playbackPeriodStart = end;
|
|
|
|
|
playbackPeriodEnd = start;
|
|
|
|
|
}
|
2008-08-07 21:27:41 +02:00
|
|
|
|
|
|
|
|
ruler->queue_draw();
|
|
|
|
|
body->queue_draw();
|
|
|
|
|
}
|
|
|
|
|
|
2008-10-07 22:17:29 +02:00
|
|
|
void
|
|
|
|
|
TimelineWidget::set_playback_point(gavl_time_t point)
|
|
|
|
|
{
|
|
|
|
|
playbackPoint = point;
|
|
|
|
|
ruler->queue_draw();
|
|
|
|
|
body->queue_draw();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gavl_time_t
|
|
|
|
|
TimelineWidget::get_playback_point() const
|
|
|
|
|
{
|
|
|
|
|
return playbackPoint;
|
|
|
|
|
}
|
|
|
|
|
|
2008-08-07 21:27:41 +02:00
|
|
|
ToolType
|
|
|
|
|
TimelineWidget::get_tool() const
|
|
|
|
|
{
|
|
|
|
|
REQUIRE(body != NULL);
|
|
|
|
|
return body->get_tool();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
TimelineWidget::set_tool(ToolType tool_type)
|
|
|
|
|
{
|
|
|
|
|
REQUIRE(body != NULL);
|
|
|
|
|
body->set_tool(tool_type);
|
2008-07-30 01:12:37 +02:00
|
|
|
}
|
|
|
|
|
|
2008-12-08 23:30:54 +01:00
|
|
|
shared_ptr<timeline::Track>
|
2008-11-15 16:17:26 +01:00
|
|
|
TimelineWidget::get_hovering_track() const
|
|
|
|
|
{
|
|
|
|
|
return hoveringTrack;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ===== Signals ===== */
|
|
|
|
|
|
2008-08-16 23:06:46 +02:00
|
|
|
sigc::signal<void, gavl_time_t>
|
|
|
|
|
TimelineWidget::mouse_hover_signal() const
|
|
|
|
|
{
|
|
|
|
|
return mouseHoverSignal;
|
|
|
|
|
}
|
|
|
|
|
|
2008-10-07 22:17:29 +02:00
|
|
|
sigc::signal<void>
|
|
|
|
|
TimelineWidget::playback_period_drag_released_signal() const
|
|
|
|
|
{
|
|
|
|
|
return playbackPeriodDragReleasedSignal;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-08 23:30:54 +01:00
|
|
|
sigc::signal<void, shared_ptr<timeline::Track> >
|
2008-11-15 16:17:26 +01:00
|
|
|
TimelineWidget::hovering_track_changed_signal() const
|
|
|
|
|
{
|
|
|
|
|
return hoveringTrackChangedSignal;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ===== Events ===== */
|
|
|
|
|
|
2008-05-31 14:22:15 +02:00
|
|
|
void
|
|
|
|
|
TimelineWidget::on_scroll()
|
2008-06-19 22:57:53 +02:00
|
|
|
{
|
2008-11-19 23:42:38 +01:00
|
|
|
viewWindow.set_time_offset(horizontalAdjustment.get_value());
|
2008-06-19 22:57:53 +02:00
|
|
|
}
|
2008-06-05 21:27:53 +02:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
TimelineWidget::on_size_allocate(Allocation& allocation)
|
2008-06-19 22:57:53 +02:00
|
|
|
{
|
|
|
|
|
Widget::on_size_allocate(allocation);
|
2008-06-05 21:27:53 +02:00
|
|
|
|
2008-06-19 22:57:53 +02:00
|
|
|
update_scroll();
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-19 23:42:38 +01:00
|
|
|
void
|
|
|
|
|
TimelineWidget::on_view_window_changed()
|
2008-08-07 21:27:41 +02:00
|
|
|
{
|
2008-11-19 23:42:38 +01:00
|
|
|
REQUIRE(ruler != NULL);
|
|
|
|
|
|
|
|
|
|
const int view_width = body->get_allocation().get_width();
|
|
|
|
|
horizontalAdjustment.set_page_size(
|
|
|
|
|
viewWindow.get_time_scale() * view_width);
|
|
|
|
|
horizontalAdjustment.set_value(
|
|
|
|
|
viewWindow.get_time_offset());
|
2008-08-07 21:27:41 +02:00
|
|
|
}
|
|
|
|
|
|
2008-12-17 01:03:30 +01:00
|
|
|
void
|
|
|
|
|
TimelineWidget::on_add_track_command()
|
|
|
|
|
{
|
|
|
|
|
REQUIRE(sequence);
|
|
|
|
|
|
|
|
|
|
// # TEST CODE
|
|
|
|
|
sequence->get_child_track_list().push_back(
|
|
|
|
|
shared_ptr<model::Track>(new model::ClipTrack()));
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-15 16:17:26 +01:00
|
|
|
/* ===== Internals ===== */
|
|
|
|
|
|
2008-05-31 14:22:15 +02:00
|
|
|
void
|
2008-06-05 21:27:53 +02:00
|
|
|
TimelineWidget::update_tracks()
|
2008-11-29 17:13:58 +01:00
|
|
|
{
|
2008-12-05 21:17:56 +01:00
|
|
|
REQUIRE(sequence);
|
2008-11-29 17:13:58 +01:00
|
|
|
|
2008-12-20 15:31:11 +01:00
|
|
|
// Remove any tracks which are no longer present in the model
|
|
|
|
|
remove_orphaned_tracks();
|
|
|
|
|
|
2008-11-29 17:13:58 +01:00
|
|
|
// Create timeline tracks from all the model tracks
|
|
|
|
|
create_timeline_tracks();
|
|
|
|
|
|
|
|
|
|
// Update the header container
|
2008-12-26 19:58:29 +01:00
|
|
|
REQUIRE(headerContainer != NULL);
|
2008-12-20 15:31:11 +01:00
|
|
|
headerContainer->show_all_children();
|
2008-06-19 22:57:53 +02:00
|
|
|
headerContainer->update_headers();
|
|
|
|
|
|
2009-01-02 14:03:00 +01:00
|
|
|
// Update the layout helper
|
|
|
|
|
layoutHelper.clone_tree_from_sequence();
|
|
|
|
|
layoutHelper.update_layout();
|
2008-06-19 22:57:53 +02:00
|
|
|
}
|
2008-11-29 17:13:58 +01:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
TimelineWidget::create_timeline_tracks()
|
|
|
|
|
{
|
2008-12-05 21:17:56 +01:00
|
|
|
REQUIRE(sequence);
|
2008-12-17 01:03:30 +01:00
|
|
|
REQUIRE(headerContainer != NULL);
|
|
|
|
|
REQUIRE(body != NULL);
|
2008-11-29 17:13:58 +01:00
|
|
|
|
2008-12-10 19:09:01 +01:00
|
|
|
BOOST_FOREACH(shared_ptr<model::Track> child,
|
|
|
|
|
sequence->get_child_tracks())
|
2008-12-13 14:57:19 +01:00
|
|
|
create_timeline_tracks_from_branch(child);
|
2008-11-29 17:13:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
TimelineWidget::create_timeline_tracks_from_branch(
|
2008-12-06 15:08:03 +01:00
|
|
|
shared_ptr<model::Track> model_track)
|
2008-11-29 17:13:58 +01:00
|
|
|
{
|
2008-12-06 15:36:29 +01:00
|
|
|
REQUIRE(model_track);
|
2008-11-29 18:02:27 +01:00
|
|
|
|
|
|
|
|
// Is a timeline UI track present in the map already?
|
2008-12-20 12:45:23 +01:00
|
|
|
if(!contains(trackMap, model_track))
|
2008-11-29 17:13:58 +01:00
|
|
|
{
|
2008-11-29 18:02:27 +01:00
|
|
|
// The timeline UI track is not present
|
|
|
|
|
// We will need to create one
|
2008-12-20 12:45:23 +01:00
|
|
|
trackMap[model_track] =
|
2008-11-29 18:02:27 +01:00
|
|
|
create_timeline_track_from_model_track(model_track);
|
2008-11-29 17:13:58 +01:00
|
|
|
}
|
2008-11-29 18:02:27 +01:00
|
|
|
|
|
|
|
|
// Recurse to child tracks
|
2008-12-08 23:30:54 +01:00
|
|
|
BOOST_FOREACH(shared_ptr<model::Track> child,
|
2008-12-06 15:08:03 +01:00
|
|
|
model_track->get_child_tracks())
|
2008-11-29 18:02:27 +01:00
|
|
|
create_timeline_tracks_from_branch(child);
|
2008-11-29 17:13:58 +01:00
|
|
|
}
|
|
|
|
|
|
2008-12-08 23:30:54 +01:00
|
|
|
shared_ptr<timeline::Track>
|
2008-11-29 17:13:58 +01:00
|
|
|
TimelineWidget::create_timeline_track_from_model_track(
|
2008-12-08 23:30:54 +01:00
|
|
|
shared_ptr<model::Track> model_track)
|
2008-11-29 17:13:58 +01:00
|
|
|
{
|
|
|
|
|
REQUIRE(model_track);
|
|
|
|
|
|
2008-11-29 17:40:50 +01:00
|
|
|
// Choose a corresponding timeline track class from the model track's
|
|
|
|
|
// class
|
2008-11-29 17:13:58 +01:00
|
|
|
if(typeid(*model_track) == typeid(model::ClipTrack))
|
2008-12-27 23:02:18 +01:00
|
|
|
return shared_ptr<timeline::Track>(new timeline::ClipTrack(
|
|
|
|
|
*this, model_track));
|
2008-11-29 17:13:58 +01:00
|
|
|
else if(typeid(*model_track) == typeid(model::GroupTrack))
|
2008-12-27 23:02:18 +01:00
|
|
|
return shared_ptr<timeline::Track>(new timeline::GroupTrack(
|
2008-12-30 22:50:18 +01:00
|
|
|
*this, dynamic_pointer_cast<model::GroupTrack>(model_track)));
|
2008-11-29 17:30:45 +01:00
|
|
|
|
|
|
|
|
ASSERT(NULL); // Unknown track type;
|
2008-12-08 23:30:54 +01:00
|
|
|
return shared_ptr<timeline::Track>();
|
2008-11-29 17:13:58 +01:00
|
|
|
}
|
|
|
|
|
|
2008-12-20 15:31:11 +01:00
|
|
|
void
|
|
|
|
|
TimelineWidget::remove_orphaned_tracks()
|
|
|
|
|
{
|
|
|
|
|
REQUIRE(sequence);
|
|
|
|
|
REQUIRE(headerContainer != NULL);
|
|
|
|
|
REQUIRE(body != NULL);
|
|
|
|
|
|
|
|
|
|
std::map<boost::shared_ptr<model::Track>,
|
|
|
|
|
boost::shared_ptr<timeline::Track> >
|
|
|
|
|
orphan_track_map(trackMap);
|
|
|
|
|
|
|
|
|
|
// Remove all tracks which are still present in the sequence
|
|
|
|
|
BOOST_FOREACH(shared_ptr<model::Track> child,
|
|
|
|
|
sequence->get_child_tracks())
|
|
|
|
|
search_orphaned_tracks_in_branch(child, orphan_track_map);
|
|
|
|
|
|
|
|
|
|
// orphan_track_map now contains all the orphaned tracks
|
|
|
|
|
// Remove them
|
|
|
|
|
std::pair<shared_ptr<model::Track>, shared_ptr<timeline::Track> >
|
|
|
|
|
pair;
|
|
|
|
|
BOOST_FOREACH( pair, orphan_track_map )
|
|
|
|
|
{
|
2009-01-05 08:33:15 +01:00
|
|
|
ENSURE(pair.first);
|
2008-12-20 15:31:11 +01:00
|
|
|
trackMap.erase(pair.first);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
TimelineWidget::search_orphaned_tracks_in_branch(
|
|
|
|
|
boost::shared_ptr<model::Track> model_track,
|
|
|
|
|
std::map<boost::shared_ptr<model::Track>,
|
|
|
|
|
boost::shared_ptr<timeline::Track> > &orphan_track_map)
|
|
|
|
|
{
|
|
|
|
|
REQUIRE(model_track);
|
|
|
|
|
|
|
|
|
|
// Is the timeline UI still present?
|
|
|
|
|
if(contains(orphan_track_map, model_track))
|
|
|
|
|
orphan_track_map.erase(model_track);
|
|
|
|
|
|
|
|
|
|
// Recurse to child tracks
|
|
|
|
|
BOOST_FOREACH(shared_ptr<model::Track> child,
|
|
|
|
|
model_track->get_child_tracks())
|
|
|
|
|
search_orphaned_tracks_in_branch(child, orphan_track_map);
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-08 23:30:54 +01:00
|
|
|
shared_ptr<timeline::Track>
|
2008-12-06 15:08:03 +01:00
|
|
|
TimelineWidget::lookup_timeline_track(
|
2008-12-20 12:51:54 +01:00
|
|
|
shared_ptr<model::Track> model_track) const
|
2008-11-29 17:13:58 +01:00
|
|
|
{
|
2008-12-05 21:17:56 +01:00
|
|
|
REQUIRE(sequence);
|
2009-01-01 19:43:46 +01:00
|
|
|
REQUIRE(model_track);
|
|
|
|
|
REQUIRE(model_track != sequence); // The sequence isn't really a track
|
|
|
|
|
|
2008-12-20 12:45:23 +01:00
|
|
|
std::map<shared_ptr<model::Track>, shared_ptr<timeline::Track> >::
|
|
|
|
|
const_iterator iterator = trackMap.find(model_track);
|
2008-11-29 17:13:58 +01:00
|
|
|
if(iterator == trackMap.end())
|
|
|
|
|
{
|
|
|
|
|
// The track is not present in the map
|
|
|
|
|
// We are in an error condition if the timeline track is not found
|
|
|
|
|
// - the timeline tracks must always be synchronous with the model
|
|
|
|
|
// tracks.
|
2008-12-06 15:48:52 +01:00
|
|
|
ENSURE(0);
|
2008-12-08 23:30:54 +01:00
|
|
|
return shared_ptr<timeline::Track>();
|
2008-11-29 17:13:58 +01:00
|
|
|
}
|
|
|
|
|
ENSURE(iterator->second != NULL);
|
|
|
|
|
return iterator->second;
|
|
|
|
|
}
|
2008-12-20 15:31:11 +01:00
|
|
|
|
2008-05-31 14:22:15 +02:00
|
|
|
void
|
2009-01-02 14:03:00 +01:00
|
|
|
TimelineWidget::on_layout_changed()
|
|
|
|
|
{
|
|
|
|
|
REQUIRE(headerContainer != NULL);
|
|
|
|
|
REQUIRE(body != NULL);
|
|
|
|
|
|
2009-01-09 21:02:09 +01:00
|
|
|
headerContainer->on_layout_changed();
|
2009-01-02 14:03:00 +01:00
|
|
|
body->queue_draw();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2008-06-05 21:27:53 +02:00
|
|
|
TimelineWidget::update_scroll()
|
2008-06-19 22:57:53 +02:00
|
|
|
{
|
2008-12-26 19:58:29 +01:00
|
|
|
REQUIRE(body != NULL);
|
2008-06-19 22:57:53 +02:00
|
|
|
const Allocation body_allocation = body->get_allocation();
|
|
|
|
|
|
2008-06-20 00:35:53 +02:00
|
|
|
//----- Horizontal Scroll ------//
|
|
|
|
|
|
2008-07-19 17:35:56 +02:00
|
|
|
// TEST CODE
|
2008-06-23 11:54:37 +02:00
|
|
|
horizontalAdjustment.set_upper(1000 * GAVL_TIME_SCALE / 200);
|
|
|
|
|
horizontalAdjustment.set_lower(-1000 * GAVL_TIME_SCALE / 200);
|
2008-06-20 00:35:53 +02:00
|
|
|
|
2008-07-19 17:35:56 +02:00
|
|
|
// Set the page size
|
|
|
|
|
horizontalAdjustment.set_page_size(
|
2008-11-19 23:42:38 +01:00
|
|
|
viewWindow.get_time_scale() * body_allocation.get_width());
|
2008-07-19 17:35:56 +02:00
|
|
|
|
2008-06-19 22:57:53 +02:00
|
|
|
//----- Vertical Scroll -----//
|
|
|
|
|
|
|
|
|
|
// Calculate the vertical length that can be scrolled:
|
|
|
|
|
// the total height of all the tracks minus one screenful
|
2009-01-01 19:43:46 +01:00
|
|
|
int y_scroll_length = layoutHelper.get_total_height() -
|
|
|
|
|
body_allocation.get_height();
|
2008-06-19 22:57:53 +02:00
|
|
|
if(y_scroll_length < 0) y_scroll_length = 0;
|
|
|
|
|
|
|
|
|
|
// If by resizing we're now over-scrolled, scroll back to
|
|
|
|
|
// maximum distance
|
|
|
|
|
if((int)verticalAdjustment.get_value() > y_scroll_length)
|
|
|
|
|
verticalAdjustment.set_value(y_scroll_length);
|
|
|
|
|
|
|
|
|
|
verticalAdjustment.set_upper(y_scroll_length);
|
|
|
|
|
|
|
|
|
|
// Hide the scrollbar if no scrolling is possible
|
2008-07-24 00:23:48 +02:00
|
|
|
#if 0
|
|
|
|
|
// Having this code included seems to cause a layout loop as the
|
|
|
|
|
// window is shrunk
|
|
|
|
|
if(y_scroll_length <= 0 && verticalScroll.is_visible())
|
2008-06-19 22:57:53 +02:00
|
|
|
verticalScroll.hide();
|
2008-07-24 00:23:48 +02:00
|
|
|
else if(y_scroll_length > 0 && !verticalScroll.is_visible())
|
2008-06-19 22:57:53 +02:00
|
|
|
verticalScroll.show();
|
2008-07-24 00:23:48 +02:00
|
|
|
#endif
|
2008-10-18 00:36:37 +02:00
|
|
|
|
2008-06-19 22:57:53 +02:00
|
|
|
}
|
2008-05-31 14:22:15 +02:00
|
|
|
|
2008-06-05 21:27:53 +02:00
|
|
|
int
|
|
|
|
|
TimelineWidget::get_y_scroll_offset() const
|
2008-06-19 22:57:53 +02:00
|
|
|
{
|
|
|
|
|
return (int)verticalAdjustment.get_value();
|
|
|
|
|
}
|
2008-04-19 21:31:27 +02:00
|
|
|
|
2008-07-17 20:07:38 +02:00
|
|
|
bool
|
|
|
|
|
TimelineWidget::on_motion_in_body_notify_event(GdkEventMotion *event)
|
2008-06-25 21:23:53 +02:00
|
|
|
{
|
2008-07-17 20:07:38 +02:00
|
|
|
REQUIRE(event != NULL);
|
2008-08-07 21:27:41 +02:00
|
|
|
ruler->set_mouse_chevron_offset(event->x);
|
2008-11-19 23:42:38 +01:00
|
|
|
mouseHoverSignal.emit(viewWindow.x_to_time(event->x));
|
2008-10-18 00:36:37 +02:00
|
|
|
|
2008-07-17 20:07:38 +02:00
|
|
|
return true;
|
2008-06-25 21:23:53 +02:00
|
|
|
}
|
|
|
|
|
|
2008-12-17 01:03:30 +01:00
|
|
|
void
|
|
|
|
|
TimelineWidget::on_track_list_changed()
|
|
|
|
|
{
|
|
|
|
|
update_tracks();
|
|
|
|
|
}
|
|
|
|
|
|
2008-10-07 22:17:29 +02:00
|
|
|
void
|
|
|
|
|
TimelineWidget::on_playback_period_drag_released()
|
|
|
|
|
{
|
|
|
|
|
playbackPeriodDragReleasedSignal.emit();
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-15 16:17:26 +01:00
|
|
|
void
|
2008-12-08 23:30:54 +01:00
|
|
|
TimelineWidget::set_hovering_track(
|
|
|
|
|
shared_ptr<timeline::Track> hovering_track)
|
2008-11-15 16:17:26 +01:00
|
|
|
{
|
|
|
|
|
hoveringTrack = hovering_track;
|
|
|
|
|
hoveringTrackChangedSignal.emit(hovering_track);
|
|
|
|
|
}
|
|
|
|
|
|
2008-04-19 21:31:27 +02:00
|
|
|
} // namespace widgets
|
|
|
|
|
} // namespace gui
|