Transitioned TimelineBody drawing code to use the TimelineLayoutHelper
This commit is contained in:
parent
9fac0b8b46
commit
bcd5dababe
4 changed files with 47 additions and 17 deletions
|
|
@ -287,26 +287,46 @@ TimelineBody::draw_tracks(Cairo::RefPtr<Cairo::Context> cr)
|
||||||
REQUIRE(timelineWidget->sequence);
|
REQUIRE(timelineWidget->sequence);
|
||||||
|
|
||||||
// Prepare
|
// Prepare
|
||||||
|
TimelineLayoutHelper &layout_helper = timelineWidget->layoutHelper;
|
||||||
|
const TimelineLayoutHelper::TrackTree &layout_tree =
|
||||||
|
layout_helper.get_layout_tree();
|
||||||
const Allocation allocation = get_allocation();
|
const Allocation allocation = get_allocation();
|
||||||
|
|
||||||
// Save the view matrix
|
// Save the view matrix
|
||||||
Cairo::Matrix view_matrix;
|
Cairo::Matrix view_matrix;
|
||||||
cr->get_matrix(view_matrix);
|
cr->get_matrix(view_matrix);
|
||||||
|
|
||||||
// Translate the view by the scroll distance
|
// Iterate drawing each track
|
||||||
cr->translate(0, -get_vertical_offset());
|
TimelineLayoutHelper::TrackTree::pre_order_iterator iterator;
|
||||||
|
for(iterator = ++layout_tree.begin(); // ++ so we skip the sequence root
|
||||||
|
iterator != layout_tree.end();
|
||||||
|
iterator++)
|
||||||
|
{
|
||||||
|
const shared_ptr<model::Track> model_track(*iterator);
|
||||||
|
const shared_ptr<timeline::Track> timeline_track =
|
||||||
|
timelineWidget->lookup_timeline_track(*iterator);
|
||||||
|
|
||||||
// Interate drawing each track
|
optional<Gdk::Rectangle> rect =
|
||||||
BOOST_FOREACH( shared_ptr<model::Track> model_track,
|
layout_helper.get_track_header_rect(timeline_track);
|
||||||
timelineWidget->sequence->get_child_tracks() )
|
|
||||||
draw_track_recursive(cr, model_track, allocation.get_width());
|
// Is this track visible?
|
||||||
|
if(rect)
|
||||||
|
{
|
||||||
|
// Translate to the top of the track
|
||||||
|
cr->set_matrix(view_matrix);
|
||||||
|
cr->translate(0, rect->get_y());
|
||||||
|
|
||||||
|
// Draw the track
|
||||||
|
draw_track(cr, model_track, allocation.get_width());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Restore the view matrix
|
// Restore the view matrix
|
||||||
cr->set_matrix(view_matrix);
|
cr->set_matrix(view_matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
TimelineBody::draw_track_recursive(Cairo::RefPtr<Cairo::Context> cr,
|
TimelineBody::draw_track(Cairo::RefPtr<Cairo::Context> cr,
|
||||||
shared_ptr<model::Track> model_track, const int view_width) const
|
shared_ptr<model::Track> model_track, const int view_width) const
|
||||||
{
|
{
|
||||||
REQUIRE(cr);
|
REQUIRE(cr);
|
||||||
|
|
@ -329,14 +349,6 @@ TimelineBody::draw_track_recursive(Cairo::RefPtr<Cairo::Context> cr,
|
||||||
cr->save();
|
cr->save();
|
||||||
timeline_track->draw_track(cr, &timelineWidget->get_view_window());
|
timeline_track->draw_track(cr, &timelineWidget->get_view_window());
|
||||||
cr->restore();
|
cr->restore();
|
||||||
|
|
||||||
// Shift for the next track
|
|
||||||
cr->translate(0, height + TimelineWidget::TrackPadding);
|
|
||||||
|
|
||||||
// Recurse drawing into children
|
|
||||||
BOOST_FOREACH( shared_ptr<model::Track> child,
|
|
||||||
model_track->get_child_tracks() )
|
|
||||||
draw_track_recursive(cr, child, view_width);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
|
|
@ -118,7 +118,7 @@ private:
|
||||||
*/
|
*/
|
||||||
void draw_tracks(Cairo::RefPtr<Cairo::Context> cr);
|
void draw_tracks(Cairo::RefPtr<Cairo::Context> cr);
|
||||||
|
|
||||||
void draw_track_recursive(Cairo::RefPtr<Cairo::Context> cr,
|
void draw_track(Cairo::RefPtr<Cairo::Context> cr,
|
||||||
boost::shared_ptr<model::Track> track, const int view_width) const;
|
boost::shared_ptr<model::Track> track, const int view_width) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -107,6 +107,22 @@ TimelineLayoutHelper::header_from_point(const Gdk::Point &point)
|
||||||
return shared_ptr<timeline::Track>();
|
return shared_ptr<timeline::Track>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boost::weak_ptr<timeline::Track>
|
||||||
|
TimelineLayoutHelper::track_from_y(const int y)
|
||||||
|
{
|
||||||
|
std::pair<weak_ptr<timeline::Track>, Gdk::Rectangle> pair;
|
||||||
|
BOOST_FOREACH( pair, headerBoxes )
|
||||||
|
{
|
||||||
|
// Hit test the rectangle
|
||||||
|
const Gdk::Rectangle &rect = pair.second;
|
||||||
|
if(y >= rect.get_y() && y < rect.get_y() + rect.get_height())
|
||||||
|
return pair.first;
|
||||||
|
}
|
||||||
|
|
||||||
|
// No track was found - return an empty pointer
|
||||||
|
return shared_ptr<timeline::Track>();
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
TimelineLayoutHelper::get_total_height() const
|
TimelineLayoutHelper::get_total_height() const
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,8 @@ public:
|
||||||
boost::weak_ptr<timeline::Track> header_from_point(
|
boost::weak_ptr<timeline::Track> header_from_point(
|
||||||
const Gdk::Point &point);
|
const Gdk::Point &point);
|
||||||
|
|
||||||
|
boost::weak_ptr<timeline::Track> track_from_y(const int y);
|
||||||
|
|
||||||
int get_total_height() const;
|
int get_total_height() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue