LUMIERA.clone/src/gui/widgets/timeline-widget.cpp

112 lines
2.9 KiB
C++
Raw Normal View History

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-05-22 20:19:04 +02:00
using namespace Gtk;
2008-05-31 14:22:15 +02:00
using namespace std;
using namespace lumiera::gui::widgets::timeline;
2008-05-22 20:19:04 +02:00
2008-04-19 21:31:27 +02:00
namespace lumiera {
namespace gui {
namespace widgets {
const int TimelineWidget::TrackPadding = 1;
2008-05-22 20:19:04 +02:00
TimelineWidget::TimelineWidget() :
Table(2, 2),
2008-05-31 14:22:15 +02:00
totalHeight(0),
horizontalAdjustment(0, 0, 0),
verticalAdjustment(0, 0, 0),
2008-05-22 20:19:04 +02:00
horizontalScroll(horizontalAdjustment),
verticalScroll(verticalAdjustment),
2008-05-31 14:22:15 +02:00
ruler("ruler")
2008-04-19 21:31:27 +02:00
{
rowHeaderLayout.set_size_request(100, 0);
2008-05-31 14:22:15 +02:00
2008-05-31 18:44:44 +02:00
body = new TimelineBody(this);
2008-05-31 14:22:15 +02:00
verticalAdjustment.signal_value_changed().connect(
sigc::mem_fun(this, &TimelineWidget::on_scroll) );
2008-04-19 21:31:27 +02:00
2008-05-31 14:22:15 +02:00
attach(*body, 1, 2, 1, 2, FILL|EXPAND, FILL|EXPAND);
2008-05-22 20:19:04 +02:00
attach(ruler, 1, 2, 0, 1, FILL|EXPAND, SHRINK);
2008-05-31 14:22:15 +02:00
attach(rowHeaderLayout, 0, 1, 1, 2, SHRINK, FILL|EXPAND);
2008-05-22 20:19:04 +02:00
attach(horizontalScroll, 1, 2, 2, 3, FILL|EXPAND, SHRINK);
attach(verticalScroll, 2, 3, 1, 2, SHRINK, FILL|EXPAND);
2008-05-31 14:22:15 +02:00
tracks.push_back(&video1);
tracks.push_back(&video2);
layout_tracks();
}
TimelineWidget::~TimelineWidget()
{
delete body;
}
void
TimelineWidget::on_scroll()
{
move_headers();
2008-04-19 21:31:27 +02:00
}
2008-05-31 14:22:15 +02:00
void
TimelineWidget::layout_tracks()
{
vector<timeline::Track*>::iterator i;
for(i = tracks.begin(); i != tracks.end(); i++)
{
timeline::Track *track = *i;
g_assert(track != NULL);
rowHeaderLayout.put(track->get_header_widget(), 0, 0);
}
move_headers();
}
2008-04-19 21:31:27 +02:00
2008-05-31 14:22:15 +02:00
void
TimelineWidget::move_headers()
{
int offset = 0;
const int y_scroll_offset = (int)verticalAdjustment.get_value();
vector<Track*>::iterator i;
for(i = tracks.begin(); i != tracks.end(); i++)
{
timeline::Track *track = *i;
g_assert(track != NULL);
const int height = track->get_track_height();
rowHeaderLayout.move(track->get_header_widget(), 0, offset - y_scroll_offset);
offset += height + TrackPadding;
2008-05-31 14:22:15 +02:00
}
totalHeight = offset;
verticalAdjustment.set_upper(totalHeight);
}
2008-04-19 21:31:27 +02:00
} // namespace widgets
} // namespace gui
} // namespace lumiera