Removed TimelineBody::track_from_point

This commit is contained in:
Joel Holdsworth 2009-01-02 12:41:30 +00:00
parent 86947936a5
commit e135cb18cb
4 changed files with 7 additions and 67 deletions

View file

@ -244,6 +244,7 @@ bool
TimelineBody::on_motion_notify_event(GdkEventMotion *event)
{
REQUIRE(event != NULL);
REQUIRE(timelineWidget != NULL);
// Handle a middle-mouse drag if one is occuring
switch(dragType)
@ -270,8 +271,8 @@ TimelineBody::on_motion_notify_event(GdkEventMotion *event)
tool->on_motion_notify_event(event);
// See if the track that we're hovering over has changed
shared_ptr<timeline::Track> new_hovering_track =
track_from_point(event->y);
shared_ptr<timeline::Track> new_hovering_track(
timelineWidget->layoutHelper.track_from_y(event->y));
if(timelineWidget->get_hovering_track() != new_hovering_track)
timelineWidget->set_hovering_track(new_hovering_track);
@ -446,60 +447,6 @@ TimelineBody::set_vertical_offset(int offset)
timelineWidget->verticalAdjustment.set_value(offset);
}
shared_ptr<timeline::Track>
TimelineBody::track_from_point(const int y) const
{
REQUIRE(timelineWidget != NULL);
REQUIRE(timelineWidget->sequence);
int offset = -get_vertical_offset();
BOOST_FOREACH( shared_ptr<model::Track> model_track,
timelineWidget->sequence->get_child_tracks() )
{
shared_ptr<timeline::Track> result = track_from_branch(
model_track, y, offset);
if(result)
return result;
}
// No track has been found with this point in it
return boost::shared_ptr<timeline::Track>();
}
shared_ptr<timeline::Track> TimelineBody::track_from_branch(
shared_ptr<model::Track> model_track,
const int y, int &offset) const
{
REQUIRE(timelineWidget != NULL);
shared_ptr<timeline::Track> timeline_track = timelineWidget->
lookup_timeline_track(model_track);
const int height = timeline_track->get_height();
REQUIRE(height >= 0);
// Does the point fall in this track?
if(offset <= y && y < offset + height)
return timeline_track;
// Add the height of this track to the accumulation
offset += height;
// Recurse drawing into children
BOOST_FOREACH( shared_ptr<model::Track> child,
model_track->get_child_tracks() )
{
shared_ptr<timeline::Track> result =
track_from_branch(child, y, offset);
if(result != NULL)
return result;
}
// No track has been found in this branch
return shared_ptr<timeline::Track>();
}
void
TimelineBody::register_styles() const
{

View file

@ -139,14 +139,7 @@ private:
int get_vertical_offset() const;
void set_vertical_offset(int offset);
boost::shared_ptr<timeline::Track> track_from_point(const int y)
const;
boost::shared_ptr<timeline::Track> track_from_branch(
boost::shared_ptr<model::Track> model_track,
const int y, int &offset) const;
/**
* Registers all the styles that this class will respond to.
*/

View file

@ -107,7 +107,7 @@ TimelineLayoutHelper::header_from_point(const Gdk::Point &point)
return shared_ptr<timeline::Track>();
}
boost::weak_ptr<timeline::Track>
boost::shared_ptr<timeline::Track>
TimelineLayoutHelper::track_from_y(const int y)
{
std::pair<weak_ptr<timeline::Track>, Gdk::Rectangle> pair;
@ -116,7 +116,7 @@ TimelineLayoutHelper::track_from_y(const int y)
// 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;
return shared_ptr<timeline::Track>(pair.first);
}
// No track was found - return an empty pointer

View file

@ -72,7 +72,7 @@ public:
boost::weak_ptr<timeline::Track> header_from_point(
const Gdk::Point &point);
boost::weak_ptr<timeline::Track> track_from_y(const int y);
boost::shared_ptr<timeline::Track> track_from_y(const int y);
int get_total_height() const;